diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2020-07-25 13:52:47 -0700 |
|---|---|---|
| committer | Tyler Mandry <tmandry@gmail.com> | 2020-07-25 13:52:47 -0700 |
| commit | e35d2867f14a36094bdceadc731fdd1d26882fc9 (patch) | |
| tree | cc3a02a88dad363a2a7660437d7f251f89c6f5dc | |
| parent | 31a3bb59ce42ae86e19c2e316d0809e8606c810f (diff) | |
| download | rust-e35d2867f14a36094bdceadc731fdd1d26882fc9.tar.gz rust-e35d2867f14a36094bdceadc731fdd1d26882fc9.zip | |
Fix diagnostic by using predicate in GATs too
3 files changed, 5 insertions, 27 deletions
diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index bf415406675..b739e2fe1fb 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -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 { diff --git a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs index 4831a8c63e8..7510c58d574 100644 --- a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs +++ b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs @@ -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 { diff --git a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr index 80f69becc2c..5d612284a21 100644 --- a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr +++ b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr @@ -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`. |
