Skip to content

Commit c1b336c

Browse files
committed
Auto merge of #126650 - compiler-errors:renames, r=lcnr
Rename a bunch of things in the new solver and `rustc_type_ir` * Renames `interner()` to `cx()` in the solver and `TypeFolder`. * Renames `Infcx` generic param to `D` * Moves `infcx.rs` to `delegate.rs` r? lcnr
2 parents 5ced3da + db638ab commit c1b336c

File tree

60 files changed

+538
-566
lines changed

Some content is hidden

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

60 files changed

+538
-566
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
11101110
tcx: TyCtxt<'tcx>,
11111111
}
11121112
impl<'tcx> ty::TypeFolder<TyCtxt<'tcx>> for OpaqueFolder<'tcx> {
1113-
fn interner(&self) -> TyCtxt<'tcx> {
1113+
fn cx(&self) -> TyCtxt<'tcx> {
11141114
self.tcx
11151115
}
11161116
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ struct RemapLateBound<'a, 'tcx> {
397397
}
398398

399399
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, 'tcx> {
400-
fn interner(&self) -> TyCtxt<'tcx> {
400+
fn cx(&self) -> TyCtxt<'tcx> {
401401
self.tcx
402402
}
403403

@@ -790,13 +790,13 @@ impl<'tcx, E> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx, E
790790
where
791791
E: 'tcx,
792792
{
793-
fn interner(&self) -> TyCtxt<'tcx> {
793+
fn cx(&self) -> TyCtxt<'tcx> {
794794
self.ocx.infcx.tcx
795795
}
796796

797797
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
798798
if let ty::Alias(ty::Projection, proj) = ty.kind()
799-
&& self.interner().is_impl_trait_in_trait(proj.def_id)
799+
&& self.cx().is_impl_trait_in_trait(proj.def_id)
800800
{
801801
if let Some((ty, _)) = self.types.get(&proj.def_id) {
802802
return *ty;
@@ -810,9 +810,9 @@ where
810810
self.types.insert(proj.def_id, (infer_ty, proj.args));
811811
// Recurse into bounds
812812
for (pred, pred_span) in self
813-
.interner()
813+
.cx()
814814
.explicit_item_bounds(proj.def_id)
815-
.iter_instantiated_copied(self.interner(), proj.args)
815+
.iter_instantiated_copied(self.cx(), proj.args)
816816
{
817817
let pred = pred.fold_with(self);
818818
let pred = self.ocx.normalize(
@@ -822,7 +822,7 @@ where
822822
);
823823

824824
self.ocx.register_obligation(traits::Obligation::new(
825-
self.interner(),
825+
self.cx(),
826826
ObligationCause::new(
827827
self.span,
828828
self.body_id,
@@ -853,7 +853,7 @@ struct RemapHiddenTyRegions<'tcx> {
853853
impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
854854
type Error = ErrorGuaranteed;
855855

856-
fn interner(&self) -> TyCtxt<'tcx> {
856+
fn cx(&self) -> TyCtxt<'tcx> {
857857
self.tcx
858858
}
859859

@@ -2072,7 +2072,7 @@ struct ReplaceTy<'tcx> {
20722072
}
20732073

20742074
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceTy<'tcx> {
2075-
fn interner(&self) -> TyCtxt<'tcx> {
2075+
fn cx(&self) -> TyCtxt<'tcx> {
20762076
self.tcx
20772077
}
20782078

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ struct Anonymize<'tcx> {
322322
}
323323

324324
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Anonymize<'tcx> {
325-
fn interner(&self) -> TyCtxt<'tcx> {
325+
fn cx(&self) -> TyCtxt<'tcx> {
326326
self.tcx
327327
}
328328

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ struct TyVarReplacer<'cx, 'tcx> {
539539
}
540540

541541
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for TyVarReplacer<'cx, 'tcx> {
542-
fn interner(&self) -> TyCtxt<'tcx> {
542+
fn cx(&self) -> TyCtxt<'tcx> {
543543
self.infcx.tcx
544544
}
545545

compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ struct AssocTyToOpaque<'tcx> {
203203
}
204204

205205
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTyToOpaque<'tcx> {
206-
fn interner(&self) -> TyCtxt<'tcx> {
206+
fn cx(&self) -> TyCtxt<'tcx> {
207207
self.tcx
208208
}
209209

compiler/rustc_hir_typeck/src/writeback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
847847
}
848848

849849
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
850-
fn interner(&self) -> TyCtxt<'tcx> {
850+
fn cx(&self) -> TyCtxt<'tcx> {
851851
self.fcx.tcx
852852
}
853853

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ struct Canonicalizer<'cx, 'tcx> {
304304
}
305305

306306
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
307-
fn interner(&self) -> TyCtxt<'tcx> {
307+
fn cx(&self) -> TyCtxt<'tcx> {
308308
self.tcx
309309
}
310310

@@ -773,7 +773,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
773773
) -> ty::Region<'tcx> {
774774
let var = self.canonical_var(info, r.into());
775775
let br = ty::BoundRegion { var, kind: ty::BrAnon };
776-
ty::Region::new_bound(self.interner(), self.binder_index, br)
776+
ty::Region::new_bound(self.cx(), self.binder_index, br)
777777
}
778778

779779
/// Given a type variable `ty_var` of the given kind, first check

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ struct ClosureEraser<'tcx> {
158158
}
159159

160160
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ClosureEraser<'tcx> {
161-
fn interner(&self) -> TyCtxt<'tcx> {
161+
fn cx(&self) -> TyCtxt<'tcx> {
162162
self.tcx
163163
}
164164

compiler/rustc_infer/src/infer/freshen.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
101101
}
102102

103103
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
104-
fn interner(&self) -> TyCtxt<'tcx> {
104+
fn cx(&self) -> TyCtxt<'tcx> {
105105
self.infcx.tcx
106106
}
107107

@@ -118,7 +118,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
118118
| ty::RePlaceholder(..)
119119
| ty::ReStatic
120120
| ty::ReError(_)
121-
| ty::ReErased => self.interner().lifetimes.re_erased,
121+
| ty::ReErased => self.cx().lifetimes.re_erased,
122122
}
123123
}
124124

compiler/rustc_infer/src/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ struct InferenceLiteralEraser<'tcx> {
17191719
}
17201720

17211721
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceLiteralEraser<'tcx> {
1722-
fn interner(&self) -> TyCtxt<'tcx> {
1722+
fn cx(&self) -> TyCtxt<'tcx> {
17231723
self.tcx
17241724
}
17251725

@@ -1859,7 +1859,7 @@ fn replace_param_and_infer_args_with_placeholder<'tcx>(
18591859
}
18601860

18611861
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceParamAndInferWithPlaceholder<'tcx> {
1862-
fn interner(&self) -> TyCtxt<'tcx> {
1862+
fn cx(&self) -> TyCtxt<'tcx> {
18631863
self.tcx
18641864
}
18651865

compiler/rustc_infer/src/infer/resolve.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> {
2424
}
2525

2626
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticVarResolver<'a, 'tcx> {
27-
fn interner(&self) -> TyCtxt<'tcx> {
27+
fn cx(&self) -> TyCtxt<'tcx> {
2828
self.infcx.tcx
2929
}
3030

@@ -66,7 +66,7 @@ impl<'a, 'tcx> OpportunisticRegionResolver<'a, 'tcx> {
6666
}
6767

6868
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx> {
69-
fn interner(&self) -> TyCtxt<'tcx> {
69+
fn cx(&self) -> TyCtxt<'tcx> {
7070
self.infcx.tcx
7171
}
7272

@@ -85,7 +85,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx
8585
.inner
8686
.borrow_mut()
8787
.unwrap_region_constraints()
88-
.opportunistic_resolve_var(TypeFolder::interner(self), vid),
88+
.opportunistic_resolve_var(TypeFolder::cx(self), vid),
8989
_ => r,
9090
}
9191
}
@@ -121,7 +121,7 @@ struct FullTypeResolver<'a, 'tcx> {
121121
impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
122122
type Error = FixupError;
123123

124-
fn interner(&self) -> TyCtxt<'tcx> {
124+
fn cx(&self) -> TyCtxt<'tcx> {
125125
self.infcx.tcx
126126
}
127127

