-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
fix refining_impl_trait suggestion with return_type_notation #151744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
r? @davidtwco rustbot has assigned @davidtwco. Use |
This comment has been minimized.
This comment has been minimized.
fb2bd79 to
34c9ebf
Compare
| hir::FnRetTy::DefaultReturn(_) => tcx.def_span(trait_m_def_id), | ||
| hir::FnRetTy::Return(ty) => ty.span, | ||
| }); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm interested in the reason why the type gets printed that way under RTN. I would look in the HIR pretty printer to look for the culprit. Once identified, there might be a more robust solution because using span_to_snippet is more like hot patching the bug (e.g., if the source is not available (so None) I'm pretty sure we will continue to print the type that way under RTN).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty_print_rpitit used RtnMode::ForDiagnostic by default. it gives impl Trait { T::method(..) } while RTN.
34c9ebf to
a7458f5
Compare
This comment has been minimized.
This comment has been minimized.
c81c4d4 to
8c9c35e
Compare
This comment has been minimized.
This comment has been minimized.
8c9c35e to
e9229ca
Compare
e9229ca to
849725e
Compare
using
#![feature(return_type_notation)]on top ofrefining_impl_traitmade the lint suggest a pretty wild “wrap the body in<Self as Trait>::f(..)”fix instead of the simple “just copy the return type from the trait”. this patch makes the lint always suggest the plain return-type replacement based on the trait signature (by grabbing the original snippet when possible), so you don’t get RTN-style desugarings in the helpnew test here
fixes #151663