Emit impl difference error for GenericBoundFailure too

This commit is contained in:
jackh726 2021-10-05 17:43:45 -04:00
parent 1dafe6d1c3
commit c4f9eb1e5a
5 changed files with 22 additions and 17 deletions

View File

@ -46,7 +46,9 @@ pub(super) fn try_report_impl_not_conforming_to_trait(&self) -> Option<ErrorRepo
} }
} }
} }
if let RegionResolutionError::ConcreteFailure(origin, _, _) = error.clone() { if let RegionResolutionError::ConcreteFailure(origin, _, _)
| RegionResolutionError::GenericBoundFailure(origin, _, _) = error.clone()
{
if let SubregionOrigin::CompareImplTypeObligation { if let SubregionOrigin::CompareImplTypeObligation {
span, span,
item_name, item_name,

View File

@ -13,7 +13,7 @@ trait Foo {
impl<T> Foo for Fooy<T> { impl<T> Foo for Fooy<T> {
type A<'a> where Self: 'static = (&'a ()); 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 ()); type B<'a, 'b> where 'b: 'a = (&'a(), &'b ());
//~^ ERROR `impl` associated type //~^ ERROR `impl` associated type
//~| ERROR lifetime bound not satisfied //~| ERROR lifetime bound not satisfied

View File

@ -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 --> $DIR/impl_bounds.rs:15:5
| |
LL | type A<'a> where Self: 'a;
| -------------------------- expected
...
LL | type A<'a> where Self: 'static = (&'a ()); LL | type A<'a> where Self: 'static = (&'a ());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found
|
= help: consider adding an explicit lifetime bound `T: 'static`...
= note: ...so that the definition in impl matches the definition from the trait
error: `impl` associated type signature for `B` doesn't match `trait` associated type signature error: `impl` associated type signature for `B` doesn't match `trait` associated type signature
--> $DIR/impl_bounds.rs:17:5 --> $DIR/impl_bounds.rs:17:5
@ -85,5 +85,5 @@ LL | impl<T: std::marker::Copy> Foo for Fooy<T> {
error: aborting due to 5 previous errors 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`. For more information about an error, try `rustc --explain E0277`.

View File

@ -21,8 +21,8 @@ impl<Left, Right> HasChildrenOf for Either<Left, Right>
{ {
type T = Either<Left::T, Right::T>; type T = Either<Left::T, Right::T>;
type TRef<'a> type TRef<'a>
//~^ the associated type //~^ `impl` associated type signature
//~^^ the associated type //~^^ `impl` associated type signature
where where
<Left as HasChildrenOf>::T: 'a, <Left as HasChildrenOf>::T: 'a,
<Right as HasChildrenOf>::T: 'a <Right as HasChildrenOf>::T: 'a

View File

@ -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 --> $DIR/issue-86787.rs:23:5
| |
LL | type TRef<'a>;
| -------------- expected
...
LL | / type TRef<'a> LL | / type TRef<'a>
LL | | LL | |
LL | | LL | |
LL | | where LL | | where
LL | | <Left as HasChildrenOf>::T: 'a, LL | | <Left as HasChildrenOf>::T: 'a,
LL | | <Right 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>; 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 --> $DIR/issue-86787.rs:23:5
| |
LL | type TRef<'a>;
| -------------- expected
...
LL | / type TRef<'a> LL | / type TRef<'a>
LL | | LL | |
LL | | LL | |
LL | | where LL | | where
LL | | <Left as HasChildrenOf>::T: 'a, LL | | <Left as HasChildrenOf>::T: 'a,
LL | | <Right 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>; 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 error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0309`.