Skip to content

Commit 61a58f1

Browse files
committed
Fix join function for CsLattice
1 parent 97bfde3 commit 61a58f1

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/librustc_mir/transform/cs_propagate.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,18 @@ impl<'tcx> Lattice for CsLattice<'tcx> {
119119
fn join(&mut self, mut other: Self) -> bool {
120120
// Calculate inteersection this way:
121121
let mut changed = false;
122-
123122
// First, drain the self.values into a list of equal values common to both maps.
124123
let mut common_keys = vec![];
125-
for (key, value) in self.values.drain() {
124+
for (key, mut value) in self.values.drain() {
126125
match other.values.remove(&key) {
127126
// self had the key, but not other, so removing
128-
None => changed = true,
129-
Some(ov) => if ov.eq(&value) {
130-
// common key, equal value
131-
common_keys.push((key, value))
132-
} else {
133-
// both had key, but different values, so its a top.
134-
common_keys.push((key, Either::Top));
127+
None => {
135128
changed = true;
136-
},
129+
}
130+
Some(ov) => {
131+
changed |= value.join(ov);
132+
common_keys.push((key, value));
133+
}
137134
}
138135
}
139136
// Now, put each common key with equal value back into the map.

0 commit comments

Comments
 (0)