Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions compiler/rustc_mir_dataflow/src/framework/lattice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ pub trait MeetSemiLattice: Eq {
/// A set that has a "bottom" element, which is less than or equal to any other element.
pub trait HasBottom {
const BOTTOM: Self;

fn is_bottom(&self) -> bool;
}

/// A set that has a "top" element, which is greater than or equal to any other element.
Expand Down Expand Up @@ -114,6 +116,10 @@ impl MeetSemiLattice for bool {

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

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

impl HasTop for bool {
Expand Down Expand Up @@ -267,6 +273,10 @@ impl<T: Clone + Eq> MeetSemiLattice for FlatSet<T> {

impl<T> HasBottom for FlatSet<T> {
const BOTTOM: Self = Self::Bottom;

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

impl<T> HasTop for FlatSet<T> {
Expand All @@ -291,6 +301,10 @@ 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> {
Expand Down
Loading