Skip to content

Conversation

@enthropy7
Copy link
Contributor

@enthropy7 enthropy7 commented Jan 27, 2026

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 #151663

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 27, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 27, 2026

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

@enthropy7 enthropy7 force-pushed the fix-refining-impl-trait-rtn branch from fb2bd79 to 34c9ebf Compare January 27, 2026 15:42
hir::FnRetTy::DefaultReturn(_) => tcx.def_span(trait_m_def_id),
hir::FnRetTy::Return(ty) => ty.span,
});

Copy link
Member

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).

Copy link
Contributor Author

@enthropy7 enthropy7 Jan 27, 2026

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.

@enthropy7 enthropy7 force-pushed the fix-refining-impl-trait-rtn branch from 34c9ebf to a7458f5 Compare January 27, 2026 19:09
@rust-log-analyzer

This comment has been minimized.

@enthropy7 enthropy7 force-pushed the fix-refining-impl-trait-rtn branch 2 times, most recently from c81c4d4 to 8c9c35e Compare January 27, 2026 19:51
@rust-log-analyzer

This comment has been minimized.

@enthropy7 enthropy7 force-pushed the fix-refining-impl-trait-rtn branch from 8c9c35e to e9229ca Compare January 27, 2026 21:52
@enthropy7 enthropy7 force-pushed the fix-refining-impl-trait-rtn branch from e9229ca to 849725e Compare January 27, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lint group refining_impl_trait: Enabling return_type_notation negatively affects the suggested fix

5 participants