Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0725d0c

Browse files
committedFeb 19, 2023
add some cfgs back
1 parent aefc5ec commit 0725d0c

File tree

7 files changed

+134
-124
lines changed

7 files changed

+134
-124
lines changed
 

‎Cargo.lock

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ dependencies = [
782782
"declare_clippy_lint",
783783
"if_chain",
784784
"itertools",
785-
"pulldown-cmark 0.9.2",
785+
"pulldown-cmark",
786786
"quine-mc_cluskey",
787787
"regex-syntax",
788788
"rustc-semver",
@@ -2003,15 +2003,9 @@ dependencies = [
20032003

20042004
[[package]]
20052005
name = "http-auth"
2006-
<<<<<<< HEAD
2007-
version = "0.1.8"
2008-
source = "registry+https://github.com/rust-lang/crates.io-index"
2009-
checksum = "5430cacd7a1f9a02fbeb350dfc81a0e5ed42d81f3398cb0ba184017f85bdcfbc"
2010-
=======
20112006
version = "0.1.6"
20122007
source = "registry+https://github.com/rust-lang/crates.io-index"
20132008
checksum = "c0b40b39d66c28829a0cf4d09f7e139ff8201f7500a5083732848ed3b4b4d850"
2014-
>>>>>>> 570ad623189 (remove cfgs)
20152009
dependencies = [
20162010
"memchr",
20172011
]
@@ -2561,7 +2555,7 @@ dependencies = [
25612555
"memchr",
25622556
"once_cell",
25632557
"opener",
2564-
"pulldown-cmark 0.9.2",
2558+
"pulldown-cmark",
25652559
"regex",
25662560
"serde",
25672561
"serde_json",
@@ -2578,7 +2572,7 @@ dependencies = [
25782572
"anyhow",
25792573
"handlebars 3.5.5",
25802574
"pretty_assertions",
2581-
"pulldown-cmark 0.7.2",
2575+
"pulldown-cmark",
25822576
"same-file",
25832577
"serde_json",
25842578
"url",
@@ -3275,17 +3269,6 @@ dependencies = [
32753269
"cc",
32763270
]
32773271

3278-
[[package]]
3279-
name = "pulldown-cmark"
3280-
version = "0.7.2"
3281-
source = "registry+https://github.com/rust-lang/crates.io-index"
3282-
checksum = "ca36dea94d187597e104a5c8e4b07576a8a45aa5db48a65e12940d3eb7461f55"
3283-
dependencies = [
3284-
"bitflags",
3285-
"memchr",
3286-
"unicase",
3287-
]
3288-
32893272
[[package]]
32903273
name = "pulldown-cmark"
32913274
version = "0.9.2"
@@ -4589,7 +4572,7 @@ name = "rustc_resolve"
45894572
version = "0.0.0"
45904573
dependencies = [
45914574
"bitflags",
4592-
"pulldown-cmark 0.9.2",
4575+
"pulldown-cmark",
45934576
"rustc_arena",
45944577
"rustc_ast",
45954578
"rustc_ast_pretty",
@@ -6277,7 +6260,6 @@ checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
62776260

62786261
[[package]]
62796262
name = "windows_aarch64_msvc"
6280-
<<<<<<< HEAD
62816263
version = "0.42.1"
62826264
source = "registry+https://github.com/rust-lang/crates.io-index"
62836265
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
@@ -6299,29 +6281,6 @@ name = "windows_x86_64_gnu"
62996281
version = "0.42.1"
63006282
source = "registry+https://github.com/rust-lang/crates.io-index"
63016283
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
6302-
=======
6303-
version = "0.42.0"
6304-
source = "registry+https://github.com/rust-lang/crates.io-index"
6305-
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
6306-
6307-
[[package]]
6308-
name = "windows_i686_gnu"
6309-
version = "0.42.0"
6310-
source = "registry+https://github.com/rust-lang/crates.io-index"
6311-
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
6312-
6313-
[[package]]
6314-
name = "windows_i686_msvc"
6315-
version = "0.42.0"
6316-
source = "registry+https://github.com/rust-lang/crates.io-index"
6317-
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
6318-
6319-
[[package]]
6320-
name = "windows_x86_64_gnu"
6321-
version = "0.42.0"
6322-
source = "registry+https://github.com/rust-lang/crates.io-index"
6323-
checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
6324-
>>>>>>> 570ad623189 (remove cfgs)
63256284

63266285
[[package]]
63276286
name = "windows_x86_64_gnullvm"
@@ -6331,15 +6290,9 @@ checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
63316290

63326291
[[package]]
63336292
name = "windows_x86_64_msvc"
6334-
<<<<<<< HEAD
63356293
version = "0.42.1"
63366294
source = "registry+https://github.com/rust-lang/crates.io-index"
63376295
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
6338-
=======
6339-
version = "0.42.0"
6340-
source = "registry+https://github.com/rust-lang/crates.io-index"
6341-
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
6342-
>>>>>>> 570ad623189 (remove cfgs)
63436296

63446297
[[package]]
63456298
name = "writeable"

‎compiler/rustc_borrowck/src/lib.rs

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -495,49 +495,59 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> {
495495
BorrowckInferCtxt { infcx, reg_var_to_origin: RefCell::new(Default::default()) }
496496
}
497497

498-
pub(crate) fn next_region_var(
498+
pub(crate) fn next_region_var<F>(
499499
&self,
500500
origin: RegionVariableOrigin,
501-
ctxt: RegionCtxt,
502-
) -> ty::Region<'tcx> {
501+
get_ctxt_fn: F,
502+
) -> ty::Region<'tcx>
503+
where
504+
F: Fn() -> RegionCtxt,
505+
{
503506
let next_region = self.infcx.next_region_var(origin);
504507
let vid = next_region
505508
.try_get_var()
506509
.unwrap_or_else(|| bug!("expected RegionKind::RegionVar on {:?}", next_region));
507510

508-
debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin);
509-
let mut var_to_origin = self.reg_var_to_origin.borrow_mut();
510-
let prev = var_to_origin.insert(vid, ctxt);
511-
debug!("var_to_origin after insertion: {:?}", var_to_origin);
511+
if cfg!(debug_assertions) {
512+
debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin);
513+
let ctxt = get_ctxt_fn();
514+
let mut var_to_origin = self.reg_var_to_origin.borrow_mut();
515+
let prev = var_to_origin.insert(vid, ctxt);
512516

513-
// This only makes sense if not called in a canonicalization context. If this
514-
// ever changes we either want to get rid of `BorrowckInferContext::reg_var_to_origin`
515-
// or modify how we track nll region vars for that map.
516-
assert!(matches!(prev, None));
517+
// This only makes sense if not called in a canonicalization context. If this
518+
// ever changes we either want to get rid of `BorrowckInferContext::reg_var_to_origin`
519+
// or modify how we track nll region vars for that map.
520+
assert!(matches!(prev, None));
521+
}
517522

518523
next_region
519524
}
520525

521-
#[instrument(skip(self), level = "debug")]
522-
pub(crate) fn next_nll_region_var(
526+
#[instrument(skip(self, get_ctxt_fn), level = "debug")]
527+
pub(crate) fn next_nll_region_var<F>(
523528
&self,
524529
origin: NllRegionVariableOrigin,
525-
ctxt: RegionCtxt,
526-
) -> ty::Region<'tcx> {
530+
get_ctxt_fn: F,
531+
) -> ty::Region<'tcx>
532+
where
533+
F: Fn() -> RegionCtxt,
534+
{
527535
let next_region = self.infcx.next_nll_region_var(origin.clone());
528536
let vid = next_region
529537
.try_get_var()
530538
.unwrap_or_else(|| bug!("expected RegionKind::RegionVar on {:?}", next_region));
531539

532-
debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin);
533-
let mut var_to_origin = self.reg_var_to_origin.borrow_mut();
534-
let prev = var_to_origin.insert(vid, ctxt);
535-
debug!("var_to_origin after insertion: {:?}", var_to_origin);
540+
if cfg!(debug_assertions) {
541+
debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin);
542+
let ctxt = get_ctxt_fn();
543+
let mut var_to_origin = self.reg_var_to_origin.borrow_mut();
544+
let prev = var_to_origin.insert(vid, ctxt);
536545

537-
// This only makes sense if not called in a canonicalization context. If this
538-
// ever changes we either want to get rid of `BorrowckInferContext::reg_var_to_origin`
539-
// or modify how we track nll region vars for that map.
540-
assert!(matches!(prev, None));
546+
// This only makes sense if not called in a canonicalization context. If this
547+
// ever changes we either want to get rid of `BorrowckInferContext::reg_var_to_origin`
548+
// or modify how we track nll region vars for that map.
549+
assert!(matches!(prev, None));
550+
}
541551

542552
next_region
543553
}

‎compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ pub enum ExtraConstraintInfo {
244244
PlaceholderFromPredicate(Span),
245245
}
246246

247+
#[cfg(debug_assertions)]
247248
#[instrument(skip(infcx, sccs), level = "debug")]
248249
fn sccs_info<'cx, 'tcx>(
249250
infcx: &'cx BorrowckInferCtxt<'cx, 'tcx>,
@@ -252,31 +253,43 @@ fn sccs_info<'cx, 'tcx>(
252253
use crate::renumber::RegionCtxt;
253254

254255
let var_to_origin = infcx.reg_var_to_origin.borrow();
256+
257+
let mut var_to_origin_sorted = var_to_origin.clone().into_iter().collect::<Vec<_>>();
258+
var_to_origin_sorted.sort_by(|a, b| a.0.cmp(&b.0));
259+
let mut debug_str = "region variables to origins:\n".to_string();
260+
for (reg_var, origin) in var_to_origin_sorted.into_iter() {
261+
debug_str.push_str(&format!("{:?}: {:?}\n", reg_var, origin));
262+
}
263+
debug!(debug_str);
264+
255265
let num_components = sccs.scc_data.ranges.len();
256266
let mut components = vec![FxHashSet::default(); num_components];
257267

258268
for (reg_var_idx, scc_idx) in sccs.scc_indices.iter().enumerate() {
259269
let reg_var = ty::RegionVid::from_usize(reg_var_idx);
260270
let origin = var_to_origin.get(&reg_var).unwrap_or_else(|| &RegionCtxt::Unknown);
261-
components[scc_idx.as_usize()].insert(*origin);
271+
components[scc_idx.as_usize()].insert((reg_var, *origin));
262272
}
263273

264-
debug!(
265-
"strongly connected components: {:#?}",
266-
components
267-
.iter()
268-
.enumerate()
269-
.map(|(idx, origin)| { (ConstraintSccIndex::from_usize(idx), origin) })
270-
.collect::<Vec<_>>()
271-
);
274+
let mut components_str = "strongly connected components:";
275+
for (scc_idx, reg_vars_origins) in components.iter().enumerate() {
276+
let regions_info = reg_vars_origins.clone().into_iter().collect::<Vec<_>>();
277+
components_str.push(&format(
278+
"{:?}: {:?})",
279+
ConstraintSccIndex::from_usize(scc_idx),
280+
regions_info,
281+
))
282+
}
283+
debug!(components_str);
272284

273-
// Now let's calculate the best representative for each component
285+
// calculate the best representative for each component
274286
let components_representatives = components
275287
.into_iter()
276288
.enumerate()
277289
.map(|(scc_idx, region_ctxts)| {
278290
let repr = region_ctxts
279291
.into_iter()
292+
.map(|reg_var_origin| reg_var_origin.1)
280293
.max_by(|x, y| x.preference_value().cmp(&y.preference_value()))
281294
.unwrap();
282295

@@ -333,6 +346,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
333346
let fr_static = universal_regions.fr_static;
334347
let constraint_sccs = Rc::new(constraints.compute_sccs(&constraint_graph, fr_static));
335348

349+
#[cfg(debug_assertions)]
336350
sccs_info(_infcx, constraint_sccs.clone());
337351

338352
let mut scc_values =

‎compiler/rustc_borrowck/src/renumber.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,19 @@ pub fn renumber_mir<'tcx>(
3131

3232
/// Replaces all regions appearing in `value` with fresh inference
3333
/// variables.
34-
#[instrument(skip(infcx), level = "debug")]
35-
pub(crate) fn renumber_regions<'tcx, T>(
34+
#[instrument(skip(infcx, get_ctxt_fn), level = "debug")]
35+
pub(crate) fn renumber_regions<'tcx, T, F>(
3636
infcx: &BorrowckInferCtxt<'_, 'tcx>,
3737
value: T,
38-
ctxt: RegionCtxt,
38+
get_ctxt_fn: F,
3939
) -> T
4040
where
4141
T: TypeFoldable<'tcx>,
42+
F: Fn() -> RegionCtxt,
4243
{
4344
infcx.tcx.fold_regions(value, |_region, _depth| {
4445
let origin = NllRegionVariableOrigin::Existential { from_forall: false };
45-
infcx.next_nll_region_var(origin, ctxt)
46+
infcx.next_nll_region_var(origin, || get_ctxt_fn())
4647
})
4748
}
4849

@@ -61,13 +62,14 @@ pub(crate) enum RegionCtxt {
6162
LateBound(BoundRegionInfo),
6263
Existential(Option<Symbol>),
6364
Placeholder(BoundRegionInfo),
65+
#[cfg(debug_assertions)]
6466
Unknown,
6567
}
6668

6769
impl RegionCtxt {
6870
/// Used to determine the representative of a component in the strongly connected
6971
/// constraint graph
70-
/// FIXME: don't use underscore here. Got a 'not used' error for some reason
72+
#[cfg(debug_assertions)]
7173
pub(crate) fn preference_value(self) -> usize {
7274
let _anon = Symbol::intern("anon");
7375

@@ -87,11 +89,12 @@ struct NllVisitor<'a, 'tcx> {
8789
}
8890

8991
impl<'a, 'tcx> NllVisitor<'a, 'tcx> {
90-
fn renumber_regions<T>(&mut self, value: T, ctxt: RegionCtxt) -> T
92+
fn renumber_regions<T, F>(&mut self, value: T, region_ctxt_fn: F) -> T
9193
where
9294
T: TypeFoldable<'tcx>,
95+
F: Fn() -> RegionCtxt,
9396
{
94-
renumber_regions(self.infcx, value, ctxt)
97+
renumber_regions(self.infcx, value, region_ctxt_fn)
9598
}
9699
}
97100

@@ -101,31 +104,31 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
101104
}
102105

103106
#[instrument(skip(self), level = "debug")]
104-
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, _ty_context: TyContext) {
105-
*ty = self.renumber_regions(*ty, RegionCtxt::TyContext(_ty_context));
107+
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
108+
*ty = self.renumber_regions(*ty, || RegionCtxt::TyContext(ty_context));
106109

107110
debug!(?ty);
108111
}
109112

110113
#[instrument(skip(self), level = "debug")]
111114
fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, location: Location) {
112-
*substs = self.renumber_regions(*substs, RegionCtxt::Location(location));
115+
*substs = self.renumber_regions(*substs, || RegionCtxt::Location(location));
113116

114117
debug!(?substs);
115118
}
116119

117120
#[instrument(skip(self), level = "debug")]
118121
fn visit_region(&mut self, region: &mut ty::Region<'tcx>, location: Location) {
119122
let old_region = *region;
120-
*region = self.renumber_regions(old_region, RegionCtxt::Location(location));
123+
*region = self.renumber_regions(old_region, || RegionCtxt::Location(location));
121124

122125
debug!(?region);
123126
}
124127

125128
#[instrument(skip(self), level = "debug")]
126129
fn visit_constant(&mut self, constant: &mut Constant<'tcx>, _location: Location) {
127130
let literal = constant.literal;
128-
constant.literal = self.renumber_regions(literal, RegionCtxt::Location(_location));
131+
constant.literal = self.renumber_regions(literal, || RegionCtxt::Location(_location));
129132
debug!("constant: {:#?}", constant);
130133
}
131134
}

‎compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,14 +1338,21 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13381338
use crate::renumber::{BoundRegionInfo, RegionCtxt};
13391339
use rustc_span::Symbol;
13401340

1341-
let reg_info = match br.kind {
1342-
// FIXME Probably better to use the `Span` here
1343-
ty::BoundRegionKind::BrAnon(_, Some(span)) => BoundRegionInfo::Span(span),
1344-
ty::BoundRegionKind::BrAnon(..) => {
1345-
BoundRegionInfo::Name(Symbol::intern("anon"))
1346-
}
1347-
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
1348-
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(Symbol::intern("env")),
1341+
let region_ctxt_fn = || {
1342+
let reg_info = match br.kind {
1343+
ty::BoundRegionKind::BrAnon(_, Some(span)) => {
1344+
BoundRegionInfo::Span(span)
1345+
}
1346+
ty::BoundRegionKind::BrAnon(..) => {
1347+
BoundRegionInfo::Name(Symbol::intern("anon"))
1348+
}
1349+
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
1350+
ty::BoundRegionKind::BrEnv => {
1351+
BoundRegionInfo::Name(Symbol::intern("env"))
1352+
}
1353+
};
1354+
1355+
RegionCtxt::LateBound(reg_info)
13491356
};
13501357

13511358
self.infcx.next_region_var(
@@ -1354,7 +1361,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13541361
br.kind,
13551362
LateBoundRegionConversionTime::FnCall,
13561363
),
1357-
RegionCtxt::LateBound(reg_info),
1364+
region_ctxt_fn,
13581365
)
13591366
});
13601367
debug!(?sig);

