Skip to content

Regression from 1.66 to nightly. Compile error: expected named lifetime parameter #106508

Closed
@Veetaha

Description

@Veetaha

I tried this code:

fn _foo<'a>(_: impl FnOnce(&'a ()) -> &()) {}

I expected to see this happen: the code compiles on nightly without errors as it does on 1.66.0

Instead, this happened: a compile error was produced:

error[E0658]: anonymous lifetimes in `impl Trait` are unstable
 --> crates/scratch/src/lib.rs:2:40
  |
2 | fn _foo<'a>(_: impl FnOnce(&'a ()) -> &()) {}
  |                                        ^ expected named lifetime parameter
  |
  = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable
help: consider introducing a named lifetime parameter
  |
2 | fn _foo<'a, 'a>(_: impl FnOnce(&'a ()) -> &'a ()) {}
  |         +++                                ++

For more information about this error, try `rustc --explain E0658`.
error: could not compile `scratch` due to previous error

Meta

rustc --version --verbose:

rustc 1.66.0 (69f9c33d7 2022-12-12)

rustc +nightly --version:

rustc 1.68.0-nightly (ad8ae0504 2022-12-29)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions