Skip to content

Commit 70497d9

Browse files
committed
fold_region: remove unused parameter
1 parent 4dbf9ba commit 70497d9

File tree

12 files changed

+18
-24
lines changed

12 files changed

+18
-24
lines changed

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
879879
}
880880

881881
let mut found = false;
882-
tcx.fold_regions(tcx.type_of(body_parent_did), &mut true, |r: ty::Region<'tcx>, _| {
882+
tcx.fold_regions(tcx.type_of(body_parent_did), |r: ty::Region<'tcx>, _| {
883883
if *r == ty::ReEarlyBound(region) {
884884
found = true;
885885
}

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
10091009

10101010
debug!("try_promote_type_test_subject(ty = {:?})", ty);
10111011

1012-
let ty = tcx.fold_regions(ty, &mut false, |r, _depth| {
1012+
let ty = tcx.fold_regions(ty, |r, _depth| {
10131013
let region_vid = self.to_region_vid(r);
10141014

10151015
// The challenge if this. We have some region variable `r`
@@ -1289,7 +1289,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
12891289
where
12901290
T: TypeFoldable<'tcx>,
12911291
{
1292-
tcx.fold_regions(value, &mut false, |r, _db| {
1292+
tcx.fold_regions(value, |r, _db| {
12931293
let vid = self.to_region_vid(r);
12941294
let scc = self.constraint_sccs.scc(vid);
12951295
let repr = self.scc_representatives[scc];

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
5959
debug!(?concrete_type, ?substs);
6060

6161
let mut subst_regions = vec![self.universal_regions.fr_static];
62-
let universal_substs = infcx.tcx.fold_regions(substs, &mut false, |region, _| {
62+
let universal_substs = infcx.tcx.fold_regions(substs, |region, _| {
6363
if let ty::RePlaceholder(..) = region.kind() {
6464
// Higher kinded regions don't need remapping, they don't refer to anything outside of this the substs.
6565
return region;
@@ -91,7 +91,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
9191
subst_regions.dedup();
9292

9393
let universal_concrete_type =
94-
infcx.tcx.fold_regions(concrete_type, &mut false, |region, _| match *region {
94+
infcx.tcx.fold_regions(concrete_type, |region, _| match *region {
9595
ty::ReVar(vid) => subst_regions
9696
.iter()
9797
.find(|ur_vid| self.eval_equal(vid, **ur_vid))
@@ -146,7 +146,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
146146
where
147147
T: TypeFoldable<'tcx>,
148148
{
149-
tcx.fold_regions(ty, &mut false, |region, _| match *region {
149+
tcx.fold_regions(ty, |region, _| match *region {
150150
ty::ReVar(vid) => {
151151
// Find something that we can name
152152
let upper_bound = self.approx_universal_upper_bound(vid);

compiler/rustc_borrowck/src/renumber.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn renumber_regions<'tcx, T>(infcx: &InferCtxt<'_, 'tcx>, value: T) -> T
3131
where
3232
T: TypeFoldable<'tcx>,
3333
{
34-
infcx.tcx.fold_regions(value, &mut false, |_region, _depth| {
34+
infcx.tcx.fold_regions(value, |_region, _depth| {
3535
let origin = NllRegionVariableOrigin::Existential { from_forall: false };
3636
infcx.next_nll_region_var(origin)
3737
})

compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
108108
// create new region variables, which can't be done later when
109109
// verifying these bounds.
110110
if t1.has_placeholders() {
111-
t1 = tcx.fold_regions(t1, &mut false, |r, _| match *r {
111+
t1 = tcx.fold_regions(t1, |r, _| match *r {
112112
ty::RePlaceholder(placeholder) => {
113113
self.constraints.placeholder_region(self.infcx, placeholder)
114114
}

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
725725
where
726726
T: TypeFoldable<'tcx>,
727727
{
728-
self.tcx.fold_regions(value, &mut false, |_region, _depth| self.next_nll_region_var(origin))
728+
self.tcx.fold_regions(value, |_region, _depth| self.next_nll_region_var(origin))
729729
}
730730

731731
#[instrument(level = "debug", skip(self, indices))]
@@ -817,9 +817,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
817817
where
818818
T: TypeFoldable<'tcx>,
819819
{
820-
tcx.fold_regions(value, &mut false, |region, _| {
821-
tcx.mk_region(ty::ReVar(self.to_region_vid(region)))
822-
})
820+
tcx.fold_regions(value, |region, _| tcx.mk_region(ty::ReVar(self.to_region_vid(region))))
823821
}
824822
}
825823

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn find_param_with_region<'tcx>(
7979
// May return None; sometimes the tables are not yet populated.
8080
let ty = fn_sig.inputs()[index];
8181
let mut found_anon_region = false;
82-
let new_param_ty = tcx.fold_regions(ty, &mut false, |r, _| {
82+
let new_param_ty = tcx.fold_regions(ty, |r, _| {
8383
if r == anon_region {
8484
found_anon_region = true;
8585
replace_region

compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ impl<'tcx> LexicalRegionResolutions<'tcx> {
868868
where
869869
T: TypeFoldable<'tcx>,
870870
{
871-
tcx.fold_regions(value, &mut false, |r, _db| match *r {
871+
tcx.fold_regions(value, |r, _db| match *r {
872872
ty::ReVar(rid) => self.resolve_var(rid),
873873
_ => r,
874874
})

compiler/rustc_middle/src/ty/fold.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,12 @@ impl<'tcx> TyCtxt<'tcx> {
465465
pub fn fold_regions<T>(
466466
self,
467467
value: T,
468-
skipped_regions: &mut bool,
469468
mut f: impl FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>,
470469
) -> T
471470
where
472471
T: TypeFoldable<'tcx>,
473472
{
474-
value.fold_with(&mut RegionFolder::new(self, skipped_regions, &mut f))
473+
value.fold_with(&mut RegionFolder::new(self, &mut f))
475474
}
476475

477476
/// Invoke `callback` on every region appearing free in `value`.
@@ -579,7 +578,6 @@ impl<'tcx> TyCtxt<'tcx> {
579578
580579
pub struct RegionFolder<'a, 'tcx> {
581580
tcx: TyCtxt<'tcx>,
582-
skipped_regions: &'a mut bool,
583581

584582
/// Stores the index of a binder *just outside* the stuff we have
585583
/// visited. So this begins as INNERMOST; when we pass through a
@@ -597,10 +595,9 @@ impl<'a, 'tcx> RegionFolder<'a, 'tcx> {
597595
#[inline]
598596
pub fn new(
599597
tcx: TyCtxt<'tcx>,
600-
skipped_regions: &'a mut bool,
601598
fold_region_fn: &'a mut dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>,
602599
) -> RegionFolder<'a, 'tcx> {
603-
RegionFolder { tcx, skipped_regions, current_index: ty::INNERMOST, fold_region_fn }
600+
RegionFolder { tcx, current_index: ty::INNERMOST, fold_region_fn }
604601
}
605602
}
606603

@@ -624,7 +621,6 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx> {
624621
match *r {
625622
ty::ReLateBound(debruijn, _) if debruijn < self.current_index => {
626623
debug!(?self.current_index, "skipped bound region");
627-
*self.skipped_regions = true;
628624
r
629625
}
630626
_ => {

compiler/rustc_typeck/src/check/generator_interior.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub fn resolve_interior<'a, 'tcx>(
225225
// Note that each region slot in the types gets a new fresh late bound region,
226226
// which means that none of the regions inside relate to any other, even if
227227
// typeck had previously found constraints that would cause them to be related.
228-
let folded = fcx.tcx.fold_regions(erased, &mut false, |_, current_depth| {
228+
let folded = fcx.tcx.fold_regions(erased, |_, current_depth| {
229229
let br = ty::BoundRegion {
230230
var: ty::BoundVar::from_u32(counter),
231231
kind: ty::BrAnon(counter),

compiler/rustc_typeck/src/collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
393393
}
394394

395395
fn ct_infer(&self, ty: Ty<'tcx>, _: Option<&ty::GenericParamDef>, span: Span) -> Const<'tcx> {
396-
let ty = self.tcx.fold_regions(ty, &mut false, |r, _| match *r {
396+
let ty = self.tcx.fold_regions(ty, |r, _| match *r {
397397
ty::ReErased => self.tcx.lifetimes.re_static,
398398
_ => r,
399399
});
@@ -1917,7 +1917,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
19171917
Some(ty) => {
19181918
let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id];
19191919
// Typeck doesn't expect erased regions to be returned from `type_of`.
1920-
let fn_sig = tcx.fold_regions(fn_sig, &mut false, |r, _| match *r {
1920+
let fn_sig = tcx.fold_regions(fn_sig, |r, _| match *r {
19211921
ty::ReErased => tcx.lifetimes.re_static,
19221922
_ => r,
19231923
});

compiler/rustc_typeck/src/collect/type_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ fn infer_placeholder_type<'a>(
772772
}
773773

774774
// Typeck doesn't expect erased regions to be returned from `type_of`.
775-
tcx.fold_regions(ty, &mut false, |r, _| match *r {
775+
tcx.fold_regions(ty, |r, _| match *r {
776776
ty::ReErased => tcx.lifetimes.re_static,
777777
_ => r,
778778
})

0 commit comments

Comments
 (0)