Skip to content

Commit 0725d0c

Browse files
committed
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

+4-51
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

+33-23
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

+24-10
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

+15-12
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
}

0 commit comments

Comments
 (0)