diff options
| author | Amanda Stjerna <amanda.stjerna@it.uu.se> | 2025-08-23 22:25:50 +0200 |
|---|---|---|
| committer | Amanda Stjerna <amanda.stjerna@it.uu.se> | 2025-08-23 22:25:50 +0200 |
| commit | ae622bb6af818d8592a143d391d4a7eacfee8f24 (patch) | |
| tree | e8a1a6e98e3d632d2253455b696e765f4fffc0fe /compiler/rustc_borrowck | |
| parent | 7dd56b10add80e21514df3a258b02106ebb52245 (diff) | |
| download | rust-ae622bb6af818d8592a143d391d4a7eacfee8f24.tar.gz rust-ae622bb6af818d8592a143d391d4a7eacfee8f24.zip | |
Simplify SCC annotations somewhat
Diffstat (limited to 'compiler/rustc_borrowck')
| -rw-r--r-- | compiler/rustc_borrowck/src/handle_placeholders.rs | 18 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/region_infer/mod.rs | 14 |
2 files changed, 8 insertions, 24 deletions
diff --git a/compiler/rustc_borrowck/src/handle_placeholders.rs b/compiler/rustc_borrowck/src/handle_placeholders.rs index b97d43a642b..94379cdebf7 100644 --- a/compiler/rustc_borrowck/src/handle_placeholders.rs +++ b/compiler/rustc_borrowck/src/handle_placeholders.rs @@ -1,8 +1,6 @@ //! Logic for lowering higher-kinded outlives constraints //! (with placeholders and universes) and turn them into regular //! outlives constraints. -use core::cmp; - use rustc_data_structures::frozen::Frozen; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::graph::scc; @@ -96,9 +94,9 @@ impl PlaceholderReachability { }, Placeholders { min_placeholder, max_placeholder, max_universe }, ) => Placeholders { - min_placeholder: cmp::min(min_pl, min_placeholder), - max_placeholder: cmp::max(max_pl, max_placeholder), - max_universe: cmp::max(max_u, max_universe), + min_placeholder: min_pl.min(min_placeholder), + max_placeholder: max_pl.max(max_placeholder), + max_universe: max_u.max(max_universe), }, } } @@ -190,17 +188,15 @@ impl scc::Annotation for RegionTracker { trace!("{:?} << {:?}", self.representative, other.representative); Self { - representative: self.representative.merge_scc(other.representative), - ..self.merge_reached(other) + representative: self.representative.min(other.representative), + max_nameable_universe: self.max_nameable_universe.min(other.max_nameable_universe), + reachable_placeholders: self.reachable_placeholders.merge(other.reachable_placeholders), } } fn merge_reached(self, other: Self) -> Self { Self { - max_nameable_universe: cmp::min( - self.max_nameable_universe, - other.max_nameable_universe, - ), + max_nameable_universe: self.max_nameable_universe.min(other.max_nameable_universe), reachable_placeholders: self.reachable_placeholders.merge(other.reachable_placeholders), representative: self.representative, } diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index f7b838a4638..9990f4cb3f2 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -3,7 +3,7 @@ use std::rc::Rc; use rustc_data_structures::frozen::Frozen; use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; -use rustc_data_structures::graph::scc::{self, Sccs}; +use rustc_data_structures::graph::scc::Sccs; use rustc_errors::Diag; use rustc_hir::def_id::CRATE_DEF_ID; use rustc_index::IndexVec; @@ -74,18 +74,6 @@ impl Representative { } } -impl scc::Annotation for Representative { - fn merge_scc(self, other: Self) -> Self { - // Just pick the smallest one. Note that we order by tag first! - std::cmp::min(self, other) - } - - // For reachability, we do nothing since the representative doesn't change. - fn merge_reached(self, _other: Self) -> Self { - self - } -} - pub(crate) type ConstraintSccs = Sccs<RegionVid, ConstraintSccIndex>; pub struct RegionInferenceContext<'tcx> { |
