fix refining_impl_trait suggestion with return_type_notation#151744
fix refining_impl_trait suggestion with return_type_notation#151744enthropy7 wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
r? @davidtwco rustbot has assigned @davidtwco. Use |
This comment has been minimized.
This comment has been minimized.
fb2bd79 to
34c9ebf
Compare
| @@ -332,6 +332,16 @@ fn report_mismatched_rpitit_signature<'tcx>( | |||
| hir::FnRetTy::Return(ty) => ty.span, | |||
| }); | |||
|
|
|||
There was a problem hiding this comment.
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.
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.
e9229ca to
849725e
Compare
|
@bors r+ rollup |
…rtn, r=davidtwco fix refining_impl_trait suggestion with return_type_notation using `#![feature(return_type_notation)] `on top of `refining_impl_trait` made 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 help new test here fixes rust-lang#151663
…uwer Rollup of 9 pull requests Successful merges: - #151278 (Provide more context on trait bounds being unmet due to imperfect derive) - #151955 (escape symbol names in global asm) - #149329 (Mark match arms in try and for as being from desugarings.) - #151474 (Minor structural improvements) - #151744 (fix refining_impl_trait suggestion with return_type_notation) - #152107 (Convert to inline diagnostics in `rustc_borrowck`) - #152117 (Convert to inline diagnostics in `rustc_trait_selection`) - #152136 (Consolidate type const checks on `tcx.is_type_const`) - #152170 (Port `rustc_effective_visibility` to the new attribute parser)
…uwer Rollup of 9 pull requests Successful merges: - #151278 (Provide more context on trait bounds being unmet due to imperfect derive) - #151955 (escape symbol names in global asm) - #149329 (Mark match arms in try and for as being from desugarings.) - #151474 (Minor structural improvements) - #151744 (fix refining_impl_trait suggestion with return_type_notation) - #152107 (Convert to inline diagnostics in `rustc_borrowck`) - #152117 (Convert to inline diagnostics in `rustc_trait_selection`) - #152136 (Consolidate type const checks on `tcx.is_type_const`) - #152170 (Port `rustc_effective_visibility` to the new attribute parser)
…rtn, r=davidtwco fix refining_impl_trait suggestion with return_type_notation using `#![feature(return_type_notation)] `on top of `refining_impl_trait` made 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 help new test here fixes rust-lang#151663
…uwer Rollup of 11 pull requests Successful merges: - #152174 (stdarch subtree update) - #151278 (Provide more context on trait bounds being unmet due to imperfect derive) - #151955 (escape symbol names in global asm) - #149329 (Mark match arms in try and for as being from desugarings.) - #151474 (Minor structural improvements) - #151744 (fix refining_impl_trait suggestion with return_type_notation) - #152107 (Convert to inline diagnostics in `rustc_borrowck`) - #152117 (Convert to inline diagnostics in `rustc_trait_selection`) - #152136 (Consolidate type const checks on `tcx.is_type_const`) - #152170 (Port `rustc_effective_visibility` to the new attribute parser) - #152184 (Port rustc_abi to the attribute parser)
…uwer Rollup of 11 pull requests Successful merges: - #152174 (stdarch subtree update) - #151278 (Provide more context on trait bounds being unmet due to imperfect derive) - #151955 (escape symbol names in global asm) - #149329 (Mark match arms in try and for as being from desugarings.) - #151474 (Minor structural improvements) - #151744 (fix refining_impl_trait suggestion with return_type_notation) - #152107 (Convert to inline diagnostics in `rustc_borrowck`) - #152117 (Convert to inline diagnostics in `rustc_trait_selection`) - #152136 (Consolidate type const checks on `tcx.is_type_const`) - #152170 (Port `rustc_effective_visibility` to the new attribute parser) - #152184 (Port rustc_abi to the attribute parser)
…uwer Rollup of 11 pull requests Successful merges: - #152174 (stdarch subtree update) - #151278 (Provide more context on trait bounds being unmet due to imperfect derive) - #151955 (escape symbol names in global asm) - #149329 (Mark match arms in try and for as being from desugarings.) - #151474 (Minor structural improvements) - #151744 (fix refining_impl_trait suggestion with return_type_notation) - #152107 (Convert to inline diagnostics in `rustc_borrowck`) - #152117 (Convert to inline diagnostics in `rustc_trait_selection`) - #152136 (Consolidate type const checks on `tcx.is_type_const`) - #152170 (Port `rustc_effective_visibility` to the new attribute parser) - #152184 (Port rustc_abi to the attribute parser)
…rtn, r=davidtwco fix refining_impl_trait suggestion with return_type_notation using `#![feature(return_type_notation)] `on top of `refining_impl_trait` made 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 help new test here fixes rust-lang#151663
…rtn, r=davidtwco fix refining_impl_trait suggestion with return_type_notation using `#![feature(return_type_notation)] `on top of `refining_impl_trait` made 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 help new test here fixes rust-lang#151663
…uwer Rollup of 13 pull requests Successful merges: - #152191 (Convert to inline diagnostics in `rustc_hir_analysis`) - #149329 (Mark match arms in try and for as being from desugarings.) - #151474 (Minor structural improvements) - #152107 (Convert to inline diagnostics in `rustc_borrowck`) - #152117 (Convert to inline diagnostics in `rustc_trait_selection`) - #152136 (Consolidate type const checks on `tcx.is_type_const`) - #152140 (Hard code the error code registry for custom drivers) - #152155 (Fix typos in riscv64a23-unknown-linux-gnu.md) - #152170 (Port `rustc_effective_visibility` to the new attribute parser) - #152182 (update compiler stable backport zulip msg) - #152184 (Port rustc_abi to the attribute parser) - #152195 (update openmp/offload builds to LLVM 22, Part 1) - #152202 (chore: clearify tidy's error message) Failed merges: - #151744 (fix refining_impl_trait suggestion with return_type_notation) - #152212 (Port some attributes to the attr parser)
This comment has been minimized.
This comment has been minimized.
849725e to
bcde3fc
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
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