You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0308]: mismatched types
--> src/main.rs:2:21
|
2 | let s: String = &String::from("hello");
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| expected struct `std::string::String`, found reference
| help: consider removing the borrow: `String::from("hello")`
|
= note: expected type `std::string::String`
found type `&std::string::String`
error[E0308]: mismatched types
--> src/main.rs:3:21
|
3 | let r: String = &format!("hello");
| ^^^^^^^^^^^^^^^^^
| |
| expected struct `std::string::String`, found reference
| help: try using a conversion method: `&format!("hello").to_string()`
|
= note: expected type `std::string::String`
found type `&std::string::String`
error: aborting due to 2 previous errors
Notice that the String expression correctly suggests removing the borrow, but the format! expression incorrectly suggests adding to_string(), which does not fix the error.
The text was updated successfully, but these errors were encountered:
euclio
changed the title
Incorrect diagnostic suggestion for borrowed macro result
Incorrect diagnostic suggestion for borrowed macro expression
Feb 28, 2019
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=d0c29d2300d97268198951d9ea5252d7
For the following code:
We get the following diagnostics:
Notice that the String expression correctly suggests removing the borrow, but the
format!
expression incorrectly suggests addingto_string()
, which does not fix the error.The text was updated successfully, but these errors were encountered: