Skip to content

Commit 2b17c27

Browse files
authored
Rollup merge of #94312 - pierwill:fix-94311-lattice-docs, r=jackh726
Edit `rustc_trait_selection::infer::lattice` docs Closes #94311. Removes mentions of outdated/missing type and filename (`infer.rs` and `LatticeValue`).
2 parents 163c207 + a014276 commit 2b17c27

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

compiler/rustc_infer/src/infer/glb.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Greatest lower bound. See [`lattice`].
2+
13
use super::combine::CombineFields;
24
use super::lattice::{self, LatticeDir};
35
use super::InferCtxt;

compiler/rustc_infer/src/infer/lattice.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
//! # Lattice Variables
1+
//! # Lattice variables
22
//!
3-
//! This file contains generic code for operating on inference variables
4-
//! that are characterized by an upper- and lower-bound. The logic and
5-
//! reasoning is explained in detail in the large comment in `infer.rs`.
3+
//! Generic code for operating on [lattices] of inference variables
4+
//! that are characterized by an upper- and lower-bound.
65
//!
7-
//! The code in here is defined quite generically so that it can be
6+
//! The code is defined quite generically so that it can be
87
//! applied both to type variables, which represent types being inferred,
98
//! and fn variables, which represent function types being inferred.
10-
//! It may eventually be applied to their types as well, who knows.
9+
//! (It may eventually be applied to their types as well.)
1110
//! In some cases, the functions are also generic with respect to the
1211
//! operation on the lattice (GLB vs LUB).
1312
//!
14-
//! Although all the functions are generic, we generally write the
15-
//! comments in a way that is specific to type variables and the LUB
16-
//! operation. It's just easier that way.
13+
//! ## Note
1714
//!
18-
//! In general all of the functions are defined parametrically
19-
//! over a `LatticeValue`, which is a value defined with respect to
20-
//! a lattice.
15+
//! Although all the functions are generic, for simplicity, comments in the source code
16+
//! generally refer to type variables and the LUB operation.
17+
//!
18+
//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order)
2119
2220
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
2321
use super::InferCtxt;
@@ -27,6 +25,11 @@ use rustc_middle::ty::relate::{RelateResult, TypeRelation};
2725
use rustc_middle::ty::TyVar;
2826
use rustc_middle::ty::{self, Ty};
2927

28+
/// Trait for returning data about a lattice, and for abstracting
29+
/// over the "direction" of the lattice operation (LUB/GLB).
30+
///
31+
/// GLB moves "down" the lattice (to smaller values); LUB moves
32+
/// "up" the lattice (to bigger values).
3033
pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> {
3134
fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>;
3235

@@ -41,6 +44,7 @@ pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> {
4144
fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>;
4245
}
4346

47+
/// Relates two types using a given lattice.
4448
pub fn super_lattice_tys<'a, 'tcx: 'a, L>(
4549
this: &mut L,
4650
a: Ty<'tcx>,

compiler/rustc_infer/src/infer/lub.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Least upper bound. See [`lattice`].
2+
13
use super::combine::CombineFields;
24
use super::lattice::{self, LatticeDir};
35
use super::InferCtxt;

0 commit comments

Comments
 (0)