Skip to content

Commit d9240d7

Browse files
committed
Ensure that '_ and GAT yields errors
1 parent 69a5d24 commit d9240d7

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// It's not yet clear how '_ and GATs should interact.
2+
// Forbid it for now but proper support might be added
3+
// at some point in the future.
4+
5+
#![feature(generic_associated_types)]
6+
7+
trait Foo {
8+
type Item<'a>;
9+
}
10+
11+
fn foo(x: &impl Foo<Item<'_> = u32>) { }
12+
//~^ ERROR missing lifetime specifier
13+
14+
fn bar(x: &impl for<'a> Foo<Item<'a> = &'_ u32>) { }
15+
//~^ ERROR missing lifetime specifier
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0106]: missing lifetime specifier
2+
--> $DIR/issue-95305.rs:11:26
3+
|
4+
LL | fn foo(x: &impl Foo<Item<'_> = u32>) { }
5+
| ^^ expected named lifetime parameter
6+
|
7+
help: consider introducing a named lifetime parameter
8+
|
9+
LL | fn foo<'a>(x: &impl Foo<Item<'a> = u32>) { }
10+
| ++++ ~~
11+
12+
error[E0106]: missing lifetime specifier
13+
--> $DIR/issue-95305.rs:14:41
14+
|
15+
LL | fn bar(x: &impl for<'a> Foo<Item<'a> = &'_ u32>) { }
16+
| ^^ expected named lifetime parameter
17+
|
18+
help: consider using the `'a` lifetime
19+
|
20+
LL | fn bar(x: &impl for<'a> Foo<Item<'a> = &'a u32>) { }
21+
| ~~
22+
23+
error: aborting due to 2 previous errors
24+
25+
For more information about this error, try `rustc --explain E0106`.

0 commit comments

Comments
 (0)