-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Detect stricter constraints on gats where clauses in impls vs trait #88336
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,24 +5,16 @@ LL | type A<'a> where Self: 'static = (&'a ()); | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider adding an explicit lifetime bound `T: 'static`... | ||
= note: ...so that the type `Fooy<T>` will meet its required lifetime bounds | ||
= note: ...so that the definition in impl matches the definition from the trait | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is a weird diagnostic. The trait has |
||
|
||
error[E0478]: lifetime bound not satisfied | ||
error: `impl` associated type signature for `B` doesn't match `trait` associated type signature | ||
--> $DIR/impl_bounds.rs:17:5 | ||
| | ||
LL | type B<'a, 'b> where 'a: 'b; | ||
| ---------------------------- expected | ||
... | ||
LL | type B<'a, 'b> where 'b: 'a = (&'a(), &'b ()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: lifetime parameter instantiated with the lifetime `'b` as defined on the associated item at 17:16 | ||
--> $DIR/impl_bounds.rs:17:16 | ||
| | ||
LL | type B<'a, 'b> where 'b: 'a = (&'a(), &'b ()); | ||
| ^^ | ||
note: but lifetime parameter must outlive the lifetime `'a` as defined on the associated item at 17:12 | ||
--> $DIR/impl_bounds.rs:17:12 | ||
| | ||
LL | type B<'a, 'b> where 'b: 'a = (&'a(), &'b ()); | ||
| ^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found | ||
|
||
error[E0478]: lifetime bound not satisfied | ||
--> $DIR/impl_bounds.rs:17:5 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ LL | | <Left as HasChildrenOf>::T: 'a, | |
LL | | <Right as HasChildrenOf>::T: 'a | ||
| | - help: consider adding a where clause: `, <Left as HasChildrenOf>::T: 'a` | ||
LL | | = Either<&'a Left::T, &'a Right::T>; | ||
| |________________________________________^ ...so that the type `<Left as HasChildrenOf>::T` will meet its required lifetime bounds | ||
| |________________________________________^ ...so that the definition in impl matches the definition from the trait | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also a bad diagnostic (still), but I wouldn't argue that it's any worse. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we maybe point at the trait's assoc There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, but I'm planning to fix this diagnostic at some point anyways. |
||
|
||
error[E0309]: the associated type `<Right as HasChildrenOf>::T` may not live long enough | ||
--> $DIR/issue-86787.rs:23:5 | ||
|
@@ -22,7 +22,7 @@ LL | | <Left as HasChildrenOf>::T: 'a, | |
LL | | <Right as HasChildrenOf>::T: 'a | ||
| | - help: consider adding a where clause: `, <Right as HasChildrenOf>::T: 'a` | ||
LL | | = Either<&'a Left::T, &'a Right::T>; | ||
| |________________________________________^ ...so that the type `<Right as HasChildrenOf>::T` will meet its required lifetime bounds | ||
| |________________________________________^ ...so that the definition in impl matches the definition from the trait | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// check-fail | ||
|
||
#![feature(generic_associated_types)] | ||
|
||
trait Foo { | ||
type Assoc<'a, 'b>; | ||
} | ||
impl Foo for () { | ||
type Assoc<'a, 'b> where 'a: 'b = (); | ||
//~^ `impl` associated type | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: `impl` associated type signature for `Assoc` doesn't match `trait` associated type signature | ||
--> $DIR/missing-where-clause-on-trait.rs:9:5 | ||
| | ||
LL | type Assoc<'a, 'b>; | ||
| ------------------- expected | ||
... | ||
LL | type Assoc<'a, 'b> where 'a: 'b = (); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found | ||
Comment on lines
+1
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For future work, I'd like us to point out the exact divergence (in this case the whole |
||
|
||
error: aborting due to previous error | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove one level of nesting by merging the second
if let
check with the first one.