Skip to content

Commit a58a717

Browse files
committed
Make TypeChecker::known_type_outlives_obligations owned.
This avoids the need to arena allocate it. `ConstraintConversion` needs some simple lifetime adjustments to allow this.
1 parent 412a3ca commit a58a717

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub(crate) struct ConstraintConversion<'a, 'tcx> {
3737
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
3838
implicit_region_bound: ty::Region<'tcx>,
3939
param_env: ty::ParamEnv<'tcx>,
40-
known_type_outlives_obligations: &'tcx [ty::PolyTypeOutlivesPredicate<'tcx>],
40+
known_type_outlives_obligations: &'a [ty::PolyTypeOutlivesPredicate<'tcx>],
4141
locations: Locations,
4242
span: Span,
4343
category: ConstraintCategory<'tcx>,
@@ -52,7 +52,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
5252
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
5353
implicit_region_bound: ty::Region<'tcx>,
5454
param_env: ty::ParamEnv<'tcx>,
55-
known_type_outlives_obligations: &'tcx [ty::PolyTypeOutlivesPredicate<'tcx>],
55+
known_type_outlives_obligations: &'a [ty::PolyTypeOutlivesPredicate<'tcx>],
5656
locations: Locations,
5757
span: Span,
5858
category: ConstraintCategory<'tcx>,

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type NormalizedInputsAndOutput<'tcx> = Vec<Ty<'tcx>>;
4646
pub(crate) struct CreateResult<'tcx> {
4747
pub(crate) universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
4848
pub(crate) region_bound_pairs: RegionBoundPairs<'tcx>,
49-
pub(crate) known_type_outlives_obligations: &'tcx [ty::PolyTypeOutlivesPredicate<'tcx>],
49+
pub(crate) known_type_outlives_obligations: Vec<ty::PolyTypeOutlivesPredicate<'tcx>>,
5050
pub(crate) normalized_inputs_and_output: NormalizedInputsAndOutput<'tcx>,
5151
}
5252

@@ -250,8 +250,6 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
250250

251251
known_type_outlives_obligations.push(outlives);
252252
}
253-
let known_type_outlives_obligations =
254-
self.infcx.tcx.arena.alloc_slice(&known_type_outlives_obligations);
255253

256254
let unnormalized_input_output_tys = self
257255
.universal_regions
@@ -340,7 +338,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
340338
&self.region_bound_pairs,
341339
self.implicit_region_bound,
342340
param_env,
343-
known_type_outlives_obligations,
341+
&known_type_outlives_obligations,
344342
Locations::All(span),
345343
span,
346344
ConstraintCategory::Internal,

compiler/rustc_borrowck/src/type_check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ struct TypeChecker<'a, 'tcx> {
844844
/// all of the promoted items.
845845
user_type_annotations: &'a CanonicalUserTypeAnnotations<'tcx>,
846846
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
847-
known_type_outlives_obligations: &'tcx [ty::PolyTypeOutlivesPredicate<'tcx>],
847+
known_type_outlives_obligations: Vec<ty::PolyTypeOutlivesPredicate<'tcx>>,
848848
implicit_region_bound: ty::Region<'tcx>,
849849
reported_errors: FxIndexSet<(Ty<'tcx>, Span)>,
850850
universal_regions: &'a UniversalRegions<'tcx>,
@@ -1028,7 +1028,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
10281028
self.region_bound_pairs,
10291029
self.implicit_region_bound,
10301030
self.param_env,
1031-
self.known_type_outlives_obligations,
1031+
&self.known_type_outlives_obligations,
10321032
locations,
10331033
locations.span(self.body),
10341034
category,
@@ -2788,7 +2788,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
27882788
self.region_bound_pairs,
27892789
self.implicit_region_bound,
27902790
self.param_env,
2791-
self.known_type_outlives_obligations,
2791+
&self.known_type_outlives_obligations,
27922792
locations,
27932793
self.body.span, // irrelevant; will be overridden.
27942794
ConstraintCategory::Boring, // same as above.

0 commit comments

Comments
 (0)