Skip to content

Commit

Permalink
By similar logic, RIP meet_mut_value_handle; assert_(in)variants now …
Browse files Browse the repository at this point in the history
…unused
  • Loading branch information
acl-cqc committed Sep 11, 2024
1 parent a71ba97 commit 05280a8
Showing 1 changed file with 5 additions and 33 deletions.
38 changes: 5 additions & 33 deletions hugr-passes/src/dataflow/partial_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,32 +190,6 @@ impl<V: AbstractValue> PartialValue<V> {
}
}

fn meet_mut_value_handle(&mut self, vh: V) -> bool {
self.assert_invariants();
match &*self {
Self::Bottom => false,
Self::Value(v) => {
if v == &vh {
false
} else {
*self = Self::Bottom;
true
}
}
Self::PartialSum(_) => match vh.into() {
Self::Value(_) => {
*self = Self::Bottom;
true
}
other => self.meet_mut(other),
},
Self::Top => {
*self = vh.into();
true
}
}
}

pub fn join(mut self, other: Self) -> Self {
self.join_mut(other);
self
Expand Down Expand Up @@ -336,14 +310,12 @@ impl<V: AbstractValue> Lattice for PartialValue<V> {
}
}
}
(Self::Value(_), mut other @ Self::PartialSum(_)) => {
std::mem::swap(self, &mut other);
let Self::Value(old_self) = other else {
unreachable!()
};
self.meet_mut_value_handle(old_self)
(Self::Value(ref v), Self::PartialSum(_))
| (Self::PartialSum(_), Self::Value(ref v)) => {
assert!(v.as_sum().is_none());
*self = Self::Bottom;
true
}
(Self::PartialSum(_), Self::Value(h)) => self.meet_mut_value_handle(h),
}
}
}
Expand Down

0 comments on commit 05280a8

Please sign in to comment.