-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
110 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// edition:2021 | ||
// gate-test-anonymous_lifetime_in_impl_trait | ||
// Verify the behaviour of `feature(anonymous_lifetime_in_impl_trait)`. | ||
|
||
fn f(_: impl Iterator<Item = &'_ ()>) {} | ||
//~^ ERROR anonymous lifetimes in `impl Trait` are unstable | ||
|
||
fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } | ||
//~^ ERROR anonymous lifetimes in `impl Trait` are unstable | ||
//~| ERROR missing lifetime specifier | ||
|
||
// Anonymous lifetimes in async fn are already allowed. | ||
// This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`. | ||
async fn h(_: impl Iterator<Item = &'_ ()>) {} | ||
|
||
// Anonymous lifetimes in async fn are already allowed. | ||
// But that lifetime does not participate in resolution. | ||
async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } | ||
//~^ ERROR missing lifetime specifier | ||
|
||
fn main() {} |
44 changes: 44 additions & 0 deletions
44
src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
error[E0658]: anonymous lifetimes in `impl Trait` are unstable | ||
--> $DIR/impl-trait-missing-lifetime-gated.rs:5:31 | ||
| | ||
LL | fn f(_: impl Iterator<Item = &'_ ()>) {} | ||
| ^^ | ||
| | ||
= help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable | ||
|
||
error[E0106]: missing lifetime specifier | ||
--> $DIR/impl-trait-missing-lifetime-gated.rs:8:50 | ||
| | ||
LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } | ||
| ^^ expected named lifetime parameter | ||
| | ||
= help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments | ||
help: consider using the `'static` lifetime | ||
| | ||
LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } | ||
| ~~~~~~~ | ||
|
||
error[E0658]: anonymous lifetimes in `impl Trait` are unstable | ||
--> $DIR/impl-trait-missing-lifetime-gated.rs:8:31 | ||
| | ||
LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } | ||
| ^^ | ||
| | ||
= help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable | ||
|
||
error[E0106]: missing lifetime specifier | ||
--> $DIR/impl-trait-missing-lifetime-gated.rs:18:56 | ||
| | ||
LL | async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } | ||
| ^^ expected named lifetime parameter | ||
| | ||
= help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments | ||
help: consider using the `'static` lifetime | ||
| | ||
LL | async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } | ||
| ~~~~~~~ | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
Some errors have detailed explanations: E0106, E0658. | ||
For more information about an error, try `rustc --explain E0106`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
// edition:2021 | ||
|
||
#![feature(anonymous_lifetime_in_impl_trait)] | ||
|
||
// This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`. | ||
fn f(_: impl Iterator<Item = &'_ ()>) {} | ||
|
||
// But that lifetime does not participate in resolution. | ||
fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } | ||
//~^ ERROR missing lifetime specifier | ||
|
||
// This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`. | ||
async fn h(_: impl Iterator<Item = &'_ ()>) {} | ||
|
||
// But that lifetime does not participate in resolution. | ||
async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } | ||
//~^ ERROR missing lifetime specifier | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters