Skip to content

Commit a800d70

Browse files
committed
Somewhat cleaner representation that separates concerns
1 parent 208a53b commit a800d70

File tree

2 files changed

+185
-173
lines changed
  • compiler/rustc_borrowck/src

2 files changed

+185
-173
lines changed

compiler/rustc_borrowck/src/constraints/mod.rs

+15-28
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ impl<'tcx> OutlivesConstraintSet<'tcx> {
152152
if let Some(to) = annotation.universe_violation() {
153153
outlives_static.insert(scc);
154154
self.add_placeholder_violation_constraint(
155-
annotation.representative,
156-
annotation.representative,
155+
annotation.representative_rvid(),
156+
annotation.representative_rvid(),
157157
to,
158158
fr_static,
159159
);
@@ -179,35 +179,22 @@ impl<'tcx> OutlivesConstraintSet<'tcx> {
179179
let annotation = sccs.annotation(scc);
180180

181181
if sccs.scc(fr_static) == scc || outlives_static.contains(&scc) {
182-
debug!("{:?} already outlives (or is) static", annotation.representative);
182+
debug!("{:?} already outlives (or is) static", annotation.representative_rvid());
183183
continue;
184184
}
185185

186-
// Unwrap safety: since this is our SCC it must contain us, which is
187-
// at worst min AND max, but it has at least one or there is a bug.
188-
let min = annotation.min_reachable_placeholder.unwrap();
189-
let max = annotation.max_reachable_placeholder.unwrap();
190-
191-
// Good path: Nothing to see here, at least no other placeholders!
192-
if min == max {
193-
continue;
194-
}
195-
196-
// Bad path: figure out who we illegally reached.
197-
// Note that this will prefer the representative if it is a
198-
// placeholder, since the representative has the smallest index!
199-
let other_placeholder = if min != rvid { min } else { max };
200-
201-
debug!(
202-
"Placeholder {rvid:?} of SCC {scc:?} reaches other placeholder {other_placeholder:?}"
203-
);
204-
outlives_static.insert(scc);
205-
self.add_placeholder_violation_constraint(
206-
annotation.representative,
207-
rvid,
208-
other_placeholder,
209-
fr_static,
210-
);
186+
if let Some(other_placeholder) = annotation.reaches_other_placeholder(rvid) {
187+
debug!(
188+
"Placeholder {rvid:?} of SCC {scc:?} reaches other placeholder {other_placeholder:?}"
189+
);
190+
outlives_static.insert(scc);
191+
self.add_placeholder_violation_constraint(
192+
annotation.representative_rvid(),
193+
rvid,
194+
other_placeholder,
195+
fr_static,
196+
);
197+
};
211198
}
212199

213200
if !outlives_static.is_empty() {

0 commit comments

Comments
 (0)