Skip to content

Commit 4462ec4

Browse files
committed
Move Ty<...> from rustc_middle to rustc_type_ir
1 parent 595f14b commit 4462ec4

File tree

88 files changed

+2871
-2657
lines changed

Some content is hidden

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

88 files changed

+2871
-2657
lines changed

compiler/rustc_codegen_gcc/src/intrinsic/simd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
538538

539539
match *in_elem.kind() {
540540
ty::RawPtr(p_ty, _) => {
541-
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
541+
let metadata = p_ty.ptr_metadata_ty(bx.tcx, &ObligationCause::dummy(), |ty| {
542542
bx.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), ty)
543543
});
544544
require!(
@@ -552,7 +552,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
552552
}
553553
match *out_elem.kind() {
554554
ty::RawPtr(p_ty, _) => {
555-
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
555+
let metadata = p_ty.ptr_metadata_ty(bx.tcx, &ObligationCause::dummy(), |ty| {
556556
bx.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), ty)
557557
});
558558
require!(

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use rustc_hir as hir;
1515
use rustc_hir::def_id::LOCAL_CRATE;
1616
use rustc_hir::find_attr;
1717
use rustc_middle::mir::BinOp;
18+
use rustc_middle::traits::ObligationCause;
1819
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, LayoutOf};
1920
use rustc_middle::ty::offload_meta::OffloadMetadata;
2021
use rustc_middle::ty::{self, GenericArgsRef, Instance, SimdAlign, Ty, TyCtxt, TypingEnv};
@@ -2560,7 +2561,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
25602561

