Skip to content

Commit

Permalink
Remove unused dataflow trait impls and bounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Dec 10, 2024
1 parent 0dbb31f commit 83f67c5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 64 deletions.
63 changes: 1 addition & 62 deletions compiler/rustc_mir_dataflow/src/framework/lattice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@
//! [Hasse diagram]: https://en.wikipedia.org/wiki/Hasse_diagram
//! [poset]: https://en.wikipedia.org/wiki/Partially_ordered_set
use std::iter;

use rustc_index::Idx;
use rustc_index::bit_set::{BitSet, MixedBitSet};
use rustc_index::{Idx, IndexVec};

use crate::framework::BitSetExt;

Expand Down Expand Up @@ -70,53 +68,6 @@ pub trait HasTop {
const TOP: Self;
}

/// A `bool` is a "two-point" lattice with `true` as the top element and `false` as the bottom:
///
/// ```text
/// true
/// |
/// false
/// ```
impl JoinSemiLattice for bool {
fn join(&mut self, other: &Self) -> bool {
if let (false, true) = (*self, *other) {
*self = true;
return true;
}

false
}
}

impl HasBottom for bool {
const BOTTOM: Self = false;

fn is_bottom(&self) -> bool {
!self
}
}

impl HasTop for bool {
const TOP: Self = true;
}

/// A tuple (or list) of lattices is itself a lattice whose least upper bound is the concatenation
/// of the least upper bounds of each element of the tuple (or list).
///
/// In other words:
/// (A₀, A₁, ..., Aₙ) ∨ (B₀, B₁, ..., Bₙ) = (A₀∨B₀, A₁∨B₁, ..., Aₙ∨Bₙ)
impl<I: Idx, T: JoinSemiLattice> JoinSemiLattice for IndexVec<I, T> {
fn join(&mut self, other: &Self) -> bool {
assert_eq!(self.len(), other.len());

let mut changed = false;
for (a, b) in iter::zip(self, other) {
changed |= a.join(b);
}
changed
}
}

/// A `BitSet` represents the lattice formed by the powerset of all possible values of
/// the index type `T` ordered by inclusion. Equivalently, it is a tuple of "two-point" lattices,
/// one for each possible value of `T`.
Expand Down Expand Up @@ -197,18 +148,6 @@ impl<T> MaybeReachable<T> {
}
}

impl<T> HasBottom for MaybeReachable<T> {
const BOTTOM: Self = MaybeReachable::Unreachable;

fn is_bottom(&self) -> bool {
matches!(self, Self::Unreachable)
}
}

impl<T: HasTop> HasTop for MaybeReachable<T> {
const TOP: Self = MaybeReachable::Reachable(T::TOP);
}

impl<S> MaybeReachable<S> {
/// Return whether the current state contains the given element. If the state is unreachable,
/// it does no contain anything.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_dataflow/src/value_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<V: Clone> Clone for StateData<V> {
}
}

impl<V: JoinSemiLattice + Clone + HasBottom> JoinSemiLattice for StateData<V> {
impl<V: JoinSemiLattice + Clone> JoinSemiLattice for StateData<V> {
fn join(&mut self, other: &Self) -> bool {
let mut changed = false;
#[allow(rustc::potential_query_instability)]
Expand Down Expand Up @@ -342,7 +342,7 @@ impl<V: Clone + HasBottom> State<V> {
}
}

impl<V: JoinSemiLattice + Clone + HasBottom> JoinSemiLattice for State<V> {
impl<V: JoinSemiLattice + Clone> JoinSemiLattice for State<V> {
fn join(&mut self, other: &Self) -> bool {
match (&mut *self, other) {
(_, State::Unreachable) => false,
Expand Down

0 comments on commit 83f67c5

Please sign in to comment.