Skip to content

Commit 7740f9a

Browse files
committed
Auto merge of #107869 - nnethercote:reduce-interning, r=compiler-errors
Reduce interning r? `@compiler-errors`
2 parents 59083c5 + e261665 commit 7740f9a

File tree

30 files changed

+173
-114
lines changed

30 files changed

+173
-114
lines changed

compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
385385
calculate_debuginfo_offset(bx, local, &var, base);
386386

387387
// Create a variable which will be a pointer to the actual value
388-
let ptr_ty = bx.tcx().mk_ty(ty::RawPtr(ty::TypeAndMut {
389-
mutbl: mir::Mutability::Mut,
390-
ty: place.layout.ty,
391-
}));
388+
let ptr_ty = bx
389+
.tcx()
390+
.mk_ptr(ty::TypeAndMut { mutbl: mir::Mutability::Mut, ty: place.layout.ty });
392391
let ptr_layout = bx.layout_of(ptr_ty);
393392
let alloca = PlaceRef::alloca(bx, ptr_layout);
394393
bx.set_var_name(alloca.llval, &(var.name.to_string() + ".dbg.spill"));

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn get_info_on_unsized_field<'tcx>(
193193

194194
// Have to adjust type for ty::Str
195195
let unsized_inner_ty = match unsized_inner_ty.kind() {
196-
ty::Str => tcx.mk_ty(ty::Uint(ty::UintTy::U8)),
196+
ty::Str => tcx.types.u8,
197197
_ => unsized_inner_ty,
198198
};
199199

@@ -216,7 +216,7 @@ fn create_pointee_place<'tcx>(
216216

217217
let (unsized_inner_ty, num_elems) = get_info_on_unsized_field(ty, valtree, tcx);
218218
let unsized_inner_ty = match unsized_inner_ty.kind() {
219-
ty::Str => tcx.mk_ty(ty::Uint(ty::UintTy::U8)),
219+
ty::Str => tcx.types.u8,
220220
_ => unsized_inner_ty,
221221
};
222222
let unsized_inner_ty_size =

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ impl Qualif for CustomEq {
217217

218218
fn in_adt_inherently<'tcx>(
219219
cx: &ConstCx<'_, 'tcx>,
220-
adt: AdtDef<'tcx>,
220+
def: AdtDef<'tcx>,
221221
substs: SubstsRef<'tcx>,
222222
) -> bool {
223-
let ty = cx.tcx.mk_ty(ty::Adt(adt, substs));
223+
let ty = cx.tcx.mk_adt(def, substs);
224224
!ty.is_structural_eq_shallow(cx.tcx)
225225
}
226226
}

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
12501250
//
12511251
// Calling `skip_binder` is okay, because `add_bounds` expects the `param_ty`
12521252
// parameter to have a skipped binder.
1253-
let param_ty = tcx.mk_ty(ty::Alias(ty::Projection, projection_ty.skip_binder()));
1253+
let param_ty = tcx.mk_alias(ty::Projection, projection_ty.skip_binder());
12541254
self.add_bounds(param_ty, ast_bounds.iter(), bounds, candidate.bound_vars());
12551255
}
12561256
}
@@ -2930,7 +2930,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
29302930
}
29312931
};
29322932

2933-
tcx.mk_ty(ty::Array(self.ast_ty_to_ty(ty), length))
2933+
tcx.mk_array_with_const_len(self.ast_ty_to_ty(ty), length)
29342934
}
29352935
hir::TyKind::Typeof(e) => {
29362936
let ty_erased = tcx.type_of(e.def_id);

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,10 +1927,10 @@ pub(super) fn check_type_bounds<'tcx>(
19271927
let kind = ty::BoundTyKind::Param(param.def_id, param.name);
19281928
let bound_var = ty::BoundVariableKind::Ty(kind);
19291929
bound_vars.push(bound_var);
1930-
tcx.mk_ty(ty::Bound(
1930+
tcx.mk_bound(
19311931
ty::INNERMOST,
19321932
ty::BoundTy { var: ty::BoundVar::from_usize(bound_vars.len() - 1), kind },
1933-
))
1933+
)
19341934
.into()
19351935
}
19361936
GenericParamDefKind::Lifetime => {

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<'tcx>>(
603603
// our example, the type was `Self`, which will also be
604604
// `Self` in the GAT.
605605
let ty_param = gat_generics.param_at(*ty_idx, tcx);
606-
let ty_param = tcx
607-
.mk_ty(ty::Param(ty::ParamTy { index: ty_param.index, name: ty_param.name }));
606+
let ty_param = tcx.mk_ty_param(ty_param.index, ty_param.name);
608607
// Same for the region. In our example, 'a corresponds
609608
// to the 'me parameter.
610609
let region_param = gat_generics.param_at(*region_a_idx, tcx);

compiler/rustc_hir_typeck/src/check.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ fn check_lang_start_fn<'tcx>(
264264
// for example `start`'s generic should be a type parameter
265265
let generics = tcx.generics_of(def_id);
266266
let fn_generic = generics.param_at(0, tcx);
267-
let generic_tykind =
268-
ty::Param(ty::ParamTy { index: fn_generic.index, name: fn_generic.name });
269-
let generic_ty = tcx.mk_ty(generic_tykind);
267+
let generic_ty = tcx.mk_ty_param(fn_generic.index, fn_generic.name);
270268
let expected_fn_sig =
271269
tcx.mk_fn_sig([].iter(), &generic_ty, false, hir::Unsafety::Normal, Abi::Rust);
272270
let expected_ty = tcx.mk_fn_ptr(Binder::dummy(expected_fn_sig));

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
273273
ct_op: |c| c,
274274
ty_op: |t| match *t.kind() {
275275
ty::Infer(ty::TyVar(_)) => self.tcx.mk_ty_var(ty::TyVid::from_u32(0)),
276-
ty::Infer(ty::IntVar(_)) => {
277-
self.tcx.mk_ty_infer(ty::IntVar(ty::IntVid { index: 0 }))
278-
}
279-
ty::Infer(ty::FloatVar(_)) => {
280-
self.tcx.mk_ty_infer(ty::FloatVar(ty::FloatVid { index: 0 }))
281-
}
276+
ty::Infer(ty::IntVar(_)) => self.tcx.mk_int_var(ty::IntVid { index: 0 }),
277+
ty::Infer(ty::FloatVar(_)) => self.tcx.mk_float_var(ty::FloatVid { index: 0 }),
282278
_ => t,
283279
},
284280
};

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14291429

14301430
self.check_repeat_element_needs_copy_bound(element, count, element_ty);
14311431

1432-
tcx.mk_ty(ty::Array(t, count))
1432+
tcx.mk_array_with_const_len(t, count)
14331433
}
14341434

14351435
fn check_repeat_element_needs_copy_bound(

compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12961296
)
12971297
});
12981298
let element_tys = tcx.mk_type_list(element_tys_iter);
1299-
let pat_ty = tcx.mk_ty(ty::Tuple(element_tys));
1299+
let pat_ty = tcx.intern_tup(element_tys);
13001300
if let Some(mut err) = self.demand_eqtype_pat_diag(span, expected, pat_ty, ti) {
13011301
let reported = err.emit();
13021302
// Walk subpatterns with an expected type of `err` in this case to silence

0 commit comments

Comments
 (0)