-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
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
jinohkang-theori
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team