Skip to content

Commit 4f4b525

Browse files
committed
actual MayInvalidate implementation for consts + remove dead code
1 parent 2d4f06c commit 4f4b525

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

chalk-ir/src/lib.rs

-16
Original file line numberDiff line numberDiff line change
@@ -938,22 +938,6 @@ impl<I: Interner> Parameter<I> {
938938
_ => None,
939939
}
940940
}
941-
942-
pub fn bound_var(&self, interner: &I) -> Option<BoundVar> {
943-
match self.data(interner) {
944-
ParameterKind::Ty(t) => t.bound_var(interner),
945-
ParameterKind::Lifetime(l) => l.bound_var(interner),
946-
ParameterKind::Const(c) => c.bound_var(interner),
947-
}
948-
}
949-
950-
pub fn inference_var(&self, interner: &I) -> Option<InferenceVar> {
951-
match self.data(interner) {
952-
ParameterKind::Ty(t) => t.inference_var(interner),
953-
ParameterKind::Lifetime(l) => l.inference_var(interner),
954-
ParameterKind::Const(c) => c.inference_var(interner),
955-
}
956-
}
957941
}
958942

959943
#[allow(type_alias_bounds)]

chalk-solve/src/solve/slg.rs

+32-4
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ impl<I: Interner> MayInvalidate<'_, I> {
572572
}
573573

574574
(TyData::Placeholder(p1), TyData::Placeholder(p2)) => {
575-
self.aggregate_placeholder_tys(p1, p2)
575+
self.aggregate_placeholders(p1, p2)
576576
}
577577

578578
(TyData::Alias(alias1), TyData::Alias(alias2)) => {
@@ -592,8 +592,36 @@ impl<I: Interner> MayInvalidate<'_, I> {
592592
true
593593
}
594594

595-
fn aggregate_consts(&mut self, _: &Const<I>, _: &Const<I>) -> bool {
596-
true
595+
// Returns true if the two consts could be unequal.
596+
fn aggregate_consts(&mut self, new: &Const<I>, current: &Const<I>) -> bool {
597+
let interner = self.interner;
598+
match (new.data(interner), current.data(interner)) {
599+
(_, ConstData::BoundVar(_)) => {
600+
// see comment in aggregate_tys
601+
false
602+
}
603+
604+
(ConstData::BoundVar(_), _) => {
605+
// see comment in aggregate_tys
606+
true
607+
}
608+
609+
(ConstData::InferenceVar(_), _) | (_, ConstData::InferenceVar(_)) => {
610+
panic!(
611+
"unexpected free inference variable in may-invalidate: {:?} vs {:?}",
612+
new, current,
613+
);
614+
}
615+
616+
(ConstData::Placeholder(p1), ConstData::Placeholder(p2)) => {
617+
self.aggregate_placeholders(p1, p2)
618+
}
619+
620+
(ConstData::Concrete(c1), ConstData::Concrete(c2)) => !c1.c_eq(c2, interner),
621+
622+
// Only variants left are placeholder = concrete, which always fails
623+
(ConstData::Placeholder(_), _) | (ConstData::Concrete(_), _) => true,
624+
}
597625
}
598626

599627
fn aggregate_application_tys(
@@ -618,7 +646,7 @@ impl<I: Interner> MayInvalidate<'_, I> {
618646
)
619647
}
620648

621-
fn aggregate_placeholder_tys(
649+
fn aggregate_placeholders(
622650
&mut self,
623651
new: &PlaceholderIndex,
624652
current: &PlaceholderIndex,

0 commit comments

Comments
 (0)