Skip to content

Commit

Permalink
apply the same logic to ConcreteFailure errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Jan 2, 2019
1 parent 77924de commit 7bc3f55
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 38 deletions.
Expand Up @@ -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.
},

_ => {}
}

Expand Down
3 changes: 1 addition & 2 deletions src/test/ui/generator/auto-trait-regions.rs
Expand Up @@ -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);
Expand Down
26 changes: 6 additions & 20 deletions src/test/ui/generator/auto-trait-regions.stderr
@@ -1,34 +1,20 @@
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: U31, name: BrAnon(1) })...
= note: ...does not necessarily outlive the static lifetime

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: 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);
| ^^^^^^^^^^
|
= 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`.
12 changes: 5 additions & 7 deletions 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::<StaticInt>() //~ 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
Expand All @@ -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`.
2 changes: 1 addition & 1 deletion src/test/ui/where-clauses/where-for-self-2.rs
Expand Up @@ -18,5 +18,5 @@ fn foo<T>(x: &T)
{}

fn main() {
foo(&X); //~ ERROR E0308
foo(&X); //~ ERROR implementation of `Bar` is not general enough
}
14 changes: 6 additions & 8 deletions 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`.

0 comments on commit 7bc3f55

Please sign in to comment.