Skip to content

Commit 8f34a50

Browse files
committed
Remove ty::BrFresh and new_bound
1 parent c28084a commit 8f34a50

File tree

8 files changed

+4
-52
lines changed

8 files changed

+4
-52
lines changed

src/librustc/ich/impls_ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ for ty::RegionKind {
100100
ty::ReClosureBound(vid) => {
101101
vid.hash_stable(hcx, hasher);
102102
}
103-
ty::ReLateBound(..) |
104103
ty::ReVar(..) |
105104
ty::RePlaceholder(..) => {
106105
bug!("StableHasher: unexpected region {:?}", *self)

src/librustc/infer/error_reporting/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
218218
format!("the anonymous lifetime #{} defined on", idx + 1),
219219
self.hir().span_by_hir_id(node),
220220
),
221-
ty::BrFresh(_) => (
222-
"an anonymous lifetime defined on".to_owned(),
223-
self.hir().span_by_hir_id(node),
224-
),
225221
_ => (
226222
format!("the lifetime {} as defined on", region),
227223
cm.def_span(self.hir().span_by_hir_id(node)),

src/librustc/infer/region_constraints/mod.rs

+2-40
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use rustc_data_structures::indexed_vec::IndexVec;
1111
use rustc_data_structures::unify as ut;
1212
use crate::ty::ReStatic;
1313
use crate::ty::{self, Ty, TyCtxt};
14-
use crate::ty::{BrFresh, ReLateBound, ReVar};
14+
use crate::ty::{ReLateBound, ReVar};
1515
use crate::ty::{Region, RegionVid};
1616

1717
use std::collections::BTreeMap;
18-
use std::{cmp, fmt, mem, u32};
18+
use std::{cmp, fmt, mem};
1919
use std::ops::Range;
2020

2121
mod leak_check;
@@ -37,10 +37,6 @@ pub struct RegionConstraintCollector<'tcx> {
3737
/// exist). This prevents us from making many such regions.
3838
glbs: CombineMap<'tcx>,
3939

40-
/// Global counter used during the GLB algorithm to create unique
41-
/// names for fresh bound regions
42-
bound_count: u32,
43-
4440
/// The undo log records actions that might later be undone.
4541
///
4642
/// Note: `num_open_snapshots` is used to track if we are actively
@@ -392,7 +388,6 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
392388
data,
393389
lubs,
394390
glbs,
395-
bound_count: _,
396391
undo_log: _,
397392
num_open_snapshots: _,
398393
unification_table,
@@ -579,39 +574,6 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
579574
}
580575
}
581576

582-
pub fn new_bound(
583-
&mut self,
584-
tcx: TyCtxt<'_, '_, 'tcx>,
585-
debruijn: ty::DebruijnIndex,
586-
) -> Region<'tcx> {
587-
// Creates a fresh bound variable for use in GLB computations.
588-
// See discussion of GLB computation in the large comment at
589-
// the top of this file for more details.
590-
//
591-
// This computation is potentially wrong in the face of
592-
// rollover. It's conceivable, if unlikely, that one might
593-
// wind up with accidental capture for nested functions in
594-
// that case, if the outer function had bound regions created
595-
// a very long time before and the inner function somehow
596-
// wound up rolling over such that supposedly fresh
597-
// identifiers were in fact shadowed. For now, we just assert
598-
// that there is no rollover -- eventually we should try to be
599-
// robust against this possibility, either by checking the set
600-
// of bound identifiers that appear in a given expression and
601-
// ensure that we generate one that is distinct, or by
602-
// changing the representation of bound regions in a fn
603-
// declaration
604-
605-
let sc = self.bound_count;
606-
self.bound_count = sc + 1;
607-
608-
if sc >= self.bound_count {
609-
bug!("rollover in RegionInference new_bound()");
610-
}
611-
612-
tcx.mk_region(ReLateBound(debruijn, BrFresh(sc)))
613-
}
614-
615577
fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
616578
// cannot add constraints once regions are resolved
617579
debug!(

src/librustc/ty/print/pretty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,6 @@ impl<F: fmt::Write> FmtPrinter<'_, 'gcx, 'tcx, F> {
14411441
br
14421442
}
14431443
ty::BrAnon(_) |
1444-
ty::BrFresh(_) |
14451444
ty::BrEnv => {
14461445
let name = loop {
14471446
let name = name_by_region_index(region_index);

src/librustc/ty/structural_impls.rs

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ impl fmt::Debug for ty::BoundRegion {
9494
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9595
match *self {
9696
ty::BrAnon(n) => write!(f, "BrAnon({:?})", n),
97-
ty::BrFresh(n) => write!(f, "BrFresh({:?})", n),
9897
ty::BrNamed(did, name) => {
9998
write!(f, "BrNamed({:?}:{:?}, {})",
10099
did.krate, did.index, name)

src/librustc/ty/sty.rs

-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ pub enum BoundRegion {
5656
/// the event of shadowing.
5757
BrNamed(DefId, InternedString),
5858

59-
/// Fresh bound identifiers created during GLB computations.
60-
BrFresh(u32),
61-
6259
/// Anonymous region for the implicit env pointer parameter
6360
/// to a closure
6461
BrEnv,

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
274274
}
275275
}
276276

277-
ty::BoundRegion::BrAnon(_) | ty::BoundRegion::BrFresh(_) => None,
277+
ty::BoundRegion::BrAnon(_) => None,
278278
},
279279

280280
ty::ReLateBound(..)

src/librustc_typeck/astconv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
20482048
for br in late_bound_in_ret.difference(&late_bound_in_args) {
20492049
let lifetime_name = match *br {
20502050
ty::BrNamed(_, name) => format!("lifetime `{}`,", name),
2051-
ty::BrAnon(_) | ty::BrFresh(_) | ty::BrEnv => "an anonymous lifetime".to_string(),
2051+
ty::BrAnon(_) | ty::BrEnv => "an anonymous lifetime".to_string(),
20522052
};
20532053
let mut err = struct_span_err!(tcx.sess,
20542054
decl.output.span(),

0 commit comments

Comments
 (0)