Skip to content

Commit ae622bb

Browse files
committed
Simplify SCC annotations somewhat
1 parent 7dd56b1 commit ae622bb

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

compiler/rustc_borrowck/src/handle_placeholders.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//! Logic for lowering higher-kinded outlives constraints
22
//! (with placeholders and universes) and turn them into regular
33
//! outlives constraints.
4-
use core::cmp;
5-
64
use rustc_data_structures::frozen::Frozen;
75
use rustc_data_structures::fx::FxIndexMap;
86
use rustc_data_structures::graph::scc;
@@ -96,9 +94,9 @@ impl PlaceholderReachability {
9694
},
9795
Placeholders { min_placeholder, max_placeholder, max_universe },
9896
) => Placeholders {
99-
min_placeholder: cmp::min(min_pl, min_placeholder),
100-
max_placeholder: cmp::max(max_pl, max_placeholder),
101-
max_universe: cmp::max(max_u, max_universe),
97+
min_placeholder: min_pl.min(min_placeholder),
98+
max_placeholder: max_pl.max(max_placeholder),
99+
max_universe: max_u.max(max_universe),
102100
},
103101
}
104102
}
@@ -190,17 +188,15 @@ impl scc::Annotation for RegionTracker {
190188
trace!("{:?} << {:?}", self.representative, other.representative);
191189

192190
Self {
193-
representative: self.representative.merge_scc(other.representative),
194-
..self.merge_reached(other)
191+
representative: self.representative.min(other.representative),
192+
max_nameable_universe: self.max_nameable_universe.min(other.max_nameable_universe),
193+
reachable_placeholders: self.reachable_placeholders.merge(other.reachable_placeholders),
195194
}
196195
}
197196

198197
fn merge_reached(self, other: Self) -> Self {
199198
Self {
200-
max_nameable_universe: cmp::min(
201-
self.max_nameable_universe,
202-
other.max_nameable_universe,
203-
),
199+
max_nameable_universe: self.max_nameable_universe.min(other.max_nameable_universe),
204200
reachable_placeholders: self.reachable_placeholders.merge(other.reachable_placeholders),
205201
representative: self.representative,
206202
}

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::rc::Rc;
33

44
use rustc_data_structures::frozen::Frozen;
55
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
6-
use rustc_data_structures::graph::scc::{self, Sccs};
6+
use rustc_data_structures::graph::scc::Sccs;
77
use rustc_errors::Diag;
88
use rustc_hir::def_id::CRATE_DEF_ID;
99
use rustc_index::IndexVec;
@@ -74,18 +74,6 @@ impl Representative {
7474
}
7575
}
7676

77-
impl scc::Annotation for Representative {
78-
fn merge_scc(self, other: Self) -> Self {
79-
// Just pick the smallest one. Note that we order by tag first!
80-
std::cmp::min(self, other)
81-
}
82-
83-
// For reachability, we do nothing since the representative doesn't change.
84-
fn merge_reached(self, _other: Self) -> Self {
85-
self
86-
}
87-
}
88-
8977
pub(crate) type ConstraintSccs = Sccs<RegionVid, ConstraintSccIndex>;
9078

9179
pub struct RegionInferenceContext<'tcx> {

0 commit comments

Comments
 (0)