Skip to content

keep the use<..> bound in the refining_impl_trait suggestion - #162575

Open
Albab-Hasan wants to merge 1 commit into
rust-lang:mainfrom
Albab-Hasan:refine-suggestion-precise-capturing
Open

keep the use<..> bound in the refining_impl_trait suggestion#162575
Albab-Hasan wants to merge 1 commit into
rust-lang:mainfrom
Albab-Hasan:refine-suggestion-precise-capturing

Conversation

@Albab-Hasan

@Albab-Hasan Albab-Hasan commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

the suggestion formats the traits RPITIT and Display doesnt print use<..> so impl use<Self> + Send renders as impl std::marker::Send. applying it makes the impl capture the elided &self lifetime which doesnt compile. new helper re emits the capture list when the trait dropped a lifetime.

one note. no existing baselines were re blessed so the new test is the only in tree coverage of an undercapturing RPITIT.

fixes #141047

r? @davidtwco

the lint suggested a return type built only from the trait bounds, so the precise capturing list was dropped. applying the suggestion then captured every lifetime in scope and failed to compile with "return type captures more lifetimes than trait definition".

the suggestion now carries the capture list over, written in terms of the impl generics. a use<..> bound is only added when the trait opaque leaves out one of the method late bound lifetimes, since everything else already has to be listed in the trait.

fixes rust-lang#141047
@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 Sep 10, 2026
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.

refining_impl_trait: The suggested fix does not yet take precise capturing into account.

3 participants