Skip to content

Commit 4dd1719

Browse files
committed
Auto merge of #113377 - BoxyUwU:move_ty_ctors_to_ty, r=compiler-errors
Move `TyCtxt::mk_x` to `Ty::new_x` where applicable Part of rust-lang/compiler-team#616 turns out there's a lot of places we construct `Ty` this is a ridiculously huge PR :S r? `@oli-obk`
2 parents b112bc5 + deda49e commit 4dd1719

File tree

165 files changed

+1388
-1187
lines changed

Some content is hidden

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

165 files changed

+1388
-1187
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10501050
Some(def_id) => type_known_to_meet_bound_modulo_regions(
10511051
&self.infcx,
10521052
self.param_env,
1053-
tcx.mk_imm_ref(tcx.lifetimes.re_erased, ty),
1053+
Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, ty),
10541054
def_id,
10551055
),
10561056
_ => false,

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
508508
let generic_arg = substs[param_index as usize];
509509
let identity_substs =
510510
InternalSubsts::identity_for_item(self.infcx.tcx, adt.did());
511-
let base_ty = self.infcx.tcx.mk_adt(*adt, identity_substs);
511+
let base_ty = Ty::new_adt(self.infcx.tcx, *adt, identity_substs);
512512
let base_generic_arg = identity_substs[param_index as usize];
513513
let adt_desc = adt.descr();
514514

compiler/rustc_borrowck/src/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
11391139
_ => arg.fold_with(self),
11401140
}
11411141
});
1142-
tcx.mk_opaque(def_id, tcx.mk_substs_from_iter(substs))
1142+
Ty::new_opaque(tcx, def_id, tcx.mk_substs_from_iter(substs))
11431143
}
11441144
}
11451145

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
158158
)
159159
.emit()
160160
});
161-
prev.ty = infcx.tcx.ty_error(guar);
161+
prev.ty = Ty::new_error(infcx.tcx, guar);
162162
}
163163
// Pick a better span if there is one.
164164
// FIXME(oli-obk): collect multiple spans for better diagnostics down the road.
@@ -248,13 +248,13 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
248248
instantiated_ty: OpaqueHiddenType<'tcx>,
249249
) -> Ty<'tcx> {
250250
if let Some(e) = self.tainted_by_errors() {
251-
return self.tcx.ty_error(e);
251+
return Ty::new_error(self.tcx, e);
252252
}
253253

254254
if let Err(guar) =
255255
check_opaque_type_parameter_valid(self.tcx, opaque_type_key, instantiated_ty.span)
256256
{
257-
return self.tcx.ty_error(guar);
257+
return Ty::new_error(self.tcx, guar);
258258
}
259259

260260
let definition_ty = instantiated_ty
@@ -271,7 +271,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
271271
definition_ty,
272272
) {
273273
Ok(hidden_ty) => hidden_ty,
274-
Err(guar) => self.tcx.ty_error(guar),
274+
Err(guar) => Ty::new_error(self.tcx, guar),
275275
}
276276
}
277277
}
@@ -313,7 +313,7 @@ fn check_opaque_type_well_formed<'tcx>(
313313

314314
// Require that the hidden type actually fulfills all the bounds of the opaque type, even without
315315
// the bounds that the function supplies.
316-
let opaque_ty = tcx.mk_opaque(def_id.to_def_id(), identity_substs);
316+
let opaque_ty = Ty::new_opaque(tcx, def_id.to_def_id(), identity_substs);
317317
ocx.eq(&ObligationCause::misc(definition_span, def_id), param_env, opaque_ty, definition_ty)
318318
.map_err(|err| {
319319
infcx

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
245245
.and(type_op::normalize::Normalize::new(ty))
246246
.fully_perform(self.infcx, span)
247247
.unwrap_or_else(|guar| TypeOpOutput {
248-
output: self.infcx.tcx.ty_error(guar),
248+
output: Ty::new_error(self.infcx.tcx, guar),
249249
constraints: None,
250250
error_info: None,
251251
});

compiler/rustc_borrowck/src/type_check/mod.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
237237
decl.hidden_type.span,
238238
format!("could not resolve {:#?}", hidden_type.ty.kind()),
239239
);
240-
hidden_type.ty = infcx.tcx.ty_error(reported);
240+
hidden_type.ty = Ty::new_error(infcx.tcx, reported);
241241
}
242242