‎compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
110110
let origin = NllRegionVariableOrigin::Existential { from_forall };
111111

112112
let reg_var =
113-
self.type_checker.infcx.next_nll_region_var(origin, RegionCtxt::Existential(_name));
113+
self.type_checker.infcx.next_nll_region_var(origin, || RegionCtxt::Existential(_name));
114114

115115
reg_var
116116
}
@@ -150,9 +150,16 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
150150
let reg_var = reg
151151
.try_get_var()
152152
.unwrap_or_else(|| bug!("expected region {:?} to be of kind ReVar", reg));
153-
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
154-
let prev = var_to_origin.insert(reg_var, RegionCtxt::Existential(None));
155-
assert!(matches!(prev, None));
153+
154+
if cfg!(debug_assertions) {
155+
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
156+
let prev = var_to_origin.insert(reg_var, RegionCtxt::Existential(None));
157+
158+
// It only makes sense to track region vars in non-canonicalization contexts. If this
159+
// ever changes we either want to get rid of `BorrowckInferContext::reg_var_to_origin`
160+
// or modify how we track nll region vars for that map.
161+
assert!(matches!(prev, None));
162+
}
156163

157164
reg
158165
}

‎compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
408408
// Create the "global" region that is always free in all contexts: 'static.
409409
let fr_static = self
410410
.infcx
411-
.next_nll_region_var(FR, RegionCtxt::Free(Symbol::intern("static")))
411+
.next_nll_region_var(FR, || RegionCtxt::Free(Symbol::intern("static")))
412412
.to_region_vid();
413413

