2016-11-01 15:00:24 +00:00
|
|
|
error[E0308]: mismatched types
|
2018-12-25 15:56:47 +00:00
|
|
|
--> $DIR/coerce-suggestions.rs:7:20
|
2016-11-01 15:00:24 +00:00
|
|
|
|
|
2018-02-23 00:42:32 +00:00
|
|
|
LL | let x: usize = String::new();
|
2016-11-01 15:00:24 +00:00
|
|
|
| ^^^^^^^^^^^^^ expected usize, found struct `std::string::String`
|
|
|
|
|
|
|
|
|
= note: expected type `usize`
|
2017-01-11 21:55:41 +00:00
|
|
|
found type `std::string::String`
|
2016-11-01 15:00:24 +00:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2018-12-25 15:56:47 +00:00
|
|
|
--> $DIR/coerce-suggestions.rs:9:19
|
2016-11-01 15:00:24 +00:00
|
|
|
|
|
2018-02-23 00:42:32 +00:00
|
|
|
LL | let x: &str = String::new();
|
2017-11-25 14:00:26 +00:00
|
|
|
| ^^^^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| expected &str, found struct `std::string::String`
|
|
|
|
| help: consider borrowing here: `&String::new()`
|
2016-11-01 15:00:24 +00:00
|
|
|
|
|
|
|
|
= note: expected type `&str`
|
2017-01-11 21:55:41 +00:00
|
|
|
found type `std::string::String`
|
2016-11-01 15:00:24 +00:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2018-12-25 15:56:47 +00:00
|
|
|
--> $DIR/coerce-suggestions.rs:12:10
|
2016-11-01 15:00:24 +00:00
|
|
|
|
|
2018-02-23 00:42:32 +00:00
|
|
|
LL | test(&y);
|
2016-11-01 15:00:24 +00:00
|
|
|
| ^^ types differ in mutability
|
|
|
|
|
|
|
|
|
= note: expected type `&mut std::string::String`
|
2017-01-11 21:55:41 +00:00
|
|
|
found type `&std::string::String`
|
2016-11-01 15:00:24 +00:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2018-12-25 15:56:47 +00:00
|
|
|
--> $DIR/coerce-suggestions.rs:14:11
|
2016-11-01 15:00:24 +00:00
|
|
|
|
|
2018-02-23 00:42:32 +00:00
|
|
|
LL | test2(&y);
|
2016-11-01 15:00:24 +00:00
|
|
|
| ^^ types differ in mutability
|
|
|
|
|
|
|
|
|
= note: expected type `&mut i32`
|
2017-01-11 21:55:41 +00:00
|
|
|
found type `&std::string::String`
|
2016-11-01 15:00:24 +00:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2018-12-25 15:56:47 +00:00
|
|
|
--> $DIR/coerce-suggestions.rs:17:9
|
2016-11-01 15:00:24 +00:00
|
|
|
|
|
2018-02-23 00:42:32 +00:00
|
|
|
LL | f = box f;
|
type error method suggestions use whitelisted identity-like conversions
Previously, on a type mismatch (and if this wasn't preëmpted by a
higher-priority suggestion), we would look for argumentless methods
returning the expected type, and list them in a `help` note.
This had two major shortcomings. Firstly, a lot of the suggestions didn't
really make sense (if you used a &str where a String was expected,
`.to_ascii_uppercase()` is probably not the solution you were hoping
for). Secondly, we weren't generating suggestions from the most useful
traits!
We address the first problem with an internal
`#[rustc_conversion_suggestion]` attribute meant to mark methods that keep
the "same value" in the relevant sense, just converting the type. We
address the second problem by making `FnCtxt.probe_for_return_type` pass
the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe
because grep reveals no other callers of `probe_for_return_type`.
Also, structured suggestions are preferred (because they're pretty, but
also for RLS and friends).
Also also, we make the E0055 autoderef recursion limit error use the
one-time-diagnostics set, because we can potentially hit the limit a lot
during probing. (Without this,
test/ui/did_you_mean/recursion_limit_deref.rs would report "aborting due to
51 errors").
Unfortunately, the trait probing is still not all one would hope for: at a
minimum, we don't know how to rule out `into()` in cases where it wouldn't
actually work, and we don't know how to rule in `.to_owned()` where it
would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME.
This is hoped to resolve #42929, #44672, and #45777.
2017-11-19 19:25:35 +00:00
|
|
|
| ^^^^^
|
|
|
|
| |
|
|
|
|
| cyclic type of infinite size
|
2019-10-01 09:00:22 +00:00
|
|
|
| help: try using a conversion method: `(box f).to_string()`
|
2016-11-01 15:00:24 +00:00
|
|
|
|
2017-06-01 06:48:19 +00:00
|
|
|
error[E0308]: mismatched types
|
2018-12-25 15:56:47 +00:00
|
|
|
--> $DIR/coerce-suggestions.rs:21:9
|
2017-06-01 06:48:19 +00:00
|
|
|
|
|
2018-02-23 00:42:32 +00:00
|
|
|
LL | s = format!("foo");
|
2019-03-28 00:04:58 +00:00
|
|
|
| ^^^^^^^^^^^^^^ expected mutable reference, found struct `std::string::String`
|
2017-06-01 06:48:19 +00:00
|
|
|
|
|
|
|
|
= note: expected type `&mut std::string::String`
|
|
|
|
found type `std::string::String`
|
2017-11-21 19:48:35 +00:00
|
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
2017-06-01 06:48:19 +00:00
|
|
|
|
2017-07-02 10:49:30 +00:00
|
|
|
error: aborting due to 6 previous errors
|
2016-11-01 15:00:24 +00:00
|
|
|
|
2018-03-03 14:59:40 +00:00
|
|
|
For more information about this error, try `rustc --explain E0308`.
|