243243
(opaque_type_key, hidden_type)
@@ -520,7 +520,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
520520
for elem in place.projection.iter() {
521521
if place_ty.variant_index.is_none() {
522522
if let Err(guar) = place_ty.ty.error_reported() {
523-
return PlaceTy::from_ty(self.tcx().ty_error(guar));
523+
return PlaceTy::from_ty(Ty::new_error(self.tcx(), guar));
524524
}
525525
}
526526
place_ty = self.sanitize_projection(place_ty, elem, place, location, context);
@@ -656,7 +656,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
656656
PlaceTy::from_ty(match base_ty.kind() {
657657
ty::Array(inner, _) => {
658658
assert!(!from_end, "array subslices should not use from_end");
659-
tcx.mk_array(*inner, to - from)
659+
Ty::new_array(tcx, *inner, to - from)
660660
}
661661
ty::Slice(..) => {
662662
assert!(from_end, "slice subslices should use from_end");
@@ -749,7 +749,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
749749
}
750750

751751
fn error(&mut self) -> Ty<'tcx> {
752-
self.tcx().ty_error_misc()
752+
Ty::new_misc_error(self.tcx())
753753
}
754754

755755
fn get_ambient_variance(&self, context: PlaceContext) -> ty::Variance {
@@ -1918,7 +1918,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19181918
// and hence may contain unnormalized results.
19191919
let fn_sig = self.normalize(fn_sig, location);
19201920

1921-
let ty_fn_ptr_from = tcx.mk_fn_ptr(fn_sig);
1921+
let ty_fn_ptr_from = Ty::new_fn_ptr(tcx, fn_sig);
19221922

19231923
if let Err(terr) = self.eq_types(
19241924
*ty,
@@ -1942,7 +1942,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19421942
ty::Closure(_, substs) => substs.as_closure().sig(),
19431943
_ => bug!(),
19441944
};
1945-
let ty_fn_ptr_from = tcx.mk_fn_ptr(tcx.signature_unclosure(sig, *unsafety));
1945+
let ty_fn_ptr_from =
1946+
Ty::new_fn_ptr(tcx, tcx.signature_unclosure(sig, *unsafety));
19461947

19471948
if let Err(terr) = self.eq_types(
19481949
*ty,

compiler/rustc_borrowck/src/universal_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
685685
assert_eq!(self.mir_def.to_def_id(), def_id);
686686
let resume_ty = substs.as_generator().resume_ty();
687687
let output = substs.as_generator().return_ty();
688-
let generator_ty = tcx.mk_generator(def_id, substs, movability);
688+
let generator_ty = Ty::new_generator(tcx, def_id, substs, movability);
689689
let inputs_and_output =
690690
self.infcx.tcx.mk_type_list(&[generator_ty, resume_ty, output]);
691691
ty::Binder::dummy(inputs_and_output)

compiler/rustc_codegen_cranelift/src/abi/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,8 @@ pub(crate) fn codegen_drop<'tcx>(
665665

666666
let arg_value = drop_place.place_ref(
667667
fx,
668-
fx.layout_of(fx.tcx.mk_ref(
668+
fx.layout_of(Ty::new_ref(
669+
fx.tcx,
669670
fx.tcx.lifetimes.re_erased,
670671
TypeAndMut { ty, mutbl: crate::rustc_hir::Mutability::Mut },
671672
)),

compiler/rustc_codegen_cranelift/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ fn codegen_stmt<'tcx>(
746746
}
747747
Rvalue::ShallowInitBox(ref operand, content_ty) => {
748748
let content_ty = fx.monomorphize(content_ty);
749-
let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty));
749+
let box_layout = fx.layout_of(Ty::new_box(fx.tcx, content_ty));
750750
let operand = codegen_operand(fx, operand);
751751
let operand = operand.load_scalar(fx);
752752
lval.write_cvalue(fx, CValue::by_val(operand, box_layout));
@@ -887,7 +887,7 @@ pub(crate) fn codegen_place<'tcx>(
887887
let ptr = cplace.to_ptr();
888888
cplace = CPlace::for_ptr(
889889
ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)),
890-
fx.layout_of(fx.tcx.mk_array(*elem_ty, to - from)),
890+
fx.layout_of(Ty::new_array(fx.tcx, *elem_ty, to - from)),
891891
);
892892
}
893893
ty::Slice(elem_ty) => {

compiler/rustc_codegen_cranelift/src/codegen_i128.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
9292
match bin_op {
9393
BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => unreachable!(),
9494
BinOp::Mul if is_signed => {
95-
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
95+
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
9696
let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
9797
let lhs = lhs.load_scalar(fx);
9898
let rhs = rhs.load_scalar(fx);
@@ -112,7 +112,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
112112
Some(CValue::by_val_pair(res, oflow, fx.layout_of(out_ty)))
113113
}
114114
BinOp::Add | BinOp::Sub | BinOp::Mul => {
115-
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
115+
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
116116
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
117117
let param_types = vec![
118118
AbiParam::special(fx.pointer_type, ArgumentPurpose::StructReturn),

compiler/rustc_codegen_cranelift/src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fn clif_pair_type_from_ty<'tcx>(
9999

100100
/// Is a pointer to this type a fat ptr?
101101
pub(crate) fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
102-
let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc_hir::Mutability::Not });
102+
let ptr_ty = Ty::new_ptr(tcx, TypeAndMut { ty, mutbl: rustc_hir::Mutability::Not });
103103
match &tcx.layout_of(ParamEnv::reveal_all().and(ptr_ty)).unwrap().abi {
104104
Abi::Scalar(_) => false,
105105
Abi::ScalarPair(_, _) => true,

compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ fn llvm_add_sub<'tcx>(
386386
// carry0 | carry1 -> carry or borrow respectively
387387
let cb_out = fx.bcx.ins().bor(cb0, cb1);
388388

389-
let layout = fx.layout_of(fx.tcx.mk_tup(&[fx.tcx.types.u8, fx.tcx.types.u64]));
389+
let layout = fx.layout_of(Ty::new_tup(fx.tcx, &[fx.tcx.types.u8, fx.tcx.types.u64]));
390390
let val = CValue::by_val_pair(cb_out, c, layout);
391391
ret.write_cvalue(fx, val);
392392
}

compiler/rustc_codegen_cranelift/src/num.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
270270
_ => bug!("binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", bin_op, in_lhs, in_rhs),
271271
};
272272

273-
let out_layout = fx.layout_of(fx.tcx.mk_tup(&[in_lhs.layout().ty, fx.tcx.types.bool]));
273+
let out_layout = fx.layout_of(Ty::new_tup(fx.tcx, &[in_lhs.layout().ty, fx.tcx.types.bool]));
274274
CValue::by_val_pair(res, has_overflow, out_layout)
275275
}
276276

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1147,19 +1147,19 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(cx: &'a CodegenCx<'gcc, 'tcx>, codegen: &mut
11471147

11481148
// Define the type up front for the signature of the rust_try function.
11491149
let tcx = cx.tcx;
1150-
let i8p = tcx.mk_mut_ptr(tcx.types.i8);
1150+
let i8p = Ty::new_mut_ptr(tcx,tcx.types.i8);
11511151
// `unsafe fn(*mut i8) -> ()`
1152-
let try_fn_ty = tcx.mk_fn_ptr(ty::Binder::dummy(tcx.mk_fn_sig(
1152+
let try_fn_ty = Ty::new_fn_ptr(tcx,ty::Binder::dummy(tcx.mk_fn_sig(
11531153
iter::once(i8p),
1154-
tcx.mk_unit(),
1154+
Ty::new_unit(tcx,),
11551155
false,
11561156
rustc_hir::Unsafety::Unsafe,
11571157
Abi::Rust,
11581158
)));
11591159
// `unsafe fn(*mut i8, *mut i8) -> ()`
1160-
let catch_fn_ty = tcx.mk_fn_ptr(ty::Binder::dummy(tcx.mk_fn_sig(
1160+
let catch_fn_ty = Ty::new_fn_ptr(tcx,ty::Binder::dummy(tcx.mk_fn_sig(
11611161
[i8p, i8p].iter().cloned(),
1162-
tcx.mk_unit(),
1162+
Ty::new_unit(tcx,),
11631163
false,
11641164
rustc_hir::Unsafety::Unsafe,
11651165
Abi::Rust,

compiler/rustc_codegen_gcc/src/type_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
283283
// only wide pointer boxes are handled as pointers
284284
// thin pointer boxes with scalar allocators are handled by the general logic below
285285
ty::Adt(def, substs) if def.is_box() && cx.layout_of(substs.type_at(1)).is_zst() => {
286-
let ptr_ty = cx.tcx.mk_mut_ptr(self.ty.boxed_ty());
286+
let ptr_ty = Ty::new_mut_ptr(cx.tcx,self.ty.boxed_ty());
287287
return cx.layout_of(ptr_ty).scalar_pair_element_gcc_type(cx, index, immediate);
288288
}
289289
_ => {}

compiler/rustc_codegen_llvm/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
351351
continue;
352352
}
353353
PassMode::Indirect { attrs: _, extra_attrs: Some(_), on_stack: _ } => {
354-
let ptr_ty = cx.tcx.mk_mut_ptr(arg.layout.ty);
354+
let ptr_ty = Ty::new_mut_ptr(cx.tcx, arg.layout.ty);
355355
let ptr_layout = cx.layout_of(ptr_ty);
356356
llargument_tys.push(ptr_layout.scalar_pair_element_llvm_type(cx, 0, true));
357357
llargument_tys.push(ptr_layout.scalar_pair_element_llvm_type(cx, 1, true));

compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use rustc_middle::ty;
2424
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt};
2525
use rustc_middle::ty::subst::InternalSubsts;
2626
use rustc_middle::ty::Instance;
27+
use rustc_middle::ty::Ty;
2728

2829
use std::cell::RefCell;
2930
use std::ffi::CString;
@@ -262,8 +263,8 @@ fn declare_unused_fn<'tcx>(cx: &CodegenCx<'_, 'tcx>, def_id: DefId) -> Instance<
262263
tcx.symbol_name(instance).name,
263264
cx.fn_abi_of_fn_ptr(
264265
ty::Binder::dummy(tcx.mk_fn_sig(
265-
[tcx.mk_unit()],
266-
tcx.mk_unit(),
266+
[Ty::new_unit(tcx)],
267+
Ty::new_unit(tcx),
267268
false,
268269
hir::Unsafety::Unsafe,
269270
Abi::Rust,

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
168168
// a (fat) pointer. Make sure it is not called for e.g. `Box<T, NonZSTAllocator>`.
169169
debug_assert_eq!(
170170
cx.size_and_align_of(ptr_type),
171-
cx.size_and_align_of(cx.tcx.mk_mut_ptr(pointee_type))
171+
cx.size_and_align_of(Ty::new_mut_ptr(cx.tcx, pointee_type))
172172
);
173173

174174
let pointee_type_di_node = type_di_node(cx, pointee_type);
@@ -223,8 +223,11 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
223223
// at all and instead emit regular struct debuginfo for it. We just
224224
// need to make sure that we don't break existing debuginfo consumers
225225
// by doing that (at least not without a warning period).
226-
let layout_type =
227-
if ptr_type.is_box() { cx.tcx.mk_mut_ptr(pointee_type) } else { ptr_type };
226+
let layout_type = if ptr_type.is_box() {
227+
Ty::new_mut_ptr(cx.tcx, pointee_type)
228+
} else {
229+
ptr_type
230+
};
228231

229232
let layout = cx.layout_of(layout_type);
230233
let addr_field = layout.field(cx, abi::FAT_PTR_ADDR);
@@ -1298,7 +1301,7 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
12981301

12991302
// All function pointers are described as opaque pointers. This could be improved in the future
13001303
// by describing them as actual function pointers.
1301-
let void_pointer_ty = tcx.mk_imm_ptr(tcx.types.unit);
1304+
let void_pointer_ty = Ty::new_imm_ptr(tcx, tcx.types.unit);
13021305
let void_pointer_type_di_node = type_di_node(cx, void_pointer_ty);
13031306
let usize_di_node = type_di_node(cx, tcx.types.usize);
13041307
let (pointer_size, pointer_align) = cx.size_and_align_of(void_pointer_ty);

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
454454
ty::Array(ct, _)
455455
if (*ct == cx.tcx.types.u8) || cx.layout_of(*ct).is_zst() =>
456456
{
457-
cx.tcx.mk_imm_ptr(*ct)
457+
Ty::new_imm_ptr(cx.tcx, *ct)
458458
}
459459
_ => t,
460460
};

compiler/rustc_codegen_llvm/src/debuginfo/utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ pub(crate) fn fat_pointer_kind<'ll, 'tcx>(
8282
ty::Foreign(_) => {
8383
// Assert that pointers to foreign types really are thin:
8484
debug_assert_eq!(
85-
cx.size_of(cx.tcx.mk_imm_ptr(pointee_tail_ty)),
86-
cx.size_of(cx.tcx.mk_imm_ptr(cx.tcx.types.u8))
85+
cx.size_of(Ty::new_imm_ptr(cx.tcx, pointee_tail_ty)),
86+
cx.size_of(Ty::new_imm_ptr(cx.tcx, cx.tcx.types.u8))
8787
);
8888
None
8989
}

compiler/rustc_codegen_llvm/src/intrinsic.rs

+21-15
Original file line numberDiff line numberDiff line change
@@ -873,23 +873,29 @@ fn get_rust_try_fn<'ll, 'tcx>(
873873

874874
// Define the type up front for the signature of the rust_try function.
875875
let tcx = cx.tcx;
876-
let i8p = tcx.mk_mut_ptr(tcx.types.i8);
876+
let i8p = Ty::new_mut_ptr(tcx, tcx.types.i8);
877877
// `unsafe fn(*mut i8) -> ()`
878-
let try_fn_ty = tcx.mk_fn_ptr(ty::Binder::dummy(tcx.mk_fn_sig(
879-
[i8p],
880-
tcx.mk_unit(),
881-
false,
882-
hir::Unsafety::Unsafe,
883-
Abi::Rust,
884-
)));
878+
let try_fn_ty = Ty::new_fn_ptr(
879+
tcx,
880+
ty::Binder::dummy(tcx.mk_fn_sig(
881+
[i8p],
882+
Ty::new_unit(tcx),
883+
false,
884+
hir::Unsafety::Unsafe,
885+
Abi::Rust,
886+
)),
887+
);
885888
// `unsafe fn(*mut i8, *mut i8) -> ()`
886-
let catch_fn_ty = tcx.mk_fn_ptr(ty::Binder::dummy(tcx.mk_fn_sig(
887-
[i8p, i8p],
888-
tcx.mk_unit(),
889-
false,
890-
hir::Unsafety::Unsafe,
891-
Abi::Rust,
892-
)));
889+
let catch_fn_ty = Ty::new_fn_ptr(
890+
tcx,
891+
ty::Binder::dummy(tcx.mk_fn_sig(
892+
[i8p, i8p],
893+
Ty::new_unit(tcx),
894+
false,
895+
hir::Unsafety::Unsafe,
896+
Abi::Rust,
897+
)),
898+
);
893899
// `unsafe fn(unsafe fn(*mut i8) -> (), *mut i8, unsafe fn(*mut i8, *mut i8) -> ()) -> i32`
894900
let rust_fn_sig = ty::Binder::dummy(cx.tcx.mk_fn_sig(
895901
[try_fn_ty, i8p, catch_fn_ty],

compiler/rustc_codegen_llvm/src/type_of.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,13 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
337337
// only wide pointer boxes are handled as pointers
338338
// thin pointer boxes with scalar allocators are handled by the general logic below
339339
ty::Adt(def, substs) if def.is_box() && cx.layout_of(substs.type_at(1)).is_zst() => {
340-
let ptr_ty = cx.tcx.mk_mut_ptr(self.ty.boxed_ty());
340+
let ptr_ty = Ty::new_mut_ptr(cx.tcx, self.ty.boxed_ty());
341341
return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate);
342342
}
343343
// `dyn* Trait` has the same ABI as `*mut dyn Trait`
344344
ty::Dynamic(bounds, region, ty::DynStar) => {
345-
let ptr_ty = cx.tcx.mk_mut_ptr(cx.tcx.mk_dynamic(bounds, region, ty::Dyn));
345+
let ptr_ty =
346+
Ty::new_mut_ptr(cx.tcx, Ty::new_dynamic(cx.tcx, bounds, region, ty::Dyn));
346347
return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate);
347348
}
348349
_ => {}

compiler/rustc_codegen_llvm/src/va_arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn emit_ptr_va_arg<'ll, 'tcx>(
7373
let layout = bx.cx.layout_of(target_ty);
7474
let (llty, size, align) = if indirect {
7575
(
76-
bx.cx.layout_of(bx.cx.tcx.mk_imm_ptr(target_ty)).llvm_type(bx.cx),
76+
bx.cx.layout_of(Ty::new_imm_ptr(bx.cx.tcx, target_ty)).llvm_type(bx.cx),
7777
bx.cx.data_layout().pointer_size,
7878
bx.cx.data_layout().pointer_align,
7979
)

0 commit comments

Comments
 (0)