Skip to content

Commit c2136ba

Browse files
committed
Revert "Fix incosistent usage of push_lifetime_outlives"
This reverts commit d5b0ffc.
1 parent 7b15b1d commit c2136ba

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

chalk-solve/src/infer/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,10 @@ fn lifetime_constraint_indirect() {
413413
assert_eq!(goals.len(), 2);
414414
assert_eq!(
415415
format!("{:?}", goals[0]),
416-
"InEnvironment { environment: Env([]), goal: \'!1_0: \'?2 }",
416+
"InEnvironment { environment: Env([]), goal: \'?2: \'!1_0 }",
417417
);
418418
assert_eq!(
419419
format!("{:?}", goals[1]),
420-
"InEnvironment { environment: Env([]), goal: \'?2: \'!1_0 }",
420+
"InEnvironment { environment: Env([]), goal: \'!1_0: \'?2 }",
421421
);
422422
}

chalk-solve/src/infer/unify.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,13 @@ impl<'t, I: Interner> Unifier<'t, I> {
255255
if mutability_a != mutability_b {
256256
return Err(NoSolution);
257257
}
258-
// Zipping lifetimes implies a is a subtype of b, meaning a outlives b
259-
Zip::zip_with(self, variance, lifetime_a, lifetime_b)?;
258+
// The lifetime is `Contravariant`
259+
Zip::zip_with(
260+
self,
261+
variance.xform(Variance::Contravariant),
262+
lifetime_a,
263+
lifetime_b,
264+
)?;
260265
// The type is `Covariant` when not mut, `Invariant` otherwise
261266
let output_variance = match mutability_a {
262267
Mutability::Not => Variance::Covariant,
@@ -1050,16 +1055,16 @@ impl<'t, I: Interner> Unifier<'t, I> {
10501055
self.goals.push(InEnvironment::new(
10511056
self.environment,
10521057
WhereClause::LifetimeOutlives(LifetimeOutlives {
1053-
a: b.clone(),
1054-
b: a.clone(),
1058+
a: a.clone(),
1059+
b: b.clone(),
10551060
})
10561061
.cast(self.interner),
10571062
));
10581063
}
10591064
if matches!(variance, Variance::Invariant | Variance::Covariant) {
10601065
self.goals.push(InEnvironment::new(
10611066
self.environment,
1062-
WhereClause::LifetimeOutlives(LifetimeOutlives { a, b }).cast(self.interner),
1067+
WhereClause::LifetimeOutlives(LifetimeOutlives { a: b, b: a }).cast(self.interner),
10631068
));
10641069
}
10651070
}

tests/test/misc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ fn basic_region_constraint_from_positive_impl() {
259259
forall<'a, 'b, T> { Ref<'a, 'b, T>: Foo }
260260
} yields_all[SolverChoice::slg(3, None)] {
261261
"substitution [], lifetime constraints [\
262-
InEnvironment { environment: Env([]), goal: '!1_1: '!1_0 }, \
263-
InEnvironment { environment: Env([]), goal: '!1_0: '!1_1 } \
262+
InEnvironment { environment: Env([]), goal: '!1_0: '!1_1 }, \
263+
InEnvironment { environment: Env([]), goal: '!1_1: '!1_0 } \
264264
]"
265265
}
266266
}

tests/test/projection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -799,10 +799,10 @@ fn normalize_under_binder_multi() {
799799
} yields_all {
800800
"substitution [?0 := I32], lifetime constraints []",
801801
"for<?U0,?U0> { substitution [?0 := (Deref::Item)<Ref<'^0.0, I32>, '^0.1>], lifetime constraints [\
802-
InEnvironment { environment: Env([]), goal: '^0.1: '!1_0 }, \
803802
InEnvironment { environment: Env([]), goal: '!1_0: '^0.1 }, \
804-
InEnvironment { environment: Env([]), goal: '^0.0: '!1_0 }, \
805-
InEnvironment { environment: Env([]), goal: '!1_0: '^0.0 }] }"
803+
InEnvironment { environment: Env([]), goal: '^0.1: '!1_0 }, \
804+
InEnvironment { environment: Env([]), goal: '!1_0: '^0.0 }, \
805+
InEnvironment { environment: Env([]), goal: '^0.0: '!1_0 }] }"
806806
}
807807

808808
goal {

tests/test/subtype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn struct_lifetime_variance() {
4545
}
4646
} yields {
4747
"Unique; substitution [], lifetime constraints [\
48-
InEnvironment { environment: Env([]), goal: '!1_0: '!1_1 } \
48+
InEnvironment { environment: Env([]), goal: '!1_1: '!1_0 } \
4949
]"
5050
}
5151
}

0 commit comments

Comments
 (0)