|
38 | 38 | //! [Hasse diagram]: https://en.wikipedia.org/wiki/Hasse_diagram |
39 | 39 | //! [poset]: https://en.wikipedia.org/wiki/Partially_ordered_set |
40 | 40 |
|
41 | | -use std::iter; |
42 | | - |
| 41 | +use rustc_index::Idx; |
43 | 42 | use rustc_index::bit_set::{BitSet, ChunkedBitSet}; |
44 | | -use rustc_index::{Idx, IndexVec}; |
45 | 43 |
|
46 | 44 | use crate::framework::BitSetExt; |
47 | 45 |
|
@@ -70,53 +68,6 @@ pub trait HasTop { |
70 | 68 | const TOP: Self; |
71 | 69 | } |
72 | 70 |
|
73 | | -/// A `bool` is a "two-point" lattice with `true` as the top element and `false` as the bottom: |
74 | | -/// |
75 | | -/// ```text |
76 | | -/// true |
77 | | -/// | |
78 | | -/// false |
79 | | -/// ``` |
80 | | -impl JoinSemiLattice for bool { |
81 | | - fn join(&mut self, other: &Self) -> bool { |
82 | | - if let (false, true) = (*self, *other) { |
83 | | - *self = true; |
84 | | - return true; |
85 | | - } |
86 | | - |
87 | | - false |
88 | | - } |
89 | | -} |
90 | | - |
91 | | -impl HasBottom for bool { |
92 | | - const BOTTOM: Self = false; |
93 | | - |
94 | | - fn is_bottom(&self) -> bool { |
95 | | - !self |
96 | | - } |
97 | | -} |
98 | | - |
99 | | -impl HasTop for bool { |
100 | | - const TOP: Self = true; |
101 | | -} |
102 | | - |
103 | | -/// A tuple (or list) of lattices is itself a lattice whose least upper bound is the concatenation |
104 | | -/// of the least upper bounds of each element of the tuple (or list). |
105 | | -/// |
106 | | -/// In other words: |
107 | | -/// (A₀, A₁, ..., Aₙ) ∨ (B₀, B₁, ..., Bₙ) = (A₀∨B₀, A₁∨B₁, ..., Aₙ∨Bₙ) |
108 | | -impl<I: Idx, T: JoinSemiLattice> JoinSemiLattice for IndexVec<I, T> { |
109 | | - fn join(&mut self, other: &Self) -> bool { |
110 | | - assert_eq!(self.len(), other.len()); |
111 | | - |
112 | | - let mut changed = false; |
113 | | - for (a, b) in iter::zip(self, other) { |
114 | | - changed |= a.join(b); |
115 | | - } |
116 | | - changed |
117 | | - } |
118 | | -} |
119 | | - |
120 | 71 | /// A `BitSet` represents the lattice formed by the powerset of all possible values of |
121 | 72 | /// the index type `T` ordered by inclusion. Equivalently, it is a tuple of "two-point" lattices, |
122 | 73 | /// one for each possible value of `T`. |
@@ -197,18 +148,6 @@ impl<T> MaybeReachable<T> { |
197 | 148 | } |
198 | 149 | } |
199 | 150 |
|
200 | | -impl<T> HasBottom for MaybeReachable<T> { |
201 | | - const BOTTOM: Self = MaybeReachable::Unreachable; |
202 | | - |
203 | | - fn is_bottom(&self) -> bool { |
204 | | - matches!(self, Self::Unreachable) |
205 | | - } |
206 | | -} |
207 | | - |
208 | | -impl<T: HasTop> HasTop for MaybeReachable<T> { |
209 | | - const TOP: Self = MaybeReachable::Reachable(T::TOP); |
210 | | -} |
211 | | - |
212 | 151 | impl<S> MaybeReachable<S> { |
213 | 152 | /// Return whether the current state contains the given element. If the state is unreachable, |
214 | 153 | /// it does no contain anything. |
|
0 commit comments