diff --git a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs index 4fd1a9700768..4e59c8c43dc0 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -89,6 +89,56 @@ impl NiceRegionError<'me, 'gcx, 'tcx> { // I actually can't see why this would be the case ever. }, + Some(RegionResolutionError::ConcreteFailure( + SubregionOrigin::Subtype(TypeTrace { .. }), + ty::RePlaceholder(_), + ty::RePlaceholder(_), + )) => { + // I actually can't see why this would be the case ever. + }, + + Some(RegionResolutionError::ConcreteFailure( + SubregionOrigin::Subtype(TypeTrace { + cause, + values: ValuePairs::TraitRefs(ExpectedFound { expected, found }), + }), + sub_region, + sup_region @ ty::RePlaceholder(_), + )) => if expected.def_id == found.def_id { + return Some(self.try_report_placeholders_trait( + Some(sub_region), + cause, + None, + Some(*sup_region), + expected.def_id, + expected.substs, + found.substs, + )); + } else { + // I actually can't see why this would be the case ever. + }, + + Some(RegionResolutionError::ConcreteFailure( + SubregionOrigin::Subtype(TypeTrace { + cause, + values: ValuePairs::TraitRefs(ExpectedFound { expected, found }), + }), + sub_region @ ty::RePlaceholder(_), + sup_region, + )) => if expected.def_id == found.def_id { + return Some(self.try_report_placeholders_trait( + Some(sup_region), + cause, + None, + Some(*sub_region), + expected.def_id, + expected.substs, + found.substs, + )); + } else { + // I actually can't see why this would be the case ever. + }, + _ => {} } diff --git a/src/test/ui/generator/auto-trait-regions.rs b/src/test/ui/generator/auto-trait-regions.rs index 5b52bf3cd04b..46d728994385 100644 --- a/src/test/ui/generator/auto-trait-regions.rs +++ b/src/test/ui/generator/auto-trait-regions.rs @@ -28,8 +28,7 @@ fn main() { assert_foo(x); }; assert_foo(gen); - //~^ ERROR mismatched types - //~| ERROR mismatched types + //~^ ERROR implementation of `Foo` is not general enough // Allow impls which matches any lifetime let x = &OnlyFooIfRef(No); diff --git a/src/test/ui/generator/auto-trait-regions.stderr b/src/test/ui/generator/auto-trait-regions.stderr index 6f748a740328..94162cb9e8fb 100644 --- a/src/test/ui/generator/auto-trait-regions.stderr +++ b/src/test/ui/generator/auto-trait-regions.stderr @@ -1,27 +1,14 @@ -error[E0308]: mismatched types +error: implementation of `Foo` is not general enough --> $DIR/auto-trait-regions.rs:30:5 | LL | assert_foo(gen); - | ^^^^^^^^^^ lifetime mismatch + | ^^^^^^^^^^ | - = note: expected type `Foo` - found type `Foo` - = note: lifetime RePlaceholder(Placeholder { universe: U31, name: BrAnon(1) })... - = note: ...does not necessarily outlive the static lifetime - -error[E0308]: mismatched types - --> $DIR/auto-trait-regions.rs:30:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^ lifetime mismatch - | - = note: expected type `Foo` - found type `Foo` - = note: lifetime RePlaceholder(Placeholder { universe: U35, name: BrAnon(1) })... - = note: ...does not necessarily outlive the static lifetime + = note: `&'0 OnlyFooIfStaticRef` must implement `Foo` for any lifetime `'0` + = note: but `&'1 OnlyFooIfStaticRef` only implements `Foo` for some lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:49:5 + --> $DIR/auto-trait-regions.rs:48:5 | LL | assert_foo(gen); | ^^^^^^^^^^ @@ -29,6 +16,5 @@ LL | assert_foo(gen); = note: `A<'0, '1>` must implement `Foo` for any two lifetimes `'0` and `'1` = note: but `A<'_, '2>` only implements `Foo` for some lifetime `'2` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/hrtb/hrtb-just-for-static.stderr b/src/test/ui/hrtb/hrtb-just-for-static.stderr index 6ea415c1734b..ee518b956ab1 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.stderr +++ b/src/test/ui/hrtb/hrtb-just-for-static.stderr @@ -1,13 +1,12 @@ -error[E0308]: mismatched types +error: implementation of `Foo` is not general enough --> $DIR/hrtb-just-for-static.rs:24:5 | LL | want_hrtb::() //~ ERROR - | ^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected type `Foo<&'a isize>` - found type `Foo<&'static isize>` - = note: lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:11), 'a) })... - = note: ...does not necessarily outlive the static lifetime + = note: Due to a where-clause on `want_hrtb`, + = note: `StaticInt` must implement `Foo<&'0 isize>` for any lifetime `'0` + = note: but `StaticInt` only implements `Foo<&'1 isize>` for some lifetime `'1` error: implementation of `Foo` is not general enough --> $DIR/hrtb-just-for-static.rs:30:5 @@ -21,4 +20,3 @@ LL | want_hrtb::<&'a u32>() //~ ERROR error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/where-clauses/where-for-self-2.rs b/src/test/ui/where-clauses/where-for-self-2.rs index c69055fe0cc8..0ce38e69f6b0 100644 --- a/src/test/ui/where-clauses/where-for-self-2.rs +++ b/src/test/ui/where-clauses/where-for-self-2.rs @@ -18,5 +18,5 @@ fn foo(x: &T) {} fn main() { - foo(&X); //~ ERROR E0308 + foo(&X); //~ ERROR implementation of `Bar` is not general enough } diff --git a/src/test/ui/where-clauses/where-for-self-2.stderr b/src/test/ui/where-clauses/where-for-self-2.stderr index 04d7bbabb2a5..06f3659a5c17 100644 --- a/src/test/ui/where-clauses/where-for-self-2.stderr +++ b/src/test/ui/where-clauses/where-for-self-2.stderr @@ -1,14 +1,12 @@ -error[E0308]: mismatched types +error: implementation of `Bar` is not general enough --> $DIR/where-for-self-2.rs:21:5 | -LL | foo(&X); //~ ERROR E0308 - | ^^^ lifetime mismatch +LL | foo(&X); //~ ERROR implementation of `Bar` is not general enough + | ^^^ | - = note: expected type `Bar` - found type `Bar` - = note: lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:10), 'a) })... - = note: ...does not necessarily outlive the static lifetime + = note: Due to a where-clause on `foo`, + = note: `&'0 _` must implement `Bar` for any lifetime `'0` + = note: but `&'1 u32` only implements `Bar` for some lifetime `'1` error: aborting due to previous error -For more information about this error, try `rustc --explain E0308`.