about summary refs log tree commit diff
path: root/compiler/rustc_mir_dataflow/src/framework/lattice.rs
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-04-24 17:10:39 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-05-09 17:27:58 +0000
commit71138e99337e791eb73d73d8a2cf8aaef29960b1 (patch)
tree6046dda092e81d7a7a15aef47e65ac4501d2100d /compiler/rustc_mir_dataflow/src/framework/lattice.rs
parentf7b831ac8a897273f78b9f47165cf8e54066ce4b (diff)
downloadrust-71138e99337e791eb73d73d8a2cf8aaef29960b1.tar.gz
rust-71138e99337e791eb73d73d8a2cf8aaef29960b1.zip
Make HasTop and HasBottom consts.
Diffstat (limited to 'compiler/rustc_mir_dataflow/src/framework/lattice.rs')
-rw-r--r--compiler/rustc_mir_dataflow/src/framework/lattice.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/compiler/rustc_mir_dataflow/src/framework/lattice.rs b/compiler/rustc_mir_dataflow/src/framework/lattice.rs
index af44a4329bf..3952f44ad48 100644
--- a/compiler/rustc_mir_dataflow/src/framework/lattice.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/lattice.rs
@@ -75,12 +75,12 @@ pub trait MeetSemiLattice: Eq {
 
 /// A set that has a "bottom" element, which is less than or equal to any other element.
 pub trait HasBottom {
-    fn bottom() -> Self;
+    const BOTTOM: Self;
 }
 
 /// A set that has a "top" element, which is greater than or equal to any other element.
 pub trait HasTop {
-    fn top() -> Self;
+    const TOP: Self;
 }
 
 /// A `bool` is a "two-point" lattice with `true` as the top element and `false` as the bottom:
@@ -113,15 +113,11 @@ impl MeetSemiLattice for bool {
 }
 
 impl HasBottom for bool {
-    fn bottom() -> Self {
-        false
-    }
+    const BOTTOM: Self = false;
 }
 
 impl HasTop for bool {
-    fn top() -> Self {
-        true
-    }
+    const TOP: Self = true;
 }
 
 /// A tuple (or list) of lattices is itself a lattice whose least upper bound is the concatenation
@@ -274,13 +270,9 @@ impl<T: Clone + Eq> MeetSemiLattice for FlatSet<T> {
 }
 
 impl<T> HasBottom for FlatSet<T> {
-    fn bottom() -> Self {
-        Self::Bottom
-    }
+    const BOTTOM: Self = Self::Bottom;
 }
 
 impl<T> HasTop for FlatSet<T> {
-    fn top() -> Self {
-        Self::Top
-    }
+    const TOP: Self = Self::Top;
 }