Skip to content

Unify lifetime elision for impl Trait arguments between async and non-async functions #85417

Description

@LukasKalbertodt

This compiles:

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

But this doesn't:

fn foo(_: impl Iterator<Item = &u32>) {}
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>) {}
  |       ^^^^                         ^^^

This difference strikes me as very odd. Is this intended? If so, why?

This is formulated as a question, but if I had to guess, I would classify this as oversight or bug -- that's why I created an issue instead of askig in the forum.

(originally asked here)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-lifetimesArea: Lifetimes / regionsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions