2 // gate-test-anonymous_lifetime_in_impl_trait
3 // Verify the behaviour of `feature(anonymous_lifetime_in_impl_trait)`.
6 fn f(_: impl Iterator<Item = &()>) {}
7 //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
9 fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
10 //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
11 //~| ERROR missing lifetime specifier
13 // Anonymous lifetimes in async fn are already allowed.
14 // This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`.
15 async fn h(_: impl Iterator<Item = &()>) {}
17 // Anonymous lifetimes in async fn are already allowed.
18 // But that lifetime does not participate in resolution.
19 async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
20 //~^ ERROR missing lifetime specifier
24 fn f(_: impl Iterator<Item = &'_ ()>) {}
25 //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
27 fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
28 //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
29 //~| ERROR missing lifetime specifier
31 // Anonymous lifetimes in async fn are already allowed.
32 // This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`.
33 async fn h(_: impl Iterator<Item = &'_ ()>) {}
35 // Anonymous lifetimes in async fn are already allowed.
36 // But that lifetime does not participate in resolution.
37 async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
38 //~^ ERROR missing lifetime specifier
42 trait Foo<'a> { fn next(&mut self) -> Option<&'a ()>; }
45 //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
47 fn g(mut x: impl Foo) -> Option<&()> { x.next() }
48 //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
49 //~| ERROR missing lifetime specifier
53 trait Foo<'a, T> { fn next(&mut self) -> Option<&'a T>; }
55 fn f(_: impl Foo<()>) {}
56 //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
58 fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() }
59 //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
60 //~| ERROR missing lifetime specifier