mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-05 21:24:12 +00:00
apply the same logic to ConcreteFailure errors
This commit is contained in:
parent
77924de4a6
commit
7bc3f5585a
@ -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.
|
||||
},
|
||||
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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`.
|
||||
|
@ -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
|
||||
@ -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`.
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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`.
|
||||
|
Loading…
Reference in New Issue
Block a user