Skip to content

Anon lifetime in impl Trait no longer suggests adding a lifetime parameter #100615

Description

@estebank

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

In 1.63:

error[E0106]: missing lifetime specifier
 --> src/lib.rs:1:32
  |
1 | fn foo(_: impl Iterator<Item = &u32>) {}
  |                                ^ expected named lifetime parameter
  |
help: consider introducing a named lifetime parameter
  |
1 | fn foo<'a>(_: impl Iterator<Item = &'a u32>) {}
  |       ++++                          ++

In 1.64:

error[E0658]: anonymous lifetimes in `impl Trait` are unstable
 --> src/lib.rs:1:32
  |
1 | fn foo(_: impl Iterator<Item = &u32>) {}
  |                                ^

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    A-lifetimesArea: Lifetimes / regions
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.
    on Aug 16, 2022
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Aug 16, 2022
  3. self-assigned this
    on Aug 16, 2022
  4. apiraino commented on Aug 17, 2022

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-high

  5. added
    P-highHigh priority
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Aug 17, 2022
  6. self-assigned this
    on Sep 1, 2022
  7. pnkfelix commented on Sep 1, 2022

    @pnkfelix
    Contributor

    self-assigning to ensure we record a cargo-bisect to the injecting PR

  8. apiraino commented on Sep 1, 2022

    @apiraino
    Contributor

    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: f1a8854

    bisected 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 
  9. spastorino commented on Sep 2, 2022

    @spastorino
    Member

    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.

  10. cjgillot commented on Sep 2, 2022

    @cjgillot
    Contributor

    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.

  11. 6 remaining items

  12. added
    E-mentorCall 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.
    on Sep 22, 2022
  13. Stoozy commented on Sep 26, 2022

    @Stoozy
    Contributor

    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 the span associated 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_ref should 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)
  14. cjgillot commented on Sep 26, 2022

    @cjgillot
    Contributor

    @Stoozy could you open a PR with what you have and tag me? Discussing on code will be more concrete and easier.

  15. Rageking8 commented on Sep 26, 2022

    @Rageking8
    Contributor

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

    Screenshot_2022-09-26-17-40-49-17_320a9a695de7cdce83ed5281148d6f19.jpg

  16. estebank commented on Sep 26, 2022

    @estebank
    ContributorAuthor

    @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?

  17. Stoozy commented on Sep 26, 2022

    @Stoozy
    Contributor

    @rustbot claim

  18. added 2 commits that reference this issue on Oct 10, 2022
  19. BGR360 commented on Nov 7, 2022

    @BGR360
    Contributor

    Closed by #102323? Or is there more to do?

  20. cjgillot commented on Nov 7, 2022

    @cjgillot
    Contributor

    Yes, closed by #102323, and #104048 will handle some suggestion corner cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions