Skip to content

Commit 9509348

Browse files
authored
Rollup merge of #98576 - lcnr:region-stuff-cool-beans, r=jackh726
small regions refactoring these commits should be fairly self-contained r? rust-lang/types
2 parents 4f61fe2 + 28fafc4 commit 9509348

File tree

21 files changed

+38
-59
lines changed

21 files changed

+38
-59
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(crate) struct ConstraintConversion<'a, 'tcx> {
2323
tcx: TyCtxt<'tcx>,
2424
universal_regions: &'a UniversalRegions<'tcx>,
2525
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
26-
implicit_region_bound: Option<ty::Region<'tcx>>,
26+
implicit_region_bound: ty::Region<'tcx>,
2727
param_env: ty::ParamEnv<'tcx>,
2828
locations: Locations,
2929
span: Span,
@@ -36,7 +36,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
3636
infcx: &'a InferCtxt<'a, 'tcx>,
3737
universal_regions: &'a UniversalRegions<'tcx>,
3838
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
39-
implicit_region_bound: Option<ty::Region<'tcx>>,
39+
implicit_region_bound: ty::Region<'tcx>,
4040
param_env: ty::ParamEnv<'tcx>,
4141
locations: Locations,
4242
span: Span,
@@ -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
}
@@ -120,7 +120,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
120120
&mut *self,
121121
tcx,
122122
region_bound_pairs,
123-
implicit_region_bound,
123+
Some(implicit_region_bound),
124124
param_env,
125125
)
126126
.type_must_outlive(origin, t1, r2);

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(crate) struct CreateResult<'tcx> {
6161
pub(crate) fn create<'tcx>(
6262
infcx: &InferCtxt<'_, 'tcx>,
6363
param_env: ty::ParamEnv<'tcx>,
64-
implicit_region_bound: Option<ty::Region<'tcx>>,
64+
implicit_region_bound: ty::Region<'tcx>,
6565
universal_regions: &Rc<UniversalRegions<'tcx>>,
6666
constraints: &mut MirTypeckRegionConstraints<'tcx>,
6767
) -> CreateResult<'tcx> {
@@ -223,7 +223,7 @@ struct UniversalRegionRelationsBuilder<'this, 'tcx> {
223223
infcx: &'this InferCtxt<'this, 'tcx>,
224224
param_env: ty::ParamEnv<'tcx>,
225225
universal_regions: Rc<UniversalRegions<'tcx>>,
226-
implicit_region_bound: Option<ty::Region<'tcx>>,
226+
implicit_region_bound: ty::Region<'tcx>,
227227
constraints: &'this mut MirTypeckRegionConstraints<'tcx>,
228228

229229
// outputs:

compiler/rustc_borrowck/src/type_check/input_output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
230230
self.infcx,
231231
&self.borrowck_context.universal_regions,
232232
&self.region_bound_pairs,
233-
Some(self.implicit_region_bound),
233+
self.implicit_region_bound,
234234
self.param_env,
235235
Locations::All(DUMMY_SP),
236236
DUMMY_SP,

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
157157
} = free_region_relations::create(
158158
infcx,
159159
param_env,
160-
Some(implicit_region_bound),
160+
implicit_region_bound,
161161
universal_regions,
162162
&mut constraints,
163163
);
@@ -1142,7 +1142,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
11421142
self.infcx,
11431143
self.borrowck_context.universal_regions,
11441144
self.region_bound_pairs,
1145-
Some(self.implicit_region_bound),
1145+
self.implicit_region_bound,
11461146
self.param_env,
11471147
locations,
11481148
locations.span(self.body),

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

0 commit comments

Comments
 (0)