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

Emit impl difference error for GenericBoundFailure too #89914

Merged
merged 1 commit into from
Oct 16, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
}
}
}
if let RegionResolutionError::ConcreteFailure(origin, _, _) = error.clone() {
if let RegionResolutionError::ConcreteFailure(origin, _, _)
| RegionResolutionError::GenericBoundFailure(origin, _, _) = error.clone()
{
if let SubregionOrigin::CompareImplTypeObligation {
span,
item_name,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/impl_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct Fooy<T>(T);

impl<T> Foo for Fooy<T> {
type A<'a> where Self: 'static = (&'a ());
//~^ ERROR the parameter type `T` may not live long enough
//~^ ERROR `impl` associated type
type B<'a, 'b> where 'b: 'a = (&'a(), &'b ());
//~^ ERROR `impl` associated type
//~| ERROR lifetime bound not satisfied
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/generic-associated-types/impl_bounds.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0310]: the parameter type `T` may not live long enough
error: `impl` associated type signature for `A` doesn't match `trait` associated type signature
--> $DIR/impl_bounds.rs:15:5
|
LL | type A<'a> where Self: 'a;
| -------------------------- expected
...
LL | type A<'a> where Self: 'static = (&'a ());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `T: 'static`...
= note: ...so that the definition in impl matches the definition from the trait
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found

error: `impl` associated type signature for `B` doesn't match `trait` associated type signature
--> $DIR/impl_bounds.rs:17:5
Expand Down Expand Up @@ -85,5 +85,5 @@ LL | impl<T: std::marker::Copy> Foo for Fooy<T> {

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0277, E0310, E0478.
Some errors have detailed explanations: E0277, E0478.
For more information about an error, try `rustc --explain E0277`.
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/issue-86787.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ where
{
type T = Either<Left::T, Right::T>;
type TRef<'a>
//~^ the associated type
//~^^ the associated type
//~^ `impl` associated type signature
//~^^ `impl` associated type signature
where
<Left as HasChildrenOf>::T: 'a,
<Right as HasChildrenOf>::T: 'a
Expand Down
17 changes: 10 additions & 7 deletions src/test/ui/generic-associated-types/issue-86787.stderr
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
error[E0309]: the associated type `<Left as HasChildrenOf>::T` may not live long enough
error: `impl` associated type signature for `TRef` doesn't match `trait` associated type signature
--> $DIR/issue-86787.rs:23:5
|
LL | type TRef<'a>;
| -------------- expected
...
LL | / type TRef<'a>
LL | |
LL | |
LL | | where
LL | | <Left as HasChildrenOf>::T: 'a,
LL | | <Right as HasChildrenOf>::T: 'a
| | - help: consider adding a where clause: `, <Left as HasChildrenOf>::T: 'a`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was gonna say "I'm sad about the missing suggestion" but a glance shows that the suggestion was wrong in the first place :-/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern is unrepresentable even with GATs, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the suggested clause already exists, but even if it didn't, we can't have clauses on an impl that weren't there in the trait.

LL | | = Either<&'a Left::T, &'a Right::T>;
| |________________________________________^ ...so that the definition in impl matches the definition from the trait
| |________________________________________^ found

error[E0309]: the associated type `<Right as HasChildrenOf>::T` may not live long enough
error: `impl` associated type signature for `TRef` doesn't match `trait` associated type signature
--> $DIR/issue-86787.rs:23:5
|
LL | type TRef<'a>;
| -------------- expected
...
LL | / type TRef<'a>
LL | |
LL | |
LL | | where
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 definition in impl matches the definition from the trait
| |________________________________________^ found

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0309`.