Skip to content

Commit 180334c

Browse files
committed
remove pop_placeholders
1 parent a24c897 commit 180334c

File tree

4 files changed

+3
-80
lines changed

4 files changed

+3
-80
lines changed

src/librustc_infer/infer/higher_ranked/mod.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
6363
/// placeholder region. This is the first step of checking subtyping
6464
/// when higher-ranked things are involved.
6565
///
66-
/// **Important:** you must call this function from within a snapshot.
67-
/// Moreover, before committing the snapshot, you must eventually call
68-
/// either `plug_leaks` or `pop_placeholders` to remove the placeholder
69-
/// regions. If you rollback the snapshot (or are using a probe), then
70-
/// the pop occurs as part of the rollback, so an explicit call is not
71-
/// needed (but is also permitted).
72-
///
73-
/// For more information about how placeholders and HRTBs work, see
66+
/// **Important:** You have to be careful to not leak these placeholders,
67+
/// for more information about how placeholders and HRTBs work, see
7468
/// the [rustc dev guide].
7569
///
7670
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html

src/librustc_infer/infer/region_constraints/leak_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'tcx> TaintSet<'tcx> {
128128
verifys[i].origin.span(),
129129
"we never add verifications while doing higher-ranked things",
130130
),
131-
&Purged | &AddCombination(..) | &AddVar(..) => {}
131+
&AddCombination(..) | &AddVar(..) => {}
132132
}
133133
}
134134
}

src/librustc_infer/infer/region_constraints/mod.rs

-67
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,6 @@ pub(crate) enum UndoLog<'tcx> {
289289

290290
/// We added a GLB/LUB "combination variable".
291291
AddCombination(CombineMapType, TwoRegions<'tcx>),
292-
293-
/// During freshening, we sometimes purge entries from the undo
294-
/// log in a kind of minisnapshot (unlike other snapshots, this
295-
/// purging actually takes place *on success*). In that case, we
296-
/// replace the corresponding entry with `Noop` so as to avoid the
297-
/// need to do a bunch of swapping. (We can't use `swap_remove` as
298-
/// the order of the vector is important.)
299-
Purged,
300292
}
301293

302294
#[derive(Copy, Clone, PartialEq)]
@@ -357,9 +349,6 @@ impl<'tcx> RegionConstraintStorage<'tcx> {
357349

358350
fn rollback_undo_entry(&mut self, undo_entry: UndoLog<'tcx>) {
359351
match undo_entry {
360-
Purged => {
361-
// nothing to do here
362-
}
363352
AddVar(vid) => {
364353
self.var_infos.pop().unwrap();
365354
assert_eq!(self.var_infos.len(), vid.index() as usize);
@@ -488,62 +477,6 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
488477
self.var_infos[vid].origin
489478
}
490479

491-
/// Removes all the edges to/from the placeholder regions that are
492-
/// in `placeholders`. This is used after a higher-ranked operation
493-
/// completes to remove all trace of the placeholder regions
494-
/// created in that time.
495-
pub fn pop_placeholders(&mut self, placeholders: &FxHashSet<ty::Region<'tcx>>) {
496-
debug!("pop_placeholders(placeholders={:?})", placeholders);
497-
498-
assert!(UndoLogs::<super::UndoLog<'_>>::in_snapshot(&self.undo_log));
499-
500-
let constraints_to_kill: Vec<usize> = self
501-
.undo_log
502-
.iter()
503-
.enumerate()
504-
.rev()
505-
.filter(|&(_, undo_entry)| match undo_entry {
506-
super::UndoLog::RegionConstraintCollector(undo_entry) => {
507-
kill_constraint(placeholders, undo_entry)
508-
}
509-
_ => false,
510-
})
511-
.map(|(index, _)| index)
512-
.collect();
513-
514-
for index in constraints_to_kill {
515-
let undo_entry = match &mut self.undo_log[index] {
516-
super::UndoLog::RegionConstraintCollector(undo_entry) => {
517-
mem::replace(undo_entry, Purged)
518-
}
519-
_ => unreachable!(),
520-
};
521-
self.rollback_undo_entry(undo_entry);
522-
}
523-
524-
return;
525-
526-
fn kill_constraint<'tcx>(
527-
placeholders: &FxHashSet<ty::Region<'tcx>>,
528-
undo_entry: &UndoLog<'tcx>,
529-
) -> bool {
530-
match undo_entry {
531-
&AddConstraint(Constraint::VarSubVar(..)) => false,
532-
&AddConstraint(Constraint::RegSubVar(a, _)) => placeholders.contains(&a),
533-
&AddConstraint(Constraint::VarSubReg(_, b)) => placeholders.contains(&b),
534-
&AddConstraint(Constraint::RegSubReg(a, b)) => {
535-
placeholders.contains(&a) || placeholders.contains(&b)
536-
}
537-
&AddGiven(..) => false,
538-
&AddVerify(_) => false,
539-
&AddCombination(_, ref two_regions) => {
540-
placeholders.contains(&two_regions.a) || placeholders.contains(&two_regions.b)
541-
}
542-
&AddVar(..) | &Purged => false,
543-
}
544-
}
545-
}
546-
547480
fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
548481
// cannot add constraints once regions are resolved
549482
debug!("RegionConstraintCollector: add_constraint({:?})", constraint);

src/librustc_infer/infer/undo_log.rs

-4
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,6 @@ impl<'tcx> InferCtxtUndoLogs<'tcx> {
198198
assert!(self.logs.len() >= snapshot.undo_len);
199199
assert!(self.num_open_snapshots > 0);
200200
}
201-
202-
pub(crate) fn iter(&self) -> std::slice::Iter<'_, UndoLog<'tcx>> {
203-
self.logs.iter()
204-
}
205201
}
206202

207203
impl<'tcx> std::ops::Index<usize> for InferCtxtUndoLogs<'tcx> {

0 commit comments

Comments
 (0)