Fix diagnostic by using predicate in GATs too
This commit is contained in:
parent
31a3bb59ce
commit
e35d2867f1
@ -1220,11 +1220,7 @@ fn compare_projection_bounds<'tcx>(
|
||||
// we want <T as X>::Y to normalize to S. This is valid because we are
|
||||
// checking the default value specifically here. Add this equality to the
|
||||
// ParamEnv for normalization specifically.
|
||||
let normalize_param_env = if impl_ty.defaultness.is_final() {
|
||||
// If the associated type is final then normalization can already
|
||||
// do this without the explicit predicate.
|
||||
param_env
|
||||
} else {
|
||||
let normalize_param_env = {
|
||||
let mut predicates = param_env.caller_bounds().iter().collect::<Vec<_>>();
|
||||
predicates.push(
|
||||
ty::Binder::dummy(ty::ProjectionPredicate {
|
||||
|
@ -7,7 +7,7 @@ trait ATy {
|
||||
|
||||
impl<'b> ATy for &'b () {
|
||||
type Item<'a> = &'b ();
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
//~^ ERROR does not fulfill the required lifetime
|
||||
}
|
||||
|
||||
trait StaticTy {
|
||||
|
@ -1,31 +1,14 @@
|
||||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
|
||||
error[E0477]: the type `&'b ()` does not fulfill the required lifetime
|
||||
--> $DIR/unsatisfied-outlives-bound.rs:9:5
|
||||
|
|
||||
LL | type Item<'a> = &'b ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'b` as defined on the impl at 8:6...
|
||||
--> $DIR/unsatisfied-outlives-bound.rs:8:6
|
||||
|
|
||||
LL | impl<'b> ATy for &'b () {
|
||||
| ^^
|
||||
note: ...so that the types are compatible
|
||||
--> $DIR/unsatisfied-outlives-bound.rs:9:5
|
||||
|
|
||||
LL | type Item<'a> = &'b ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: expected `ATy`
|
||||
found `ATy`
|
||||
note: but, the lifetime must be valid for the lifetime `'a` as defined on the associated item at 9:15...
|
||||
note: type must outlive the lifetime `'a` as defined on the associated item at 9:15
|
||||
--> $DIR/unsatisfied-outlives-bound.rs:9:15
|
||||
|
|
||||
LL | type Item<'a> = &'b ();
|
||||
| ^^
|
||||
note: ...so that the type `&()` will meet its required lifetime bounds
|
||||
--> $DIR/unsatisfied-outlives-bound.rs:9:5
|
||||
|
|
||||
LL | type Item<'a> = &'b ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0477]: the type `&'a ()` does not fulfill the required lifetime
|
||||
--> $DIR/unsatisfied-outlives-bound.rs:18:5
|
||||
@ -37,5 +20,4 @@ LL | type Item<'a> = &'a ();
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0477, E0495.
|
||||
For more information about an error, try `rustc --explain E0477`.
|
||||
For more information about this error, try `rustc --explain E0477`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user