414414
// We've now added all the global regions. The next ones we
@@ -447,10 +447,9 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
447447
_ => Symbol::intern("anon"),
448448
};
449449

450-
self.infcx.next_nll_region_var(
451-
FR,
452-
RegionCtxt::LateBound(BoundRegionInfo::Name(name)),
453-
)
450+
self.infcx.next_nll_region_var(FR, || {
451+
RegionCtxt::LateBound(BoundRegionInfo::Name(name))
452+
})
454453
};
455454

456455
debug!(?region_vid);
@@ -486,8 +485,9 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
486485
_ => Symbol::intern("anon"),
487486
};
488487

489-
self.infcx
490-
.next_nll_region_var(FR, RegionCtxt::LateBound(BoundRegionInfo::Name(name)))
488+
self.infcx.next_nll_region_var(FR, || {
489+
RegionCtxt::LateBound(BoundRegionInfo::Name(name))
490+
})
491491
};
492492

493493
debug!(?region_vid);
@@ -506,9 +506,13 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
506506
LangItem::VaList,
507507
Some(self.infcx.tcx.def_span(self.mir_def.did)),
508508
);
509-
let reg_vid = self.infcx.next_nll_region_var(FR, RegionCtxt::Free(Symbol::intern("c-variadic")).to_region_vid();
510-
let region =
511-
self.infcx.tcx.mk_re_var(reg_vid);
509+
510+
let reg_vid = self
511+
.infcx
512+
.next_nll_region_var(FR, || RegionCtxt::Free(Symbol::intern("c-variadic")))
513+
.to_region_vid();
514+
515+
let region = self.infcx.tcx.mk_re_var(reg_vid);
512516
let va_list_ty =
513517
self.infcx.tcx.type_of(va_list_did).subst(self.infcx.tcx, &[region.into()]);
514518

@@ -520,7 +524,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
520524

521525
let fr_fn_body = self
522526
.infcx
523-
.next_nll_region_var(FR, RegionCtxt::Free(Symbol::intern("fn_body")))
527+
.next_nll_region_var(FR, || RegionCtxt::Free(Symbol::intern("fn_body")))
524528
.to_region_vid();
525529

526530
let num_universals = self.infcx.num_region_vars();
@@ -766,7 +770,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
766770
};
767771
debug!(?region, ?name);
768772