compiler/rustc_infer/src/infer/snapshot/fudge.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub struct InferenceFudger<'a, 'tcx> {
183183
}
184184

185185
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceFudger<'a, 'tcx> {
186-
fn interner(&self) -> TyCtxt<'tcx> {
186+
fn cx(&self) -> TyCtxt<'tcx> {
187187
self.infcx.tcx
188188
}
189189

compiler/rustc_lint/src/non_local_def.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ struct ReplaceLocalTypesWithInfer<'a, 'tcx, F: FnMut(DefId) -> bool> {
390390
impl<'a, 'tcx, F: FnMut(DefId) -> bool> TypeFolder<TyCtxt<'tcx>>
391391
for ReplaceLocalTypesWithInfer<'a, 'tcx, F>
392392
{
393-
fn interner(&self) -> TyCtxt<'tcx> {
393+
fn cx(&self) -> TyCtxt<'tcx> {
394394
self.infcx.tcx
395395
}
396396

compiler/rustc_middle/src/traits/solve.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
5353
self,
5454
folder: &mut F,
5555
) -> Result<Self, F::Error> {
56-
Ok(FallibleTypeFolder::interner(folder).mk_external_constraints(ExternalConstraintsData {
56+
Ok(FallibleTypeFolder::cx(folder).mk_external_constraints(ExternalConstraintsData {
5757
region_constraints: self.region_constraints.clone().try_fold_with(folder)?,
5858
opaque_types: self
5959
.opaque_types
@@ -68,7 +68,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
6868
}
6969

7070
fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
71-
TypeFolder::interner(folder).mk_external_constraints(ExternalConstraintsData {
71+
TypeFolder::cx(folder).mk_external_constraints(ExternalConstraintsData {
7272
region_constraints: self.region_constraints.clone().fold_with(folder),
7373
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
7474
normalization_nested_goals: self.normalization_nested_goals.clone().fold_with(folder),
@@ -94,19 +94,17 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for PredefinedOpaques<'tcx> {
9494
self,
9595
folder: &mut F,
9696
) -> Result<Self, F::Error> {
97-
Ok(FallibleTypeFolder::interner(folder).mk_predefined_opaques_in_body(
98-
PredefinedOpaquesData {
99-
opaque_types: self
100-
.opaque_types
101-
.iter()
102-
.map(|opaque| opaque.try_fold_with(folder))
103-
.collect::<Result<_, F::Error>>()?,
104-
},
105-
))
97+
Ok(FallibleTypeFolder::cx(folder).mk_predefined_opaques_in_body(PredefinedOpaquesData {
98+
opaque_types: self
99+
.opaque_types
100+
.iter()
101+
.map(|opaque| opaque.try_fold_with(folder))
102+
.collect::<Result<_, F::Error>>()?,
103+
}))
106104
}
107105

108106
fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
109-
TypeFolder::interner(folder).mk_predefined_opaques_in_body(PredefinedOpaquesData {
107+
TypeFolder::cx(folder).mk_predefined_opaques_in_body(PredefinedOpaquesData {
110108
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
111109
})
112110
}

compiler/rustc_middle/src/ty/abstract_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'tcx> TyCtxt<'tcx> {
4141
}
4242

4343
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Expander<'tcx> {
44-
fn interner(&self) -> TyCtxt<'tcx> {
44+
fn cx(&self) -> TyCtxt<'tcx> {
4545
self.tcx
4646
}
4747
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {

compiler/rustc_middle/src/ty/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ pub struct MakeSuggestableFolder<'tcx> {
579579
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> {
580580
type Error = ();
581581

582-
fn interner(&self) -> TyCtxt<'tcx> {
582+
fn cx(&self) -> TyCtxt<'tcx> {
583583
self.tcx
584584
}
585585

compiler/rustc_middle/src/ty/erase_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct RegionEraserVisitor<'tcx> {
3737
}
3838

3939
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RegionEraserVisitor<'tcx> {
40-
fn interner(&self) -> TyCtxt<'tcx> {
40+
fn cx(&self) -> TyCtxt<'tcx> {
4141
self.tcx
4242
}
4343

compiler/rustc_middle/src/ty/fold.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ where
2828
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
2929
H: FnMut(ty::Const<'tcx>) -> ty::Const<'tcx>,
3030
{
31-
fn interner(&self) -> TyCtxt<'tcx> {
31+
fn cx(&self) -> TyCtxt<'tcx> {
3232
self.tcx
3333
}
3434

@@ -99,7 +99,7 @@ impl<'a, 'tcx> RegionFolder<'a, 'tcx> {
9999
}
100100

101101
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
102-
fn interner(&self) -> TyCtxt<'tcx> {
102+
fn cx(&self) -> TyCtxt<'tcx> {
103103
self.tcx
104104
}
105105

@@ -176,7 +176,7 @@ impl<'tcx, D> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'tcx, D>
176176
where
177177
D: BoundVarReplacerDelegate<'tcx>,
178178
{
179-
fn interner(&self) -> TyCtxt<'tcx> {
179+
fn cx(&self) -> TyCtxt<'tcx> {
180180
self.tcx
181181
}
182182

compiler/rustc_middle/src/ty/generic_args.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -591,15 +591,15 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArgsRef<'tcx> {
591591
match self.len() {
592592
1 => {
593593
let param0 = self[0].try_fold_with(folder)?;
594-
if param0 == self[0] { Ok(self) } else { Ok(folder.interner().mk_args(&[param0])) }
594+
if param0 == self[0] { Ok(self) } else { Ok(folder.cx().mk_args(&[param0])) }
595595
}
596596
2 => {
597597
let param0 = self[0].try_fold_with(folder)?;
598598
let param1 = self[1].try_fold_with(folder)?;
599599
if param0 == self[0] && param1 == self[1] {
600600
Ok(self)
601601
} else {
602-
Ok(folder.interner().mk_args(&[param0, param1]))
602+
Ok(folder.cx().mk_args(&[param0, param1]))
603603
}
604604
}
605605
0 => Ok(self),
@@ -635,7 +635,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<Ty<'tcx>> {
635635
if param0 == self[0] && param1 == self[1] {
636636
Ok(self)
637637
} else {
638-
Ok(folder.interner().mk_type_list(&[param0, param1]))
638+
Ok(folder.cx().mk_type_list(&[param0, param1]))
639639
}
640640
}
641641
_ => ty::util::fold_list(self, folder, |tcx, v| tcx.mk_type_list(v)),

compiler/rustc_middle/src/ty/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ fn polymorphize<'tcx>(
873873
}
874874

875875
impl<'tcx> ty::TypeFolder<TyCtxt<'tcx>> for PolymorphizationFolder<'tcx> {
876-
fn interner(&self) -> TyCtxt<'tcx> {
876+
fn cx(&self) -> TyCtxt<'tcx> {
877877
self.tcx
878878
}
879879

compiler/rustc_middle/src/ty/normalize_erasing_regions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<'tcx> NormalizeAfterErasingRegionsFolder<'tcx> {
173173
}
174174

175175
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for NormalizeAfterErasingRegionsFolder<'tcx> {
176-
fn interner(&self) -> TyCtxt<'tcx> {
176+
fn cx(&self) -> TyCtxt<'tcx> {
177177
self.tcx
178178
}
179179

@@ -211,7 +211,7 @@ impl<'tcx> TryNormalizeAfterErasingRegionsFolder<'tcx> {
211211
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for TryNormalizeAfterErasingRegionsFolder<'tcx> {
212212
type Error = NormalizationError<'tcx>;
213213

214-
fn interner(&self) -> TyCtxt<'tcx> {
214+
fn cx(&self) -> TyCtxt<'tcx> {
215215
self.tcx
216216
}
217217

compiler/rustc_middle/src/ty/opaque_types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<'tcx> ReverseMapper<'tcx> {
9595
}
9696

9797
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
98-
fn interner(&self) -> TyCtxt<'tcx> {
98+
fn cx(&self) -> TyCtxt<'tcx> {
9999
self.tcx
100100
}
101101

@@ -144,7 +144,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
144144
)
145145
.emit();
146146

147-
ty::Region::new_error(self.interner(), e)
147+
ty::Region::new_error(self.cx(), e)
148148
}
149149
}
150150
}

0 commit comments

Comments
 (0)