Open
Description
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
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Async-await issues that have been triaged during a working group meeting.Category: This is a bug.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.