769-
let reg_var = self.next_nll_region_var(origin, RegionCtxt::Free(name));
773+
let reg_var = self.next_nll_region_var(origin, || RegionCtxt::Free(name));
770774

771775
reg_var
772776
})
@@ -786,7 +790,15 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
786790
let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| {
787791
debug!(?br);
788792
let liberated_region = self.tcx.mk_re_free(all_outlive_scope.to_def_id(), br.kind);
789-
let region_vid = self.next_nll_region_var(origin, RegionCtxt::Bound(BoundRegionInfo::Name(name)));
793+
let region_vid = {
794+
let name = match br.kind.get_name() {
795+
Some(name) => name,
796+
_ => Symbol::intern("anon"),
797+
};
798+
799+
self.next_nll_region_var(origin, || RegionCtxt::Bound(BoundRegionInfo::Name(name)))
800+
};
801+
790802
indices.insert_late_bound_region(liberated_region, region_vid.to_region_vid());
791803
debug!(?liberated_region, ?region_vid);
792804
region_vid
@@ -818,7 +830,9 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
818830
_ => Symbol::intern("anon"),
819831
};
820832

821-
self.next_nll_region_var(FR, RegionCtxt::LateBound(BoundRegionInfo::Name(name)))
833+
self.next_nll_region_var(FR, || {
834+
RegionCtxt::LateBound(BoundRegionInfo::Name(name))
835+
})
822836
};
823837

824838
debug!(?region_vid);
@@ -842,7 +856,9 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
842856
_ => Symbol::intern("anon"),
843857
};
844858

845-
self.next_nll_region_var(FR, RegionCtxt::LateBound(BoundRegionInfo::Name(name)))
859+
self.next_nll_region_var(FR, || {
860+
RegionCtxt::LateBound(BoundRegionInfo::Name(name))
861+
})
846862
};
847863

848864
indices.insert_late_bound_region(r, region_vid.to_region_vid());

0 commit comments

Comments
 (0)
Please sign in to comment.