Skip to content

Commit e35d286

Browse files
committed
Fix diagnostic by using predicate in GATs too
1 parent 31a3bb5 commit e35d286

File tree

3 files changed

+5
-27
lines changed

3 files changed

+5
-27
lines changed

src/librustc_typeck/check/compare_method.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1220,11 +1220,7 @@ fn compare_projection_bounds<'tcx>(
12201220
// we want <T as X>::Y to normalize to S. This is valid because we are
12211221
// checking the default value specifically here. Add this equality to the
12221222
// ParamEnv for normalization specifically.
1223-
let normalize_param_env = if impl_ty.defaultness.is_final() {
1224-
// If the associated type is final then normalization can already
1225-
// do this without the explicit predicate.
1226-
param_env
1227-
} else {
1223+
let normalize_param_env = {
12281224
let mut predicates = param_env.caller_bounds().iter().collect::<Vec<_>>();
12291225
predicates.push(
12301226
ty::Binder::dummy(ty::ProjectionPredicate {

src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ trait ATy {
77

88
impl<'b> ATy for &'b () {
99
type Item<'a> = &'b ();
10-
//~^ ERROR cannot infer an appropriate lifetime
10+
//~^ ERROR does not fulfill the required lifetime
1111
}
1212

1313
trait StaticTy {
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
1-
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
1+
error[E0477]: the type `&'b ()` does not fulfill the required lifetime
22
--> $DIR/unsatisfied-outlives-bound.rs:9:5
33
|
44
LL | type Item<'a> = &'b ();
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
note: first, the lifetime cannot outlive the lifetime `'b` as defined on the impl at 8:6...
8-
--> $DIR/unsatisfied-outlives-bound.rs:8:6
9-
|
10-
LL | impl<'b> ATy for &'b () {
11-
| ^^
12-
note: ...so that the types are compatible
13-
--> $DIR/unsatisfied-outlives-bound.rs:9:5
14-
|
15-
LL | type Item<'a> = &'b ();
16-
| ^^^^^^^^^^^^^^^^^^^^^^^
17-
= note: expected `ATy`
18-
found `ATy`
19-
note: but, the lifetime must be valid for the lifetime `'a` as defined on the associated item at 9:15...
7+
note: type must outlive the lifetime `'a` as defined on the associated item at 9:15
208
--> $DIR/unsatisfied-outlives-bound.rs:9:15
219
|
2210
LL | type Item<'a> = &'b ();
2311
| ^^
24-
note: ...so that the type `&()` will meet its required lifetime bounds
25-
--> $DIR/unsatisfied-outlives-bound.rs:9:5
26-
|
27-
LL | type Item<'a> = &'b ();
28-
| ^^^^^^^^^^^^^^^^^^^^^^^
2912

3013
error[E0477]: the type `&'a ()` does not fulfill the required lifetime
3114
--> $DIR/unsatisfied-outlives-bound.rs:18:5
@@ -37,5 +20,4 @@ LL | type Item<'a> = &'a ();
3720

3821
error: aborting due to 2 previous errors
3922

40-
Some errors have detailed explanations: E0477, E0495.
41-
For more information about an error, try `rustc --explain E0477`.
23+
For more information about this error, try `rustc --explain E0477`.

0 commit comments

Comments
 (0)