Rocket: error : cannot resolve `std::borrow::Cow<'_, str>: std::borrow::Borrow<_>

Created on 19 May 2018  路  10Comments  路  Source: SergioBenitez/Rocket

rocket version : 0.3.10
rustc version : 1.28.0-nightly
i am getting started into rocket .
i have installation as in docs and downloaded examples from git .
when i entered cargo run .
i see

 type annotations required: cannot resolve `std::borrow::Cow<'_, str>: std::borrow::Borrow<_>`
   --> lib/src/http/header.rs:544:47
    |
544 |                 Header::new(key.as_str(), val.borrow())
    |                                               ^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0283`.
error: Could not compile `rocket`.
i tied to switch to other versions and i faced more error in previous versions.
if this issue is already in progress . please provide link or reference 

Most helpful comment

Fixed in ff5db841114d8da1a17b723808501c756df57c64. Will push a new release with this fix soon.

Edit: Released in v0.3.11.

All 10 comments

I get this at rustc 1.28.0-nightly (952f344cd 2018-05-18)

Hi Sergio,

The same problem :-(

stable-x86_64-apple-darwin unchanged - rustc 1.26.0 (a77568041 2018-05-07)
nightly-x86_64-apple-darwin unchanged - rustc 1.28.0-nightly (952f344cd 2018-05-18)

rustup override set nightly
rustup update && cargo update

But no results:

screen shot 2018-05-19 at 14 31 19

Having the same problem, tried to downgrade to version 0.3.6, cargo does not like this.

Running the following nightly version:

  • cargo 1.28.0-nightly (f352115d5 2018-05-15)
  • rustc 1.28.0-nightly (952f344cd 2018-05-18)

capture

my temporary solution is to downgrade:

rustup toolchain install nightly-2018-05-17
rustup default nightly-2018-05-17

Looks like something has changed with type inference, but I can't tell what. Changing https://github.com/SergioBenitez/Rocket/blob/v0.3/lib/src/http/header.rs#L544 from val.borrow() to &**val (which is what Cow::borrow() does anyway) appears to compile successfully.

EDIT: hypothetical reason for the error -- Header::new wants any Into<Cow<'_, str>>, and there might be multiple valid things to borrow() out of a Cow<'_, str> especially given that it impls Deref. Borrow::<str>::borrow(val) is another way to resolve the ambiguity.

is this resolved ?

Not yet #644 isn't merged yet

did downgrading worked for anyone ?

Downgrading fixed the problem

Try this: rustup override set nightly-2018-05-17

Fixed in ff5db841114d8da1a17b723808501c756df57c64. Will push a new release with this fix soon.

Edit: Released in v0.3.11.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kitsuneninetails picture kitsuneninetails  路  4Comments

Ronaldho80 picture Ronaldho80  路  3Comments

Hokutosei picture Hokutosei  路  4Comments

GoRustafari picture GoRustafari  路  3Comments

sphinxc0re picture sphinxc0re  路  3Comments