aba56ddd05
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.
24 lines
795 B
Plaintext
24 lines
795 B
Plaintext
error[E0055]: reached the recursion limit while auto-dereferencing I
|
|
--> $DIR/recursion_limit_deref.rs:62:22
|
|
|
|
|
62 | let x: &Bottom = &t; //~ ERROR mismatched types
|
|
| ^^ deref recursion limit reached
|
|
|
|
|
= help: consider adding a `#![recursion_limit="20"]` attribute to your crate
|
|
|
|
error[E0055]: reached the recursion limit while auto-dereferencing I
|
|
|
|
|
= help: consider adding a `#![recursion_limit="20"]` attribute to your crate
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/recursion_limit_deref.rs:62:22
|
|
|
|
|
62 | let x: &Bottom = &t; //~ ERROR mismatched types
|
|
| ^^ expected struct `Bottom`, found struct `Top`
|
|
|
|
|
= note: expected type `&Bottom`
|
|
found type `&Top`
|
|
|
|
error: aborting due to 3 previous errors
|
|
|