Repository navigation
Anon lifetime in impl Trait no longer suggests adding a lifetime parameter #100615
Description
Activity
- addedA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
on Aug 16, 2022 - addedI-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}Issue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
on Aug 16, 2022 WG-prioritization assigning priority (Zulip discussion).
@rustbot label -I-prioritize +P-high
- addedP-highHigh priorityHigh priorityand removedI-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}Issue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
on Aug 17, 2022 self-assigning to ensure we record a cargo-bisect to the injecting PR
I went ahead and attempted a bisection. The breadcrumbs seem to lead to rollup of #99231 with possibly #97720 being the patchset where this issue originates cc @cjgillot ?
searched nightlies: from nightly-2022-07-13 to nightly-2022-07-15
regressed nightly: nightly-2022-07-15
searched commit range: 87588a2...c2f428d
regressed commit: f1a8854bisected with cargo-bisect-rustc v0.6.3
Host triple: x86_64-unknown-linux-gnu
Reproduce with:cargo bisect-rustc --start 2022-07-13 --end 2022-07-15 --preserve
I'm not sure what would be wrong after @cjgillot change. I think this is exactly the support Camille has added. If you use
#![feature(anonymous_lifetime_in_impl_trait)]the example compiles and if you don't the error points to the anonymous lifetime and tells you that you would need the feature flag to support such case.Added an explanation in #85417 (comment).
TLDR: I proposed to allow this syntax, we made a feature gate instead, and I forgot to put back the suggestion.Reacted by Santiago Pastorino6 remaining items
- addedE-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.
on Sep 22, 2022 Hello, I would like to work on this. So far I've been able to get this kind of output
error[E0106]: missing lifetime specifier --> test.rs:1:32 | 1 | fn foo(_: impl Iterator<Item = & u32>) {} | ^ expected named lifetime parameter | help: consider introducing a named lifetime parameter --> test.rs:1:7 | 1 | fn foo(_: impl Iterator<Item = & u32>) {} | ^with the input found in the original message.
I am looping over all generic params and checking if the full
<...>span doesn't contain thespanassociated with the parameter, at which point I try to suggest the introduction of the named lifetime parameter.I'm looking for a few pointers on:
- If my logic actually makes sense
- what other suggestions
rustc_resolve::late::lifetimes::resolve_lifetime_refshould handle. - how to properly emit the errors/suggestions (I see that late/diagnostics.rs also does similar suggestions but I'm unsure if/how I should use it)
@Stoozy could you open a PR with what you have and tag me? Discussing on code will be more concrete and easier.
@Stoozy Another friendly tip: when you want to undertake an issue, you should claim the issue first to prevent duplicated effort (Write the command shown below in the target issue as a comment to assign urself). Thanks.
@Stoozy can you call
LateResolutionVisitor::suggest_introducing_lifetime(or split part of its body to make it appropriate for this case too) and reuse that logic?@rustbot claim
Reacted by Rageking8Closed by #102323? Or is there more to do?

Given
fn foo(_: impl Iterator<Item = &u32>) {}.In 1.63:
In 1.64: