Skip to content

Commit 0fc84fa

Browse files
committed
Move Ty<...> from rustc_middle to rustc_type_ir
1 parent b711f95 commit 0fc84fa

90 files changed

Lines changed: 2950 additions & 2670 deletions

File tree

Some content is hidden

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

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};
@@ -2554,7 +2555,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
25542555

25552556
match in_elem.kind() {
25562557
ty::RawPtr(p_ty, _) => {
2557-
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
2558+
let metadata = p_ty.ptr_metadata_ty(bx.tcx, &ObligationCause::dummy(), |ty| {
25582559
bx.tcx.normalize_erasing_regions(bx.typing_env(), ty)
25592560
});
25602561
require!(
@@ -2568,7 +2569,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
25682569
}
25692570
match out_elem.kind() {
25702571
ty::RawPtr(p_ty, _) => {
2571-
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
2572+
let metadata = p_ty.ptr_metadata_ty(bx.tcx, &ObligationCause::dummy(), |ty| {
25722573
bx.tcx.normalize_erasing_regions(bx.typing_env(), ty)
25732574
});
25742575
require!(

compiler/rustc_const_eval/src/interpret/call.rs

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

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
@@ -33,8 +33,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
3333
return map[&trait_item_def_id];
3434
}
3535
Err(_) => {
36-
return ty::EarlyBinder::bind(Ty::new_error_with_message(
37-
tcx,
36+
return ty::EarlyBinder::bind(tcx.new_error_with_message(
3837
DUMMY_SP,
3938
"Could not collect return position impl trait in trait tys",
4039
));
@@ -359,8 +358,7 @@ fn anon_const_type_of<'tcx>(icx: &ItemCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx
359358
tcx.type_of(field_def_id).instantiate_identity()
360359
}
361360

362-
_ => Ty::new_error_with_message(
363-
tcx,
361+
_ => tcx.new_error_with_message(
364362
span,
365363
format!("unexpected anon const parent in type_of(): {parent_node:?}"),
366364
),
@@ -395,8 +393,7 @@ fn const_arg_anon_type_of<'tcx>(icx: &ItemCtxt<'tcx>, arg_hir_id: HirId, span: S
395393

396394
// This is not a `bug!` as const arguments in path segments that did not resolve to anything
397395
// will result in `type_of` never being fed.
398-
_ => Ty::new_error_with_message(
399-
tcx,
396+
_ => tcx.new_error_with_message(
400397
span,
401398
"`type_of` called on const argument's anon const before the const argument was lowered",
402399
),
@@ -420,8 +417,7 @@ fn infer_placeholder_type<'tcx>(
420417
if let Some(trait_item_def_id) = tcx.trait_item_of(def_id.to_def_id()) {
421418
tcx.type_of(trait_item_def_id).instantiate_identity()
422419
} else {
423-
Ty::new_error_with_message(
424-
tcx,
420+
tcx.new_error_with_message(
425421
ty_span,
426422
"constant with `type const` requires an explicit type",
427423
)

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)