Skip to content

Commit 12138b8

Browse files
committed
Move TyCtxt::mk_x to Ty::new_x where applicable
1 parent 5dac6b3 commit 12138b8

File tree

164 files changed

+1386
-1185
lines changed

Some content is hidden

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

164 files changed

+1386
-1185
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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),

0 commit comments

Comments
 (0)