rust/src/test/ui/deref-suggestion.stderr

93 lines
2.8 KiB
Plaintext
Raw Normal View History

2017-08-14 17:21:36 -05:00
error[E0308]: mismatched types
2018-12-25 09:56:47 -06:00
--> $DIR/deref-suggestion.rs:8:9
2017-08-14 17:21:36 -05:00
|
2018-08-26 18:54:06 -05:00
LL | foo(s);
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 13:25:35 -06:00
| ^
| |
| expected struct `std::string::String`, found &std::string::String
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 13:25:35 -06:00
| help: try using a conversion method: `s.to_string()`
2017-08-14 17:21:36 -05:00
error[E0308]: mismatched types
2018-12-25 09:56:47 -06:00
--> $DIR/deref-suggestion.rs:14:10
2017-08-14 17:21:36 -05:00
|
2018-08-26 18:54:06 -05:00
LL | foo3(u);
| ^
| |
| expected u32, found &u32
| help: consider dereferencing the borrow: `*u`
2017-08-14 17:21:36 -05:00
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:30:9
2017-08-14 17:21:36 -05:00
|
2018-08-26 18:54:06 -05:00
LL | foo(&"aaa".to_owned());
| ^^^^^^^^^^^^^^^^^
| |
| expected struct `std::string::String`, found &std::string::String
| help: consider removing the borrow: `"aaa".to_owned()`
2017-08-14 17:21:36 -05:00
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:32:9
2017-08-14 17:21:36 -05:00
|
2018-08-26 18:54:06 -05:00
LL | foo(&mut "aaa".to_owned());
| ^^^^^^^^^^^^^^^^^^^^^
| |
| expected struct `std::string::String`, found &mut std::string::String
| help: consider removing the borrow: `"aaa".to_owned()`
2017-08-14 17:21:36 -05:00
error[E0308]: mismatched types
2018-12-25 09:56:47 -06:00
--> $DIR/deref-suggestion.rs:2:20
2017-08-14 17:21:36 -05:00
|
2019-03-09 06:03:44 -06:00
LL | ($x:expr) => { &$x }
2017-08-14 17:21:36 -05:00
| ^^^ expected u32, found &{integer}
...
2018-02-22 18:42:32 -06:00
LL | foo3(borrow!(0));
2017-08-14 17:21:36 -05:00
| ---------- in this macro invocation
2018-08-26 18:54:06 -05:00
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:36:5
2018-08-26 18:54:06 -05:00
|
LL | assert_eq!(3i32, &3i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found &i32
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:39:17
|
LL | let s = S { u };
| ^
| |
| expected &u32, found integer
| help: consider borrowing here: `u: &u`
error[E0308]: mismatched types
2019-03-26 21:07:15 -05:00
--> $DIR/deref-suggestion.rs:41:20
|
LL | let s = S { u: u };
| ^
| |
| expected &u32, found integer
| help: consider borrowing here: `&u`
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:44:17
|
LL | let r = R { i };
| ^
| |
| expected u32, found &{integer}
| help: consider dereferencing the borrow: `i: *i`
2019-03-26 21:07:15 -05:00
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:46:20
|
LL | let r = R { i: i };
| ^
| |
| expected u32, found &{integer}
| help: consider dereferencing the borrow: `*i`
error: aborting due to 10 previous errors
2017-08-14 17:21:36 -05:00
2018-03-03 08:59:40 -06:00
For more information about this error, try `rustc --explain E0308`.