Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that '_ and GAT yields errors #95312

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/test/ui/generic-associated-types/issue-95305.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 25 additions & 0 deletions src/test/ui/generic-associated-types/issue-95305.stderr
Original file line number Diff line number Diff line change
@@ -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`.