Rollup merge of #95312 - marmeladema:tests-for-issue-95305, r=jackh726
Ensure that `'_` and GAT yields errors Fixes #95305 ```@bors``` r? ```@jackh726```
This commit is contained in:
commit
d665a5ea4a
2 changed files with 42 additions and 0 deletions
17
src/test/ui/generic-associated-types/issue-95305.rs
Normal file
17
src/test/ui/generic-associated-types/issue-95305.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// It's not yet clear how '_ and GATs should interact.
|
||||||
|
// Forbid it for now but proper support might be added
|
||||||
|
// at some point in the future.
|
||||||
|
|
||||||
|
#![feature(generic_associated_types)]
|
||||||
|
|
||||||
|
trait Foo {
|
||||||
|
type Item<'a>;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo(x: &impl Foo<Item<'_> = u32>) { }
|
||||||
|
//~^ ERROR missing lifetime specifier
|
||||||
|
|
||||||
|
fn bar(x: &impl for<'a> Foo<Item<'a> = &'_ u32>) { }
|
||||||
|
//~^ ERROR missing lifetime specifier
|
||||||
|
|
||||||
|
fn main() {}
|
25
src/test/ui/generic-associated-types/issue-95305.stderr
Normal file
25
src/test/ui/generic-associated-types/issue-95305.stderr
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/issue-95305.rs:11:26
|
||||||
|
|
|
||||||
|
LL | fn foo(x: &impl Foo<Item<'_> = u32>) { }
|
||||||
|
| ^^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | fn foo<'a>(x: &impl Foo<Item<'a> = u32>) { }
|
||||||
|
| ++++ ~~
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/issue-95305.rs:14:41
|
||||||
|
|
|
||||||
|
LL | fn bar(x: &impl for<'a> Foo<Item<'a> = &'_ u32>) { }
|
||||||
|
| ^^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
help: consider using the `'a` lifetime
|
||||||
|
|
|
||||||
|
LL | fn bar(x: &impl for<'a> Foo<Item<'a> = &'a u32>) { }
|
||||||
|
| ~~
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0106`.
|
Loading…
Add table
Add a link
Reference in a new issue