diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-28 20:12:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-28 20:12:57 +0200 |
| commit | d665a5ea4a68a6bc793c267c1a110f01aa946b4f (patch) | |
| tree | f1e9c1aafa0176f2e76eb3339ff2bdc047c9ba54 | |
| parent | b2c2a32870e15af02eb89de434c36535439dbf5a (diff) | |
| parent | d9240d72ea2f050c45b1772e6de005a1ee4aed47 (diff) | |
| download | rust-d665a5ea4a68a6bc793c267c1a110f01aa946b4f.tar.gz rust-d665a5ea4a68a6bc793c267c1a110f01aa946b4f.zip | |
Rollup merge of #95312 - marmeladema:tests-for-issue-95305, r=jackh726
Ensure that `'_` and GAT yields errors Fixes #95305 ```@bors``` r? ```@jackh726```
| -rw-r--r-- | src/test/ui/generic-associated-types/issue-95305.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/generic-associated-types/issue-95305.stderr | 25 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/test/ui/generic-associated-types/issue-95305.rs b/src/test/ui/generic-associated-types/issue-95305.rs new file mode 100644 index 00000000000..9ead347984b --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-95305.rs @@ -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() {} diff --git a/src/test/ui/generic-associated-types/issue-95305.stderr b/src/test/ui/generic-associated-types/issue-95305.stderr new file mode 100644 index 00000000000..2b48378dc43 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-95305.stderr @@ -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`. |
