Skip to content

Commit 25bc709

Browse files
committed
Add MeetSemiLattice
The upstream version is removed, so we have to vendor the trait in.
1 parent 5876bc6 commit 25bc709

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/lattice.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright Gary Guo.
2+
//
3+
// SPDX-License-Identifier: MIT OR Apache-2.0
4+
5+
/// A [partially ordered set][poset] that has a [greatest lower bound][glb] for any pair of
6+
/// elements in the set.
7+
///
8+
/// Dataflow analyses only require that their domains implement [`JoinSemiLattice`], not
9+
/// `MeetSemiLattice`. However, types that will be used as dataflow domains should implement both
10+
/// so that they can be used with [`Dual`].
11+
///
12+
/// [glb]: https://en.wikipedia.org/wiki/Infimum_and_supremum
13+
/// [poset]: https://en.wikipedia.org/wiki/Partially_ordered_set
14+
pub trait MeetSemiLattice: Eq {
15+
/// Computes the greatest lower bound of two elements, storing the result in `self` and
16+
/// returning `true` if `self` has changed.
17+
///
18+
/// The lattice meet operator is abbreviated as `∧`.
19+
fn meet(&mut self, other: &Self) -> bool;
20+
}

src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ mod ctxt;
4949
mod atomic_context;
5050
mod attribute;
5151
mod infallible_allocation;
52+
mod lattice;
5253
mod mir;
5354
mod monomorphize_collector;
5455
mod preempt_count;

src/preempt_count/expectation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ use rustc_middle::mir::{self, Body, TerminatorKind};
99
use rustc_middle::ty::{
1010
self, GenericArgs, Instance, PseudoCanonicalInput, Ty, TypingEnv, TypingMode,
1111
};
12-
use rustc_mir_dataflow::lattice::MeetSemiLattice;
1312
use rustc_mir_dataflow::Analysis;
1413
use rustc_span::DUMMY_SP;
1514
use rustc_trait_selection::infer::TyCtxtInferExt;
1615

1716
use super::dataflow::AdjustmentComputation;
1817
use super::{AdjustmentBounds, Error, ExpectationRange, PolyDisplay, UseSite, UseSiteKind};
1918
use crate::ctxt::AnalysisCtxt;
19+
use crate::lattice::MeetSemiLattice;
2020

2121
impl<'tcx> AnalysisCtxt<'tcx> {
2222
pub fn terminator_expectation(

src/preempt_count/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ pub mod expectation;
1010

1111
use rustc_errors::ErrorGuaranteed;
1212
use rustc_middle::ty::{Instance, PseudoCanonicalInput};
13-
use rustc_mir_dataflow::lattice::MeetSemiLattice;
1413
use rustc_span::Span;
1514

1615
use self::dataflow::AdjustmentBounds;
16+
use crate::lattice::MeetSemiLattice;
1717

1818
#[derive(Clone, Copy, Debug, PartialEq, Eq, Encodable, Decodable)]
1919
pub enum Error {

0 commit comments

Comments
 (0)