Skip to content

Commit 092135b

Browse files
compiler: Directly use rustc_abi in ty_utils
1 parent 6c16a31 commit 092135b

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

compiler/rustc_ty_utils/src/abi.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::iter;
22

33
use rustc_abi::Primitive::Pointer;
4-
use rustc_abi::{BackendRepr, PointerKind, Scalar, Size};
4+
use rustc_abi::{BackendRepr, ExternAbi, PointerKind, Scalar, Size};
55
use rustc_hir as hir;
66
use rustc_hir::lang_items::LangItem;
77
use rustc_middle::bug;
@@ -12,10 +12,9 @@ use rustc_middle::ty::layout::{
1212
use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt};
1313
use rustc_session::config::OptLevel;
1414
use rustc_span::def_id::DefId;
15-
use rustc_target::abi::call::{
15+
use rustc_target::callconv::{
1616
ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, Conv, FnAbi, PassMode, RiscvInterruptKind,
1717
};
18-
use rustc_target::spec::abi::Abi as SpecAbi;
1918
use tracing::debug;
2019

2120
pub(crate) fn provide(providers: &mut Providers) {
@@ -39,7 +38,7 @@ fn fn_sig_for_fn_abi<'tcx>(
3938
tcx.thread_local_ptr_ty(instance.def_id()),
4039
false,
4140
hir::Safety::Safe,
42-
rustc_target::spec::abi::Abi::Unadjusted,
41+
rustc_abi::ExternAbi::Unadjusted,
4342
));
4443
}
4544

@@ -270,7 +269,7 @@ fn fn_sig_for_fn_abi<'tcx>(
270269
ret_ty,
271270
false,
272271
hir::Safety::Safe,
273-
rustc_target::spec::abi::Abi::Rust,
272+
rustc_abi::ExternAbi::Rust,
274273
)
275274
} else {
276275
// `Iterator::next` doesn't have a `resume` argument.
@@ -279,7 +278,7 @@ fn fn_sig_for_fn_abi<'tcx>(
279278
ret_ty,
280279
false,
281280
hir::Safety::Safe,
282-
rustc_target::spec::abi::Abi::Rust,
281+
rustc_abi::ExternAbi::Rust,
283282
)
284283
};
285284
ty::Binder::bind_with_vars(fn_sig, bound_vars)
@@ -289,8 +288,8 @@ fn fn_sig_for_fn_abi<'tcx>(
289288
}
290289

291290
#[inline]
292-
fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv {
293-
use rustc_target::spec::abi::Abi::*;
291+
fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: ExternAbi, c_variadic: bool) -> Conv {
292+
use rustc_abi::ExternAbi::*;
294293
match tcx.sess.target.adjust_abi(abi, c_variadic) {
295294
RustIntrinsic | Rust | RustCall => Conv::Rust,
296295

@@ -453,12 +452,12 @@ fn adjust_for_rust_scalar<'tcx>(
453452
fn fn_abi_sanity_check<'tcx>(
454453
cx: &LayoutCx<'tcx>,
455454
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
456-
spec_abi: SpecAbi,
455+
spec_abi: ExternAbi,
457456
) {
458457
fn fn_arg_sanity_check<'tcx>(
459458
cx: &LayoutCx<'tcx>,
460459
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
461-
spec_abi: SpecAbi,
460+
spec_abi: ExternAbi,
462461
arg: &ArgAbi<'tcx, Ty<'tcx>>,
463462
) {
464463
let tcx = cx.tcx();
@@ -489,7 +488,7 @@ fn fn_abi_sanity_check<'tcx>(
489488
// (See issue: https://github.com/rust-lang/rust/issues/117271)
490489
assert!(
491490
matches!(&*tcx.sess.target.arch, "wasm32" | "wasm64")
492-
|| matches!(spec_abi, SpecAbi::PtxKernel | SpecAbi::Unadjusted),
491+
|| matches!(spec_abi, ExternAbi::PtxKernel | ExternAbi::Unadjusted),
493492
"`PassMode::Direct` for aggregates only allowed for \"unadjusted\" and \"ptx-kernel\" functions and on wasm\n\
494493
Problematic type: {:#?}",
495494
arg.layout,
@@ -556,7 +555,7 @@ fn fn_abi_new_uncached<'tcx>(
556555
let conv = conv_from_spec_abi(cx.tcx(), sig.abi, sig.c_variadic);
557556

558557
let mut inputs = sig.inputs();
559-
let extra_args = if sig.abi == SpecAbi::RustCall {
558+
let extra_args = if sig.abi == ExternAbi::RustCall {
560559
assert!(!sig.c_variadic && extra_args.is_empty());
561560

562561
if let Some(input) = sig.inputs().last() {
@@ -649,10 +648,10 @@ fn fn_abi_new_uncached<'tcx>(
649648
fn fn_abi_adjust_for_abi<'tcx>(
650649
cx: &LayoutCx<'tcx>,
651650
fn_abi: &mut FnAbi<'tcx, Ty<'tcx>>,
652-
abi: SpecAbi,
651+
abi: ExternAbi,
653652
fn_def_id: Option<DefId>,
654653
) -> Result<(), &'tcx FnAbiError<'tcx>> {
655-
if abi == SpecAbi::Unadjusted {
654+
if abi == ExternAbi::Unadjusted {
656655
// The "unadjusted" ABI passes aggregates in "direct" mode. That's fragile but needed for
657656
// some LLVM intrinsics.
658657
fn unadjust<'tcx>(arg: &mut ArgAbi<'tcx, Ty<'tcx>>) {
@@ -676,7 +675,7 @@ fn fn_abi_adjust_for_abi<'tcx>(
676675

677676
let tcx = cx.tcx();
678677

679-
if abi == SpecAbi::Rust || abi == SpecAbi::RustCall || abi == SpecAbi::RustIntrinsic {
678+
if abi == ExternAbi::Rust || abi == ExternAbi::RustCall || abi == ExternAbi::RustIntrinsic {
680679
fn_abi.adjust_for_rust_abi(cx, abi);
681680

682681
// Look up the deduced parameter attributes for this function, if we have its def ID and

compiler/rustc_ty_utils/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::iter;
22

3+
use rustc_abi::{FIRST_VARIANT, VariantIdx};
34
use rustc_errors::ErrorGuaranteed;
45
use rustc_hir::def::DefKind;
56
use rustc_hir::def_id::LocalDefId;
@@ -11,7 +12,6 @@ use rustc_middle::ty::abstract_const::CastKind;
1112
use rustc_middle::ty::{self, Expr, TyCtxt, TypeVisitableExt};
1213
use rustc_middle::{bug, mir, thir};
1314
use rustc_span::Span;
14-
use rustc_target::abi::{FIRST_VARIANT, VariantIdx};
1515
use tracing::{debug, instrument};
1616

1717
use crate::errors::{GenericConstantTooComplex, GenericConstantTooComplexSub};

compiler/rustc_ty_utils/src/layout.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use hir::def_id::DefId;
55
use rustc_abi::Integer::{I8, I32};
66
use rustc_abi::Primitive::{self, Float, Int, Pointer};
77
use rustc_abi::{
8-
AbiAndPrefAlign, AddressSpace, Align, BackendRepr, FieldsShape, HasDataLayout,
9-
LayoutCalculatorError, LayoutData, Niche, ReprOptions, Scalar, Size, StructKind, TagEncoding,
10-
Variants, WrappingRange,
8+
AbiAndPrefAlign, AddressSpace, Align, BackendRepr, FIRST_VARIANT, FieldIdx, FieldsShape,
9+
HasDataLayout, Layout, LayoutCalculatorError, LayoutData, Niche, ReprOptions, Scalar, Size,
10+
StructKind, TagEncoding, VariantIdx, Variants, WrappingRange,
1111
};
1212
use rustc_index::bit_set::BitSet;
1313
use rustc_index::{IndexSlice, IndexVec};
@@ -24,7 +24,6 @@ use rustc_middle::ty::{
2424
use rustc_session::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
2525
use rustc_span::sym;
2626
use rustc_span::symbol::Symbol;
27-
use rustc_target::abi::{FIRST_VARIANT, FieldIdx, Layout, VariantIdx};
2827
use tracing::{debug, instrument, trace};
2928
use {rustc_abi as abi, rustc_hir as hir};
3029

compiler/rustc_ty_utils/src/layout/invariant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::assert_matches::assert_matches;
22

3+
use rustc_abi::{BackendRepr, FieldsShape, Scalar, Size, Variants};
34
use rustc_middle::bug;
45
use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, TyAndLayout};
5-
use rustc_target::abi::*;
66

77
/// Enforce some basic invariants on layouts.
88
pub(super) fn partially_check_layout<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayout<'tcx>) {

0 commit comments

Comments
 (0)