Skip to content

Commit 349415d

Browse files
committed
Remove TypeckResults from InferCtxt
1 parent 4a68373 commit 349415d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+240
-280
lines changed

compiler/rustc_borrowck/src/constraint_generation.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use crate::{
1414
places_conflict, region_infer::values::LivenessValues,
1515
};
1616

17-
pub(super) fn generate_constraints<'cx, 'tcx>(
18-
infcx: &InferCtxt<'cx, 'tcx>,
17+
pub(super) fn generate_constraints<'tcx>(
18+
infcx: &InferCtxt<'tcx>,
1919
liveness_constraints: &mut LivenessValues<RegionVid>,
2020
all_facts: &mut Option<AllFacts>,
2121
location_table: &LocationTable,
@@ -37,16 +37,16 @@ pub(super) fn generate_constraints<'cx, 'tcx>(
3737
}
3838

3939
/// 'cg = the duration of the constraint generation process itself.
40-
struct ConstraintGeneration<'cg, 'cx, 'tcx> {
41-
infcx: &'cg InferCtxt<'cx, 'tcx>,
40+
struct ConstraintGeneration<'cg, 'tcx> {
41+
infcx: &'cg InferCtxt<'tcx>,
4242
all_facts: &'cg mut Option<AllFacts>,
4343
location_table: &'cg LocationTable,
4444
liveness_constraints: &'cg mut LivenessValues<RegionVid>,
4545
borrow_set: &'cg BorrowSet<'tcx>,
4646
body: &'cg Body<'tcx>,
4747
}
4848

49-
impl<'cg, 'cx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'tcx> {
49+
impl<'cg, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'tcx> {
5050
fn visit_basic_block_data(&mut self, bb: BasicBlock, data: &BasicBlockData<'tcx>) {
5151
self.super_basic_block_data(bb, data);
5252
}
@@ -156,7 +156,7 @@ impl<'cg, 'cx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'tcx> {
156156
}
157157
}
158158

159-
impl<'cx, 'cg, 'tcx> ConstraintGeneration<'cx, 'cg, 'tcx> {
159+
impl<'cx, 'tcx> ConstraintGeneration<'cx, 'tcx> {
160160
/// Some variable with type `live_ty` is "regular live" at
161161
/// `location` -- i.e., it may be used later. This means that all
162162
/// regions appearing in the type `live_ty` must be live at

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
407407
#[instrument(skip(fulfill_cx, infcx), level = "debug")]
408408
fn try_extract_error_from_fulfill_cx<'tcx>(
409409
mut fulfill_cx: Box<dyn TraitEngine<'tcx> + 'tcx>,
410-
infcx: &InferCtxt<'_, 'tcx>,
410+
infcx: &InferCtxt<'tcx>,
411411
placeholder_region: ty::Region<'tcx>,
412412
error_region: Option<ty::Region<'tcx>>,
413413
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
@@ -427,7 +427,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
427427
}
428428

429429
fn try_extract_error_from_region_constraints<'tcx>(
430-
infcx: &InferCtxt<'_, 'tcx>,
430+
infcx: &InferCtxt<'tcx>,
431431
placeholder_region: ty::Region<'tcx>,
432432
error_region: Option<ty::Region<'tcx>>,
433433
region_constraints: &RegionConstraintData<'tcx>,

compiler/rustc_borrowck/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ fn mir_borrowck<'tcx>(
150150
/// region ids on which the borrow checking was performed together with Polonius
151151
/// facts.
152152
#[instrument(skip(infcx, input_body, input_promoted), fields(id=?input_body.source.with_opt_param().as_local().unwrap()), level = "debug")]
153-
fn do_mir_borrowck<'a, 'tcx>(
154-
infcx: &InferCtxt<'a, 'tcx>,
153+
fn do_mir_borrowck<'tcx>(
154+
infcx: &InferCtxt<'tcx>,
155155
input_body: &Body<'tcx>,
156156
input_promoted: &IndexVec<Promoted, Body<'tcx>>,
157157
return_body_with_facts: bool,
@@ -474,7 +474,7 @@ pub struct BodyWithBorrowckFacts<'tcx> {
474474
}
475475

476476
struct MirBorrowckCtxt<'cx, 'tcx> {
477-
infcx: &'cx InferCtxt<'cx, 'tcx>,
477+
infcx: &'cx InferCtxt<'tcx>,
478478
param_env: ParamEnv<'tcx>,
479479
body: &'cx Body<'tcx>,
480480
move_data: &'cx MoveData<'tcx>,

compiler/rustc_borrowck/src/nll.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ pub(crate) struct NllOutput<'tcx> {
5555
/// regions (e.g., region parameters) declared on the function. That set will need to be given to
5656
/// `compute_regions`.
5757
#[instrument(skip(infcx, param_env, body, promoted), level = "debug")]
58-
pub(crate) fn replace_regions_in_mir<'cx, 'tcx>(
59-
infcx: &InferCtxt<'cx, 'tcx>,
58+
pub(crate) fn replace_regions_in_mir<'tcx>(
59+
infcx: &InferCtxt<'tcx>,
6060
param_env: ty::ParamEnv<'tcx>,
6161
body: &mut Body<'tcx>,
6262
promoted: &mut IndexVec<Promoted, Body<'tcx>>,
@@ -155,7 +155,7 @@ fn populate_polonius_move_facts(
155155
///
156156
/// This may result in errors being reported.
157157
pub(crate) fn compute_regions<'cx, 'tcx>(
158-
infcx: &InferCtxt<'cx, 'tcx>,
158+
infcx: &InferCtxt<'tcx>,
159159
universal_regions: UniversalRegions<'tcx>,
160160
body: &Body<'tcx>,
161161
promoted: &IndexVec<Promoted, Body<'tcx>>,
@@ -318,8 +318,8 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
318318
}
319319
}
320320

321-
pub(super) fn dump_mir_results<'a, 'tcx>(
322-
infcx: &InferCtxt<'a, 'tcx>,
321+
pub(super) fn dump_mir_results<'tcx>(
322+
infcx: &InferCtxt<'tcx>,
323323
body: &Body<'tcx>,
324324
regioncx: &RegionInferenceContext<'tcx>,
325325
closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,
@@ -368,8 +368,8 @@ pub(super) fn dump_mir_results<'a, 'tcx>(
368368
};
369369
}
370370

371-
pub(super) fn dump_annotation<'a, 'tcx>(
372-
infcx: &InferCtxt<'a, 'tcx>,
371+
pub(super) fn dump_annotation<'tcx>(
372+
infcx: &InferCtxt<'tcx>,
373373
body: &Body<'tcx>,
374374
regioncx: &RegionInferenceContext<'tcx>,
375375
closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,

compiler/rustc_borrowck/src/region_infer/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
565565
#[instrument(skip(self, infcx, body, polonius_output), level = "debug")]
566566
pub(super) fn solve(
567567
&mut self,
568-
infcx: &InferCtxt<'_, 'tcx>,
568+
infcx: &InferCtxt<'tcx>,
569569
param_env: ty::ParamEnv<'tcx>,
570570
body: &Body<'tcx>,
571571
polonius_output: Option<Rc<PoloniusOutput>>,
@@ -835,7 +835,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
835835
/// 'a`. See `TypeTest` for more details.
836836
fn check_type_tests(
837837
&self,
838-
infcx: &InferCtxt<'_, 'tcx>,
838+
infcx: &InferCtxt<'tcx>,
839839
param_env: ty::ParamEnv<'tcx>,
840840
body: &Body<'tcx>,
841841
mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
@@ -923,7 +923,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
923923
#[instrument(level = "debug", skip(self, infcx, propagated_outlives_requirements))]
924924
fn try_promote_type_test(
925925
&self,
926-
infcx: &InferCtxt<'_, 'tcx>,
926+
infcx: &InferCtxt<'tcx>,
927927
param_env: ty::ParamEnv<'tcx>,
928928
body: &Body<'tcx>,
929929
type_test: &TypeTest<'tcx>,
@@ -1036,7 +1036,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
10361036
#[instrument(level = "debug", skip(self, infcx))]
10371037
fn try_promote_type_test_subject(
10381038
&self,
1039-
infcx: &InferCtxt<'_, 'tcx>,
1039+
infcx: &InferCtxt<'tcx>,
10401040
ty: Ty<'tcx>,
10411041
) -> Option<ClosureOutlivesSubject<'tcx>> {
10421042
let tcx = infcx.tcx;
@@ -1212,7 +1212,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
12121212
/// `point`.
12131213
fn eval_verify_bound(
12141214
&self,
1215-
infcx: &InferCtxt<'_, 'tcx>,
1215+
infcx: &InferCtxt<'tcx>,
12161216
param_env: ty::ParamEnv<'tcx>,
12171217
body: &Body<'tcx>,
12181218
generic_ty: Ty<'tcx>,
@@ -1262,7 +1262,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
12621262

12631263
fn eval_if_eq(
12641264
&self,
1265-
infcx: &InferCtxt<'_, 'tcx>,
1265+
infcx: &InferCtxt<'tcx>,
12661266
param_env: ty::ParamEnv<'tcx>,
12671267
generic_ty: Ty<'tcx>,
12681268
lower_bound: RegionVid,
@@ -1718,7 +1718,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
17181718

17191719
fn check_member_constraints(
17201720
&self,
1721-
infcx: &InferCtxt<'_, 'tcx>,
1721+
infcx: &InferCtxt<'tcx>,
17221722
errors_buffer: &mut RegionErrors<'tcx>,
17231723
) {
17241724
let member_constraints = self.member_constraints.clone();

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
6363
#[instrument(level = "debug", skip(self, infcx), ret)]
6464
pub(crate) fn infer_opaque_types(
6565
&self,
66-
infcx: &InferCtxt<'_, 'tcx>,
66+
infcx: &InferCtxt<'tcx>,
6767
opaque_ty_decls: VecMap<OpaqueTypeKey<'tcx>, (OpaqueHiddenType<'tcx>, OpaqueTyOrigin)>,
6868
) -> VecMap<LocalDefId, OpaqueHiddenType<'tcx>> {
6969
let mut result: VecMap<LocalDefId, OpaqueHiddenType<'tcx>> = VecMap::new();
@@ -194,7 +194,7 @@ pub trait InferCtxtExt<'tcx> {
194194
) -> Ty<'tcx>;
195195
}
196196

197-
impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
197+
impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
198198
/// Given the fully resolved, instantiated type for an opaque
199199
/// type, i.e., the value of an inference variable like C1 or C2
200200
/// (*), computes the "definition type" for an opaque type

compiler/rustc_borrowck/src/renumber.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
1010
/// inference variables, returning the number of variables created.
1111
#[instrument(skip(infcx, body, promoted), level = "debug")]
1212
pub fn renumber_mir<'tcx>(
13-
infcx: &InferCtxt<'_, 'tcx>,
13+
infcx: &InferCtxt<'tcx>,
1414
body: &mut Body<'tcx>,
1515
promoted: &mut IndexVec<Promoted, Body<'tcx>>,
1616
) {
@@ -28,7 +28,7 @@ pub fn renumber_mir<'tcx>(
2828
/// Replaces all regions appearing in `value` with fresh inference
2929
/// variables.
3030
#[instrument(skip(infcx), level = "debug")]
31-
pub fn renumber_regions<'tcx, T>(infcx: &InferCtxt<'_, 'tcx>, value: T) -> T
31+
pub fn renumber_regions<'tcx, T>(infcx: &InferCtxt<'tcx>, value: T) -> T
3232
where
3333
T: TypeFoldable<'tcx>,
3434
{
@@ -44,7 +44,7 @@ where
4444
// Once `visit_mir_constant` is removed we can also remove this function
4545
// and just use `renumber_regions`.
4646
fn renumber_regions_in_mir_constant<'tcx>(
47-
infcx: &InferCtxt<'_, 'tcx>,
47+
infcx: &InferCtxt<'tcx>,
4848
value: ConstantKind<'tcx>,
4949
) -> ConstantKind<'tcx> {
5050
infcx.tcx.super_fold_regions(value, |_region, _depth| {
@@ -54,7 +54,7 @@ fn renumber_regions_in_mir_constant<'tcx>(
5454
}
5555

5656
struct NllVisitor<'a, 'tcx> {
57-
infcx: &'a InferCtxt<'a, 'tcx>,
57+
infcx: &'a InferCtxt<'tcx>,
5858
}
5959

6060
impl<'a, 'tcx> NllVisitor<'a, 'tcx> {

compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
};
2020

2121
pub(crate) struct ConstraintConversion<'a, 'tcx> {
22-
infcx: &'a InferCtxt<'a, 'tcx>,
22+
infcx: &'a InferCtxt<'tcx>,
2323
tcx: TyCtxt<'tcx>,
2424
universal_regions: &'a UniversalRegions<'tcx>,
2525
/// Each RBP `GK: 'a` is assumed to be true. These encode
@@ -43,7 +43,7 @@ pub(crate) struct ConstraintConversion<'a, 'tcx> {
4343

4444
impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
4545
pub(crate) fn new(
46-
infcx: &'a InferCtxt<'a, 'tcx>,
46+
infcx: &'a InferCtxt<'tcx>,
4747
universal_regions: &'a UniversalRegions<'tcx>,
4848
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
4949
implicit_region_bound: ty::Region<'tcx>,

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub(crate) struct CreateResult<'tcx> {
4848
}
4949

5050
pub(crate) fn create<'tcx>(
51-
infcx: &InferCtxt<'_, 'tcx>,
51+
infcx: &InferCtxt<'tcx>,
5252
param_env: ty::ParamEnv<'tcx>,
5353
implicit_region_bound: ty::Region<'tcx>,
5454
universal_regions: &Rc<UniversalRegions<'tcx>>,
@@ -197,7 +197,7 @@ impl UniversalRegionRelations<'_> {
197197
}
198198

199199
struct UniversalRegionRelationsBuilder<'this, 'tcx> {
200-
infcx: &'this InferCtxt<'this, 'tcx>,
200+
infcx: &'this InferCtxt<'tcx>,
201201
param_env: ty::ParamEnv<'tcx>,
202202
universal_regions: Rc<UniversalRegions<'tcx>>,
203203
implicit_region_bound: ty::Region<'tcx>,

compiler/rustc_borrowck/src/type_check/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ mod relate_tys;
123123
/// - `move_data` -- move-data constructed when performing the maybe-init dataflow analysis
124124
/// - `elements` -- MIR region map
125125
pub(crate) fn type_check<'mir, 'tcx>(
126-
infcx: &InferCtxt<'_, 'tcx>,
126+
infcx: &InferCtxt<'tcx>,
127127
param_env: ty::ParamEnv<'tcx>,
128128
body: &Body<'tcx>,
129129
promoted: &IndexVec<Promoted, Body<'tcx>>,
@@ -876,7 +876,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
876876
/// way, it accrues region constraints -- these can later be used by
877877
/// NLL region checking.
878878
struct TypeChecker<'a, 'tcx> {
879-
infcx: &'a InferCtxt<'a, 'tcx>,
879+
infcx: &'a InferCtxt<'tcx>,
880880
param_env: ty::ParamEnv<'tcx>,
881881
last_span: Span,
882882
body: &'a Body<'tcx>,
@@ -946,7 +946,7 @@ pub(crate) struct MirTypeckRegionConstraints<'tcx> {
946946
impl<'tcx> MirTypeckRegionConstraints<'tcx> {
947947
fn placeholder_region(
948948
&mut self,
949-
infcx: &InferCtxt<'_, 'tcx>,
949+
infcx: &InferCtxt<'tcx>,
950950
placeholder: ty::PlaceholderRegion,
951951
) -> ty::Region<'tcx> {
952952
let placeholder_index = self.placeholder_indices.insert(placeholder);
@@ -1030,7 +1030,7 @@ impl Locations {
10301030

10311031
impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
10321032
fn new(
1033-
infcx: &'a InferCtxt<'a, 'tcx>,
1033+
infcx: &'a InferCtxt<'tcx>,
10341034
body: &'a Body<'tcx>,
10351035
param_env: ty::ParamEnv<'tcx>,
10361036
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
@@ -2744,7 +2744,7 @@ impl<'tcx> TypeOp<'tcx> for InstantiateOpaqueType<'tcx> {
27442744
/// constraints in our `InferCtxt`
27452745
type ErrorInfo = InstantiateOpaqueType<'tcx>;
27462746

2747-
fn fully_perform(mut self, infcx: &InferCtxt<'_, 'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
2747+
fn fully_perform(mut self, infcx: &InferCtxt<'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
27482748
let (mut output, region_constraints) = scrape_region_constraints(infcx, || {
27492749
Ok(InferOk { value: (), obligations: self.obligations.clone() })
27502750
})?;

compiler/rustc_borrowck/src/universal_regions.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl<'tcx> UniversalRegions<'tcx> {
219219
/// signature. This will also compute the relationships that are
220220
/// known between those regions.
221221
pub fn new(
222-
infcx: &InferCtxt<'_, 'tcx>,
222+
infcx: &InferCtxt<'tcx>,
223223
mir_def: ty::WithOptConstParam<LocalDefId>,
224224
param_env: ty::ParamEnv<'tcx>,
225225
) -> Self {
@@ -382,7 +382,7 @@ impl<'tcx> UniversalRegions<'tcx> {
382382
}
383383

384384
struct UniversalRegionsBuilder<'cx, 'tcx> {
385-
infcx: &'cx InferCtxt<'cx, 'tcx>,
385+
infcx: &'cx InferCtxt<'tcx>,
386386
mir_def: ty::WithOptConstParam<LocalDefId>,
387387
mir_hir_id: HirId,
388388
param_env: ty::ParamEnv<'tcx>,
@@ -699,7 +699,7 @@ trait InferCtxtExt<'tcx> {
699699
);
700700
}
701701

702-
impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
702+
impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
703703
fn replace_free_regions_with_nll_infer_vars<T>(
704704
&self,
705705
origin: NllRegionVariableOrigin,

compiler/rustc_hir_analysis/src/check/compare_method.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,8 @@ fn check_region_bounds_on_impl_item<'tcx>(
712712
}
713713

714714
#[instrument(level = "debug", skip(infcx))]
715-
fn extract_spans_for_error_reporting<'a, 'tcx>(
716-
infcx: &infer::InferCtxt<'a, 'tcx>,
715+
fn extract_spans_for_error_reporting<'tcx>(
716+
infcx: &infer::InferCtxt<'tcx>,
717717
terr: TypeError<'_>,
718718
cause: &ObligationCause<'tcx>,
719719
impl_m: &ty::AssocItem,

0 commit comments

Comments
 (0)