25612562
match in_elem.kind() {
25622563
ty::RawPtr(p_ty, _) => {
2563-
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
2564+
let metadata = p_ty.ptr_metadata_ty(bx.tcx, &ObligationCause::dummy(), |ty| {
25642565
bx.tcx.normalize_erasing_regions(bx.typing_env(), ty)
25652566
});
25662567
require!(
@@ -2574,7 +2575,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
25742575
}
25752576
match out_elem.kind() {
25762577
ty::RawPtr(p_ty, _) => {
2577-
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
2578+
let metadata = p_ty.ptr_metadata_ty(bx.tcx, &ObligationCause::dummy(), |ty| {
25782579
bx.tcx.normalize_erasing_regions(bx.typing_env(), ty)
25792580
});
25802581
require!(

compiler/rustc_const_eval/src/interpret/call.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_abi::{self as abi, ExternAbi, FieldIdx, Integer, VariantIdx};
99
use rustc_errors::msg;
1010
use rustc_hir::def_id::DefId;
1111
use rustc_hir::find_attr;
12+
use rustc_infer::traits::ObligationCause;
1213
use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
1314
use rustc_middle::ty::{self, AdtDef, Instance, Ty, VariantDef};
1415
use rustc_middle::{bug, mir, span_bug};
@@ -221,7 +222,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
221222
// to fields, which can yield non-normalized types. So we need to provide a
222223
// normalization function.
223224
let normalize = |ty| self.tcx.normalize_erasing_regions(self.typing_env, ty);
224-
ty.ptr_metadata_ty(*self.tcx, normalize)
225+
ty.ptr_metadata_ty(*self.tcx, &ObligationCause::dummy(), normalize)
225226
};
226227
return interp_ok(meta_ty(caller) == meta_ty(callee));
227228
}

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,9 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
777777
if !remapped_types.contains_key(assoc_item) {
778778
remapped_types.insert(
779779
*assoc_item,
780-
ty::EarlyBinder::bind(Ty::new_error_with_message(
781-
tcx,
782-
return_span,
783-
"missing synthetic item for RPITIT",
784-
)),
780+
ty::EarlyBinder::bind(
781+
tcx.new_error_with_message(return_span, "missing synthetic item for RPITIT"),
782+
),
785783
);
786784
}
787785
}

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ pub(crate) fn check_intrinsic_type(
257257
{
258258
Ty::new_param(tcx, n, name)
259259
} else {
260-
Ty::new_error_with_message(tcx, span, "expected param")
260+
tcx.new_error_with_message(span, "expected param")
261261
}
262262
};
263263

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
343343
if !self.tcx.dcx().has_stashed_diagnostic(span, StashKey::ItemNoType) {
344344
self.report_placeholder_type_error(vec![span], vec![]);
345345
}
346-
Ty::new_error_with_message(self.tcx(), span, "bad placeholder type")
346+
self.tcx().new_error_with_message(span, "bad placeholder type")
347347
}
348348

349349
fn ct_infer(&self, _: Option<&ty::GenericParamDef>, span: Span) -> Const<'tcx> {
@@ -540,7 +540,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
540540
self.lowerer().suggest_trait_fn_ty_for_impl_fn_infer(hir_id, Some(i))
541541
{
542542
infer_replacements.push((a.span, suggested_ty.to_string()));
543-
return Ty::new_error_with_message(tcx, a.span, suggested_ty.to_string());
543+
return tcx.new_error_with_message(a.span, suggested_ty.to_string());
544544
}
545545

546546
self.lowerer().lower_ty(a)
@@ -554,7 +554,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
554554
self.lowerer().suggest_trait_fn_ty_for_impl_fn_infer(hir_id, None)
555555
{
556556
infer_replacements.push((output.span, suggested_ty.to_string()));
557-
Ty::new_error_with_message(tcx, output.span, suggested_ty.to_string())
557+
tcx.new_error_with_message(output.span, suggested_ty.to_string())
558558
} else {
559559
self.lower_ty(output)
560560
}

compiler/rustc_hir_analysis/src/collect/type_of.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
3434
return map[&trait_item_def_id];
3535
}
3636
Err(_) => {
37-
return ty::EarlyBinder::bind(Ty::new_error_with_message(
38-
tcx,
37+
return ty::EarlyBinder::bind(tcx.new_error_with_message(
3938
DUMMY_SP,
4039
"Could not collect return position impl trait in trait tys",
4140
));
@@ -366,8 +365,7 @@ fn anon_const_type_of<'tcx>(icx: &ItemCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx
366365
tcx.type_of(field_def_id).instantiate_identity()
367366
}
368367

369-
_ => Ty::new_error_with_message(
370-
tcx,
368+
_ => tcx.new_error_with_message(
371369
span,
372370
format!("unexpected anon const parent in type_of(): {parent_node:?}"),
373371
),
@@ -402,8 +400,7 @@ fn const_arg_anon_type_of<'tcx>(icx: &ItemCtxt<'tcx>, arg_hir_id: HirId, span: S
402400

403401
// This is not a `bug!` as const arguments in path segments that did not resolve to anything
404402
// will result in `type_of` never being fed.
405-
_ => Ty::new_error_with_message(
406-
tcx,
403+
_ => tcx.new_error_with_message(
407404
span,
408405
"`type_of` called on const argument's anon const before the const argument was lowered",
409406
),
@@ -427,8 +424,7 @@ fn infer_placeholder_type<'tcx>(
427424
if let Some(trait_item_def_id) = tcx.trait_item_of(def_id.to_def_id()) {
428425
tcx.type_of(trait_item_def_id).instantiate_identity()
429426
} else {
430-
Ty::new_error_with_message(
431-
tcx,
427+
tcx.new_error_with_message(
432428
ty_span,
433429
"constant with `type const` requires an explicit type",
434430
)

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,11 +684,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
684684
let item_def_id = match path.res {
685685
Res::Def(DefKind::AssocFn, item_def_id) => item_def_id,
686686
Res::Err => {
687-
return Ty::new_error_with_message(
688-
tcx,
689-
hir_ty.span,
690-
"failed to resolve RTN",
691-
);
687+
return tcx.new_error_with_message(hir_ty.span, "failed to resolve RTN");
692688
}
693689
_ => bug!("only expected method resolution for fully qualified RTN"),
694690
};

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
765765
self.lowerer.ty_infer(Some(param), self.span).into()
766766
} else {
767767
// We've already errored above about the mismatch.
768-
Ty::new_misc_error(tcx).into()
768+
tcx.new_misc_error().into()
769769
}
770770
}
771771
GenericParamDefKind::Const { has_default, .. } => {

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10181018
})?
10191019
}
10201020
ty::Alias(ty::Projection, _) => {
1021-
return Some(Ty::new_error_with_message(
1022-
self.tcx,
1021+
return Some(self.tcx.new_error_with_message(
10231022
closure_span,
10241023
"this projection should have been projected to an opaque type",
10251024
));

0 commit comments

Comments
 (0)