Skip to content

Commit 8303383

Browse files
committed
remove redundant fields
1 parent c5fdddc commit 8303383

File tree

4 files changed

+13
-28
lines changed

4 files changed

+13
-28
lines changed

Diff for: compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use crate::{ClosureOutlivesSubject, ClosureRegionRequirements, ConstraintCategor
2121

2222
pub(crate) struct ConstraintConversion<'a, 'tcx> {
2323
infcx: &'a InferCtxt<'tcx>,
24-
tcx: TyCtxt<'tcx>,
2524
universal_regions: &'a UniversalRegions<'tcx>,
2625
/// Each RBP `GK: 'a` is assumed to be true. These encode
2726
/// relationships like `T: 'a` that are added via implicit bounds
@@ -34,7 +33,6 @@ pub(crate) struct ConstraintConversion<'a, 'tcx> {
3433
/// logic expecting to see (e.g.) `ReStatic`, and if we supplied
3534
/// our special inference variable there, we would mess that up.
3635
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
37-
implicit_region_bound: ty::Region<'tcx>,
3836
param_env: ty::ParamEnv<'tcx>,
3937
known_type_outlives_obligations: &'a [ty::PolyTypeOutlivesPredicate<'tcx>],
4038
locations: Locations,
@@ -49,7 +47,6 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
4947
infcx: &'a InferCtxt<'tcx>,
5048
universal_regions: &'a UniversalRegions<'tcx>,
5149
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
52-
implicit_region_bound: ty::Region<'tcx>,
5350
param_env: ty::ParamEnv<'tcx>,
5451
known_type_outlives_obligations: &'a [ty::PolyTypeOutlivesPredicate<'tcx>],
5552
locations: Locations,
@@ -59,10 +56,8 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
5956
) -> Self {
6057
Self {
6158
infcx,
62-
tcx: infcx.tcx,
6359
universal_regions,
6460
region_bound_pairs,
65-
implicit_region_bound,
6661
param_env,
6762
known_type_outlives_obligations,
6863
locations,
@@ -96,7 +91,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
9691
// into a vector. These are the regions that we will be
9792
// relating to one another.
9893
let closure_mapping = &UniversalRegions::closure_mapping(
99-
self.tcx,
94+
self.infcx.tcx,
10095
closure_args,
10196
closure_requirements.num_external_vids,
10297
closure_def_id,
@@ -111,7 +106,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
111106
let subject = match outlives_requirement.subject {
112107
ClosureOutlivesSubject::Region(re) => closure_mapping[re].into(),
113108
ClosureOutlivesSubject::Ty(subject_ty) => {
114-
subject_ty.instantiate(self.tcx, |vid| closure_mapping[vid]).into()
109+
subject_ty.instantiate(self.infcx.tcx, |vid| closure_mapping[vid]).into()
115110
}
116111
};
117112

@@ -127,14 +122,14 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
127122
predicate: ty::OutlivesPredicate<'tcx, ty::GenericArg<'tcx>>,
128123
constraint_category: ConstraintCategory<'tcx>,
129124
) {
125+
let tcx = self.infcx.tcx;
130126
debug!("generate: constraints at: {:#?}", self.locations);
131127

132128
// Extract out various useful fields we'll need below.
133129
let ConstraintConversion {
134-
tcx,
135130
infcx,
131+
universal_regions,
136132
region_bound_pairs,
137-
implicit_region_bound,
138133
known_type_outlives_obligations,
139134
..
140135
} = *self;
@@ -145,7 +140,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
145140
break;
146141
}
147142

148-
if !self.tcx.recursion_limit().value_within_limit(iteration) {
143+
if !tcx.recursion_limit().value_within_limit(iteration) {
149144
bug!(
150145
"FIXME(-Znext-solver): Overflowed when processing region obligations: {outlives_predicates:#?}"
151146
);
@@ -170,10 +165,11 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
170165
);
171166
}
172167

168+
let implicit_region_bound =
169+
ty::Region::new_var(tcx, universal_regions.implicit_region_bound());
173170
// we don't actually use this for anything, but
174171
// the `TypeOutlives` code needs an origin.
175172
let origin = infer::RelateParamBound(self.span, t1, None);
176-
177173
TypeOutlives::new(
178174
&mut *self,
179175
tcx,
@@ -205,7 +201,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
205201
/// are dealt with during trait solving.
206202
fn replace_placeholders_with_nll<T: TypeFoldable<TyCtxt<'tcx>>>(&mut self, value: T) -> T {
207203
if value.has_placeholders() {
208-
fold_regions(self.tcx, value, |r, _| match r.kind() {
204+
fold_regions(self.infcx.tcx, value, |r, _| match r.kind() {
209205
ty::RePlaceholder(placeholder) => {
210206
self.constraints.placeholder_region(self.infcx, placeholder)
211207
}

Diff for: compiler/rustc_borrowck/src/type_check/free_region_relations.rs

-4
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@ pub(crate) struct CreateResult<'tcx> {
4949
pub(crate) fn create<'tcx>(
5050
infcx: &InferCtxt<'tcx>,
5151
param_env: ty::ParamEnv<'tcx>,
52-
implicit_region_bound: ty::Region<'tcx>,
5352
universal_regions: UniversalRegions<'tcx>,
5453
constraints: &mut MirTypeckRegionConstraints<'tcx>,
5554
) -> CreateResult<'tcx> {
5655
UniversalRegionRelationsBuilder {
5756
infcx,
5857
param_env,
59-
implicit_region_bound,
6058
constraints,
6159
universal_regions,
6260
region_bound_pairs: Default::default(),
@@ -181,7 +179,6 @@ struct UniversalRegionRelationsBuilder<'a, 'tcx> {
181179
infcx: &'a InferCtxt<'tcx>,
182180
param_env: ty::ParamEnv<'tcx>,
183181
universal_regions: UniversalRegions<'tcx>,
184-
implicit_region_bound: ty::Region<'tcx>,
185182
constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
186183

187184
// outputs:
@@ -320,7 +317,6 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
320317
self.infcx,
321318
&self.universal_regions,
322319
&self.region_bound_pairs,
323-
self.implicit_region_bound,
324320
param_env,
325321
&known_type_outlives_obligations,
326322
Locations::All(span),

Diff for: compiler/rustc_borrowck/src/type_check/mod.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ pub(crate) fn type_check<'a, 'tcx>(
113113
move_data: &MoveData<'tcx>,
114114
location_map: Rc<DenseLocationMap>,
115115
) -> MirTypeckResults<'tcx> {
116-
let implicit_region_bound = ty::Region::new_var(infcx.tcx, universal_regions.fr_fn_body);
117116
let mut constraints = MirTypeckRegionConstraints {
118117
placeholder_indices: PlaceholderIndices::default(),
119118
placeholder_index_to_region: IndexVec::default(),
@@ -129,13 +128,7 @@ pub(crate) fn type_check<'a, 'tcx>(
129128
region_bound_pairs,
130129
normalized_inputs_and_output,
131130
known_type_outlives_obligations,
132-
} = free_region_relations::create(
133-
infcx,
134-
infcx.param_env,
135-
implicit_region_bound,
136-
universal_regions,
137-
&mut constraints,
138-
);
131+
} = free_region_relations::create(infcx, infcx.param_env, universal_regions, &mut constraints);
139132

140133
let pre_obligations = infcx.take_registered_region_obligations();
141134
assert!(
@@ -160,7 +153,6 @@ pub(crate) fn type_check<'a, 'tcx>(
160153
user_type_annotations: &body.user_type_annotations,
161154
region_bound_pairs,
162155
known_type_outlives_obligations,
163-
implicit_region_bound,
164156
reported_errors: Default::default(),
165157
universal_regions: &universal_region_relations.universal_regions,
166158
location_table,
@@ -226,7 +218,6 @@ struct TypeChecker<'a, 'tcx> {
226218
user_type_annotations: &'a CanonicalUserTypeAnnotations<'tcx>,
227219
region_bound_pairs: RegionBoundPairs<'tcx>,
228220
known_type_outlives_obligations: Vec<ty::PolyTypeOutlivesPredicate<'tcx>>,
229-
implicit_region_bound: ty::Region<'tcx>,
230221
reported_errors: FxIndexSet<(Ty<'tcx>, Span)>,
231222
universal_regions: &'a UniversalRegions<'tcx>,
232223
location_table: &'a PoloniusLocationTable,
@@ -422,7 +413,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
422413
self.infcx,
423414
self.universal_regions,
424415
&self.region_bound_pairs,
425-
self.implicit_region_bound,
426416
self.infcx.param_env,
427417
&self.known_type_outlives_obligations,
428418
locations,
@@ -2507,7 +2497,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25072497
self.infcx,
25082498
self.universal_regions,
25092499
&self.region_bound_pairs,
2510-
self.implicit_region_bound,
25112500
self.infcx.param_env,
25122501
&self.known_type_outlives_obligations,
25132502
locations,

Diff for: compiler/rustc_borrowck/src/universal_regions.rs

+4
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,10 @@ impl<'tcx> UniversalRegions<'tcx> {
438438
}
439439
}
440440

441+
pub(crate) fn implicit_region_bound(&self) -> RegionVid {
442+
self.fr_fn_body
443+
}
444+
441445
pub(crate) fn tainted_by_errors(&self) -> Option<ErrorGuaranteed> {
442446
self.indices.tainted_by_errors.get()
443447
}

0 commit comments

Comments
 (0)