I tried this code (playground):
async fn test(args: impl Iterator<Item = &str>) {}
I expected to see this happen: an error because &str contains an anonymous lifetime, and is part of an impl Trait type.
Instead, this happened: Compiles successfully.
Removing async from the function definition gives the following error (on nightly to see the feature gate):
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
--> src/lib.rs:1:37
|
1 | fn test(args: impl Iterator<Item = &str>) {}
| ^ 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
|
1 | fn test<'a>(args: impl Iterator<Item = &'a str>) {}
| ++++ ++
This feature seems to have no documentation or tracking issue, only an unstable book entry. Given this, and the fact this behavior has been stable on async accidentally (AFAICT) for many releases now, maybe the best solution will be to just un-featuregate this functionality.
Meta
rustc --version --verbose:
rustc 1.67.1 (d5a82bbd2 2023-02-07)
@rustbot label: +A-impl-trait +T-compiler
I tried this code (playground):
I expected to see this happen: an error because
&strcontains an anonymous lifetime, and is part of animpl Traittype.Instead, this happened: Compiles successfully.
Removing
asyncfrom the function definition gives the following error (on nightly to see the feature gate):This feature seems to have no documentation or tracking issue, only an unstable book entry. Given this, and the fact this behavior has been stable on async accidentally (AFAICT) for many releases now, maybe the best solution will be to just un-featuregate this functionality.
Meta
rustc --version --verbose:@rustbot label: +A-impl-trait +T-compiler