Skip to content

Commit e8efe09

Browse files
authored
Rollup merge of #89914 - jackh726:gat_genericboundfailure, r=estebank
Emit impl difference error for GenericBoundFailure too Fixes #86787 r? ````@estebank````
2 parents 27a7ced + c4f9eb1 commit e8efe09

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
4646
}
4747
}
4848
}
49-
if let RegionResolutionError::ConcreteFailure(origin, _, _) = error.clone() {
49+
if let RegionResolutionError::ConcreteFailure(origin, _, _)
50+
| RegionResolutionError::GenericBoundFailure(origin, _, _) = error.clone()
51+
{
5052
if let SubregionOrigin::CompareImplTypeObligation {
5153
span,
5254
item_name,

src/test/ui/generic-associated-types/impl_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct Fooy<T>(T);
1313

1414
impl<T> Foo for Fooy<T> {
1515
type A<'a> where Self: 'static = (&'a ());
16-
//~^ ERROR the parameter type `T` may not live long enough
16+
//~^ ERROR `impl` associated type
1717
type B<'a, 'b> where 'b: 'a = (&'a(), &'b ());
1818
//~^ ERROR `impl` associated type
1919
//~| ERROR lifetime bound not satisfied

src/test/ui/generic-associated-types/impl_bounds.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0310]: the parameter type `T` may not live long enough
1+
error: `impl` associated type signature for `A` doesn't match `trait` associated type signature
22
--> $DIR/impl_bounds.rs:15:5
33
|
4+
LL | type A<'a> where Self: 'a;
5+
| -------------------------- expected
6+
...
47
LL | type A<'a> where Self: 'static = (&'a ());
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= help: consider adding an explicit lifetime bound `T: 'static`...
8-
= note: ...so that the definition in impl matches the definition from the trait
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found
99

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

8686
error: aborting due to 5 previous errors
8787

88-
Some errors have detailed explanations: E0277, E0310, E0478.
88+
Some errors have detailed explanations: E0277, E0478.
8989
For more information about an error, try `rustc --explain E0277`.

src/test/ui/generic-associated-types/issue-86787.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ where
2121
{
2222
type T = Either<Left::T, Right::T>;
2323
type TRef<'a>
24-
//~^ the associated type
25-
//~^^ the associated type
24+
//~^ `impl` associated type signature
25+
//~^^ `impl` associated type signature
2626
where
2727
<Left as HasChildrenOf>::T: 'a,
2828
<Right as HasChildrenOf>::T: 'a

src/test/ui/generic-associated-types/issue-86787.stderr

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
1-
error[E0309]: the associated type `<Left as HasChildrenOf>::T` may not live long enough
1+
error: `impl` associated type signature for `TRef` doesn't match `trait` associated type signature
22
--> $DIR/issue-86787.rs:23:5
33
|
4+
LL | type TRef<'a>;
5+
| -------------- expected
6+
...
47
LL | / type TRef<'a>
58
LL | |
69
LL | |
710
LL | | where
811
LL | | <Left as HasChildrenOf>::T: 'a,
912
LL | | <Right as HasChildrenOf>::T: 'a
10-
| | - help: consider adding a where clause: `, <Left as HasChildrenOf>::T: 'a`
1113
LL | | = Either<&'a Left::T, &'a Right::T>;
12-
| |________________________________________^ ...so that the definition in impl matches the definition from the trait
14+
| |________________________________________^ found
1315

14-
error[E0309]: the associated type `<Right as HasChildrenOf>::T` may not live long enough
16+
error: `impl` associated type signature for `TRef` doesn't match `trait` associated type signature
1517
--> $DIR/issue-86787.rs:23:5
1618
|
19+
LL | type TRef<'a>;
20+
| -------------- expected
21+
...
1722
LL | / type TRef<'a>
1823
LL | |
1924
LL | |
2025
LL | | where
2126
LL | | <Left as HasChildrenOf>::T: 'a,
2227
LL | | <Right as HasChildrenOf>::T: 'a
23-
| | - help: consider adding a where clause: `, <Right as HasChildrenOf>::T: 'a`
2428
LL | | = Either<&'a Left::T, &'a Right::T>;
25-
| |________________________________________^ ...so that the definition in impl matches the definition from the trait
29+
| |________________________________________^ found
2630

2731
error: aborting due to 2 previous errors
2832

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

0 commit comments

Comments
 (0)