Skip to content

Commit 528d48c

Browse files
committed
actual MayInvalidate implementation for consts + remove dead code
1 parent 95a5bde commit 528d48c

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

chalk-ir/src/lib.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -941,22 +941,6 @@ impl<I: Interner> Parameter<I> {
941941
_ => None,
942942
}
943943
}
944-
945-
pub fn bound_var(&self, interner: &I) -> Option<BoundVar> {
946-
match self.data(interner) {
947-
ParameterKind::Ty(t) => t.bound_var(interner),
948-
ParameterKind::Lifetime(l) => l.bound_var(interner),
949-
ParameterKind::Const(c) => c.bound_var(interner),
950-
}
951-
}
952-
953-
pub fn inference_var(&self, interner: &I) -> Option<InferenceVar> {
954-
match self.data(interner) {
955-
ParameterKind::Ty(t) => t.inference_var(interner),
956-
ParameterKind::Lifetime(l) => l.inference_var(interner),
957-
ParameterKind::Const(c) => c.inference_var(interner),
958-
}
959-
}
960944
}
961945

962946
#[allow(type_alias_bounds)]

chalk-solve/src/solve/slg.rs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ impl<I: Interner> MayInvalidate<'_, I> {
547547
}
548548

549549
(TyData::Placeholder(p1), TyData::Placeholder(p2)) => {
550-
self.aggregate_placeholder_tys(p1, p2)
550+
self.aggregate_placeholders(p1, p2)
551551
}
552552

553553
(TyData::Alias(alias1), TyData::Alias(alias2)) => {
@@ -567,8 +567,36 @@ impl<I: Interner> MayInvalidate<'_, I> {
567567
true
568568
}
569569

570-
fn aggregate_consts(&mut self, _: &Const<I>, _: &Const<I>) -> bool {
571-
true
570+
// Returns true if the two consts could be unequal.
571+
fn aggregate_consts(&mut self, new: &Const<I>, current: &Const<I>) -> bool {
572+
let interner = self.interner;
573+
match (new.data(interner), current.data(interner)) {
574+
(_, ConstData::BoundVar(_)) => {
575+
// see comment in aggregate_tys
576+
false
577+
}
578+
579+
(ConstData::BoundVar(_), _) => {
580+
// see comment in aggregate_tys
581+
true
582+
}
583+
584+
(ConstData::InferenceVar(_), _) | (_, ConstData::InferenceVar(_)) => {
585+
panic!(
586+
"unexpected free inference variable in may-invalidate: {:?} vs {:?}",
587+
new, current,
588+
);
589+
}
590+
591+
(ConstData::Placeholder(p1), ConstData::Placeholder(p2)) => {
592+
self.aggregate_placeholders(p1, p2)
593+
}
594+
595+
(ConstData::Concrete(c1), ConstData::Concrete(c2)) => !c1.c_eq(c2, interner),
596+
597+
// Only variants left are placeholder = concrete, which always fails
598+
(ConstData::Placeholder(_), _) | (ConstData::Concrete(_), _) => true,
599+
}
572600
}
573601

574602
fn aggregate_application_tys(
@@ -593,7 +621,7 @@ impl<I: Interner> MayInvalidate<'_, I> {
593621
)
594622
}
595623

596-
fn aggregate_placeholder_tys(
624+
fn aggregate_placeholders(
597625
&mut self,
598626
new: &PlaceholderIndex,
599627
current: &PlaceholderIndex,

chalk-solve/src/solve/truncate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'infer, 'i, I: Interner> Visitor<'i, I> for TySizeVisitor<'infer, 'i, I> {
4646
}
4747

4848
fn visit_ty(&mut self, ty: &Ty<I>, outer_binder: DebruijnIndex) {
49-
if let Some(normalized_ty) = self.infer.normalize_shallow(self.interner, ty) {
49+
if let Some(normalized_ty) = self.infer.normalize_ty_shallow(self.interner, ty) {
5050
normalized_ty.visit_with(self, outer_binder);
5151
return;
5252
}

0 commit comments

Comments
 (0)