From b895bf4fdce434f394dbe0f4c57d4d0952cd13d7 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 2 Nov 2024 19:32:52 -0700 Subject: [PATCH 01/11] compiler: Directly use rustc_abi in codegen --- compiler/rustc_codegen_llvm/src/abi.rs | 6 +++--- compiler/rustc_codegen_llvm/src/asm.rs | 2 +- compiler/rustc_codegen_llvm/src/builder.rs | 2 +- compiler/rustc_codegen_llvm/src/consts.rs | 6 +++--- compiler/rustc_codegen_llvm/src/context.rs | 2 +- compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs | 2 +- compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs | 2 +- .../src/debuginfo/metadata/enums/cpp_like.rs | 2 +- .../src/debuginfo/metadata/enums/mod.rs | 2 +- .../src/debuginfo/metadata/enums/native.rs | 2 +- .../src/debuginfo/metadata/type_map.rs | 2 +- compiler/rustc_codegen_llvm/src/debuginfo/mod.rs | 2 +- compiler/rustc_codegen_llvm/src/intrinsic.rs | 10 +++++----- compiler/rustc_codegen_llvm/src/llvm/mod.rs | 2 +- compiler/rustc_codegen_llvm/src/type_.rs | 4 ++-- compiler/rustc_codegen_llvm/src/va_arg.rs | 2 +- compiler/rustc_codegen_ssa/src/back/metadata.rs | 2 +- compiler/rustc_codegen_ssa/src/back/symbol_export.rs | 2 +- compiler/rustc_codegen_ssa/src/base.rs | 2 +- compiler/rustc_codegen_ssa/src/debuginfo/mod.rs | 2 +- compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs | 4 ++-- compiler/rustc_codegen_ssa/src/meth.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/block.rs | 7 +++---- compiler/rustc_codegen_ssa/src/mir/intrinsic.rs | 4 ++-- compiler/rustc_codegen_ssa/src/mir/mod.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/place.rs | 3 +-- compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/statement.rs | 2 +- compiler/rustc_codegen_ssa/src/size_of_val.rs | 2 +- compiler/rustc_codegen_ssa/src/traits/builder.rs | 2 +- compiler/rustc_codegen_ssa/src/traits/debuginfo.rs | 4 ++-- compiler/rustc_codegen_ssa/src/traits/intrinsic.rs | 2 +- compiler/rustc_codegen_ssa/src/traits/mod.rs | 2 +- compiler/rustc_codegen_ssa/src/traits/statics.rs | 2 +- compiler/rustc_codegen_ssa/src/traits/type_.rs | 4 ++-- 35 files changed, 50 insertions(+), 52 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index 855ca01061190..1d35138b01348 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -2,6 +2,7 @@ use std::cmp; use libc::c_uint; use rustc_abi as abi; +pub(crate) use rustc_abi::ExternAbi; use rustc_abi::Primitive::Int; use rustc_abi::{HasDataLayout, Size}; use rustc_codegen_ssa::MemFlags; @@ -13,9 +14,8 @@ use rustc_middle::ty::layout::LayoutOf; pub(crate) use rustc_middle::ty::layout::{WIDE_PTR_ADDR, WIDE_PTR_EXTRA}; use rustc_middle::{bug, ty}; use rustc_session::config; -pub(crate) use rustc_target::abi::call::*; +pub(crate) use rustc_target::callconv::*; use rustc_target::spec::SanitizerSet; -pub(crate) use rustc_target::spec::abi::Abi; use smallvec::SmallVec; use crate::attributes::llfn_attrs_from_instance; @@ -436,7 +436,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { i - 1 }; - let apply_range_attr = |idx: AttributePlace, scalar: rustc_target::abi::Scalar| { + let apply_range_attr = |idx: AttributePlace, scalar: rustc_abi::Scalar| { if cx.sess().opts.optimize != config::OptLevel::No && llvm_util::get_version() >= (19, 0, 0) && matches!(scalar.primitive(), Int(..)) diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index 53758967552d4..21df60a4a7b4d 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -1,6 +1,7 @@ use std::assert_matches::assert_matches; use libc::{c_char, c_uint}; +use rustc_abi::{BackendRepr, Float, Integer, Primitive, Scalar}; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_codegen_ssa::mir::operand::OperandValue; use rustc_codegen_ssa::traits::*; @@ -9,7 +10,6 @@ use rustc_middle::ty::Instance; use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::{bug, span_bug}; use rustc_span::{Pos, Span, Symbol, sym}; -use rustc_target::abi::*; use rustc_target::asm::*; use smallvec::SmallVec; use tracing::debug; diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 15883c91053e4..751b2235dc856 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -21,7 +21,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; use rustc_sanitizers::{cfi, kcfi}; use rustc_session::config::OptLevel; use rustc_span::Span; -use rustc_target::abi::call::FnAbi; +use rustc_target::callconv::FnAbi; use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target}; use smallvec::SmallVec; use tracing::{debug, instrument}; diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 21d996ef460c0..bed64686a23c5 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -1,5 +1,8 @@ use std::ops::Range; +use rustc_abi::{ + Align, AlignFromBytesError, HasDataLayout, Primitive, Scalar, Size, WrappingRange, +}; use rustc_codegen_ssa::common; use rustc_codegen_ssa::traits::*; use rustc_hir::def::DefKind; @@ -14,9 +17,6 @@ use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, Instance}; use rustc_middle::{bug, span_bug}; use rustc_session::config::Lto; -use rustc_target::abi::{ - Align, AlignFromBytesError, HasDataLayout, Primitive, Scalar, Size, WrappingRange, -}; use tracing::{debug, instrument, trace}; use crate::common::{AsCCharPtr, CodegenCx}; diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 03f4fb527a8c5..6838a6f977916 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -3,6 +3,7 @@ use std::cell::{Cell, RefCell}; use std::ffi::{CStr, c_uint}; use std::str; +use rustc_abi::{HasDataLayout, TargetDataLayout, VariantIdx}; use rustc_codegen_ssa::back::versioned_llvm_target; use rustc_codegen_ssa::base::{wants_msvc_seh, wants_wasm_eh}; use rustc_codegen_ssa::errors as ssa_errors; @@ -24,7 +25,6 @@ use rustc_session::config::{ }; use rustc_span::source_map::Spanned; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::abi::{HasDataLayout, TargetDataLayout, VariantIdx}; use rustc_target::spec::{HasTargetSpec, RelocModel, SmallDataThresholdSupport, Target, TlsModel}; use smallvec::SmallVec; diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs index e4ff50816b97c..aaba0684c1296 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs @@ -2,6 +2,7 @@ use std::cell::{OnceCell, RefCell}; use std::ffi::{CStr, CString}; use libc::c_uint; +use rustc_abi::Size; use rustc_codegen_ssa::traits::{ BuilderMethods, ConstCodegenMethods, CoverageInfoBuilderMethods, MiscCodegenMethods, }; @@ -10,7 +11,6 @@ use rustc_llvm::RustString; use rustc_middle::mir::coverage::CoverageKind; use rustc_middle::ty::Instance; use rustc_middle::ty::layout::HasTyCtxt; -use rustc_target::abi::Size; use tracing::{debug, instrument}; use crate::builder::Builder; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 0d1fd0163ebfd..151923a3bd288 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -5,6 +5,7 @@ use std::path::{Path, PathBuf}; use std::{iter, ptr}; use libc::{c_char, c_longlong, c_uint}; +use rustc_abi::{Align, Size}; use rustc_codegen_ssa::debuginfo::type_names::{VTableNameKind, cpp_like_debuginfo}; use rustc_codegen_ssa::traits::*; use rustc_hir::def::{CtorKind, DefKind}; @@ -19,7 +20,6 @@ use rustc_session::config::{self, DebugInfo, Lto}; use rustc_span::symbol::Symbol; use rustc_span::{DUMMY_SP, FileName, FileNameDisplayPreference, SourceFile, hygiene}; use rustc_symbol_mangling::typeid_for_trait_ref; -use rustc_target::abi::{Align, Size}; use rustc_target::spec::DebuginfoKind; use smallvec::smallvec; use tracing::{debug, instrument}; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs index 5385d3a9212ba..100b046cee21b 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs @@ -1,6 +1,7 @@ use std::borrow::Cow; use libc::c_uint; +use rustc_abi::{Align, Endian, Size, TagEncoding, VariantIdx, Variants}; use rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name; use rustc_codegen_ssa::debuginfo::{tag_base_type, wants_c_like_enum_debuginfo}; use rustc_codegen_ssa::traits::ConstCodegenMethods; @@ -8,7 +9,6 @@ use rustc_index::IndexVec; use rustc_middle::bug; use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; use rustc_middle::ty::{self, AdtDef, CoroutineArgs, CoroutineArgsExt, Ty}; -use rustc_target::abi::{Align, Endian, Size, TagEncoding, VariantIdx, Variants}; use smallvec::smallvec; use crate::common::{AsCCharPtr, CodegenCx}; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs index 4c848027b55ae..b3d4a6642a16c 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs @@ -1,5 +1,6 @@ use std::borrow::Cow; +use rustc_abi::{FieldIdx, TagEncoding, VariantIdx, Variants}; use rustc_codegen_ssa::debuginfo::type_names::{compute_debuginfo_type_name, cpp_like_debuginfo}; use rustc_codegen_ssa::debuginfo::{tag_base_type, wants_c_like_enum_debuginfo}; use rustc_hir::def::CtorKind; @@ -9,7 +10,6 @@ use rustc_middle::mir::CoroutineLayout; use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; use rustc_middle::ty::{self, AdtDef, CoroutineArgs, CoroutineArgsExt, Ty, VariantDef}; use rustc_span::Symbol; -use rustc_target::abi::{FieldIdx, TagEncoding, VariantIdx, Variants}; use super::type_map::{DINodeCreationResult, UniqueTypeId}; use super::{SmallVec, size_and_align_of}; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs index b7400c5aeb264..d4006691d377e 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs @@ -1,13 +1,13 @@ use std::borrow::Cow; use libc::c_uint; +use rustc_abi::{Size, TagEncoding, VariantIdx, Variants}; use rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name; use rustc_codegen_ssa::debuginfo::{tag_base_type, wants_c_like_enum_debuginfo}; use rustc_codegen_ssa::traits::ConstCodegenMethods; use rustc_middle::bug; use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; use rustc_middle::ty::{self}; -use rustc_target::abi::{Size, TagEncoding, VariantIdx, Variants}; use smallvec::smallvec; use crate::common::{AsCCharPtr, CodegenCx}; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs index d050dc9b40648..5120b63d173b3 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs @@ -1,12 +1,12 @@ use std::cell::RefCell; +use rustc_abi::{Align, Size, VariantIdx}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_macros::HashStable; use rustc_middle::bug; use rustc_middle::ty::{ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt}; -use rustc_target::abi::{Align, Size, VariantIdx}; use super::{SmallVec, UNKNOWN_LINE_NUMBER, unknown_file_metadata}; use crate::common::{AsCCharPtr, CodegenCx}; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index b6c20cdcf0cd4..9e1e5127e80f3 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -5,6 +5,7 @@ use std::ops::Range; use std::{iter, ptr}; use libc::c_uint; +use rustc_abi::Size; use rustc_codegen_ssa::debuginfo::type_names; use rustc_codegen_ssa::mir::debuginfo::VariableKind::*; use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind}; @@ -22,7 +23,6 @@ use rustc_span::symbol::Symbol; use rustc_span::{ BytePos, Pos, SourceFile, SourceFileAndLine, SourceFileHash, Span, StableSourceFileId, }; -use rustc_target::abi::Size; use smallvec::SmallVec; use tracing::debug; diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index c77e00aed9ac5..e9c687d75e359 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -1,6 +1,7 @@ use std::assert_matches::assert_matches; use std::cmp::Ordering; +use rustc_abi::{self as abi, Align, Float, HasDataLayout, Primitive, Size}; use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh, wants_wasm_eh}; use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; use rustc_codegen_ssa::errors::{ExpectedPointerMutability, InvalidMonomorphization}; @@ -13,11 +14,10 @@ use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf}; use rustc_middle::ty::{self, GenericArgsRef, Ty}; use rustc_middle::{bug, span_bug}; use rustc_span::{Span, Symbol, sym}; -use rustc_target::abi::{self, Align, Float, HasDataLayout, Primitive, Size}; use rustc_target::spec::{HasTargetSpec, PanicStrategy}; use tracing::debug; -use crate::abi::{Abi, FnAbi, FnAbiLlvmExt, LlvmType, PassMode}; +use crate::abi::{ExternAbi, FnAbi, FnAbiLlvmExt, LlvmType, PassMode}; use crate::builder::Builder; use crate::context::CodegenCx; use crate::llvm::{self, Metadata}; @@ -1094,7 +1094,7 @@ fn get_rust_try_fn<'ll, 'tcx>( tcx.types.unit, false, hir::Safety::Unsafe, - Abi::Rust, + ExternAbi::Rust, )), ); // `unsafe fn(*mut i8, *mut i8) -> ()` @@ -1105,7 +1105,7 @@ fn get_rust_try_fn<'ll, 'tcx>( tcx.types.unit, false, hir::Safety::Unsafe, - Abi::Rust, + ExternAbi::Rust, )), ); // `unsafe fn(unsafe fn(*mut i8) -> (), *mut i8, unsafe fn(*mut i8, *mut i8) -> ()) -> i32` @@ -1114,7 +1114,7 @@ fn get_rust_try_fn<'ll, 'tcx>( tcx.types.i32, false, hir::Safety::Unsafe, - Abi::Rust, + ExternAbi::Rust, )); let rust_try = gen_fn(cx, "__rust_try", rust_fn_sig, codegen); cx.rust_try_fn.set(Some(rust_try)); diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index 00a5cd3b8595f..3b0bf47366e2a 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -8,8 +8,8 @@ use std::str::FromStr; use std::string::FromUtf8Error; use libc::c_uint; +use rustc_abi::{Align, Size, WrappingRange}; use rustc_llvm::RustString; -use rustc_target::abi::{Align, Size, WrappingRange}; pub use self::AtomicRmwBinOp::*; pub use self::CallConv::*; diff --git a/compiler/rustc_codegen_llvm/src/type_.rs b/compiler/rustc_codegen_llvm/src/type_.rs index f1efc7a3dacb8..6aec078e0de34 100644 --- a/compiler/rustc_codegen_llvm/src/type_.rs +++ b/compiler/rustc_codegen_llvm/src/type_.rs @@ -1,14 +1,14 @@ use std::{fmt, ptr}; use libc::{c_char, c_uint}; +use rustc_abi::{AddressSpace, Align, Integer, Size}; use rustc_codegen_ssa::common::TypeKind; use rustc_codegen_ssa::traits::*; use rustc_data_structures::small_c_str::SmallCStr; use rustc_middle::bug; use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{self, Ty}; -use rustc_target::abi::call::{CastTarget, FnAbi, Reg}; -use rustc_target::abi::{AddressSpace, Align, Integer, Size}; +use rustc_target::callconv::{CastTarget, FnAbi, Reg}; use crate::abi::{FnAbiLlvmExt, LlvmType}; use crate::context::CodegenCx; diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index f12b94d5887ea..e4c3e748cb5df 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -1,9 +1,9 @@ +use rustc_abi::{Align, Endian, HasDataLayout, Size}; use rustc_codegen_ssa::common::IntPredicate; use rustc_codegen_ssa::mir::operand::OperandRef; use rustc_codegen_ssa::traits::{BaseTypeCodegenMethods, BuilderMethods, ConstCodegenMethods}; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf}; -use rustc_target::abi::{Align, Endian, HasDataLayout, Size}; use crate::builder::Builder; use crate::type_::Type; diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index a7d95d56784e5..dad21bb309f9c 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -11,6 +11,7 @@ use object::{ SectionFlags, SectionKind, SubArchitecture, SymbolFlags, SymbolKind, SymbolScope, elf, pe, xcoff, }; +use rustc_abi::Endian; use rustc_data_structures::memmap::Mmap; use rustc_data_structures::owned_slice::{OwnedSlice, try_slice_owned}; use rustc_metadata::EncodedMetadata; @@ -19,7 +20,6 @@ use rustc_metadata::fs::METADATA_FILENAME; use rustc_middle::bug; use rustc_session::Session; use rustc_span::sym; -use rustc_target::abi::Endian; use rustc_target::spec::{RelocModel, Target, ef_avr_arch}; use super::apple; diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index d9669453f5adc..850d36872dd57 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -548,7 +548,7 @@ pub(crate) fn linking_symbol_name_for_instance_in_crate<'tcx>( symbol: ExportedSymbol<'tcx>, instantiating_crate: CrateNum, ) -> String { - use rustc_target::abi::call::Conv; + use rustc_target::callconv::Conv; let mut undecorated = symbol_name_for_instance_in_crate(tcx, symbol, instantiating_crate); diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index cb4c9c078b197..ef95ab94062ee 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -3,6 +3,7 @@ use std::collections::BTreeSet; use std::time::{Duration, Instant}; use itertools::Itertools; +use rustc_abi::FIRST_VARIANT; use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, AllocatorKind, global_fn_name}; use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; @@ -26,7 +27,6 @@ use rustc_session::Session; use rustc_session::config::{self, CrateType, EntryFnType, OptLevel, OutputType}; use rustc_span::symbol::sym; use rustc_span::{DUMMY_SP, Symbol}; -use rustc_target::abi::FIRST_VARIANT; use rustc_trait_selection::infer::at::ToTrace; use rustc_trait_selection::infer::{BoundRegionConversionTime, TyCtxtInferExt}; use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt}; diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs b/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs index bfd1b94c7903f..88d36b19da432 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs @@ -1,7 +1,7 @@ +use rustc_abi::{Integer, Primitive, Size, TagEncoding, Variants}; use rustc_middle::bug; use rustc_middle::ty::layout::{IntegerExt, PrimitiveExt, TyAndLayout}; use rustc_middle::ty::{self, Ty, TyCtxt}; -use rustc_target::abi::{Integer, Primitive, Size, TagEncoding, Variants}; // FIXME(eddyb) find a place for this (or a way to replace it). pub mod type_names; diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index 1e5b4f3433d6c..27bc58516c08d 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -13,6 +13,7 @@ use std::fmt::Write; +use rustc_abi::Integer; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; use rustc_hir::def_id::DefId; @@ -23,7 +24,6 @@ use rustc_middle::ty::layout::{IntegerExt, TyAndLayout}; use rustc_middle::ty::{ self, ExistentialProjection, GenericArgKind, GenericArgsRef, ParamEnv, Ty, TyCtxt, }; -use rustc_target::abi::Integer; use smallvec::SmallVec; use crate::debuginfo::wants_c_like_enum_debuginfo; @@ -364,7 +364,7 @@ fn push_debuginfo_type_name<'tcx>( } else { output.push_str(sig.safety.prefix_str()); - if sig.abi != rustc_target::spec::abi::Abi::Rust { + if sig.abi != rustc_abi::ExternAbi::Rust { output.push_str("extern \""); output.push_str(sig.abi.name()); output.push_str("\" "); diff --git a/compiler/rustc_codegen_ssa/src/meth.rs b/compiler/rustc_codegen_ssa/src/meth.rs index 7eb0ecd12ffec..64cd4c38937e7 100644 --- a/compiler/rustc_codegen_ssa/src/meth.rs +++ b/compiler/rustc_codegen_ssa/src/meth.rs @@ -2,7 +2,7 @@ use rustc_middle::bug; use rustc_middle::ty::{self, GenericArgKind, Ty}; use rustc_session::config::Lto; use rustc_symbol_mangling::typeid_for_trait_ref; -use rustc_target::abi::call::FnAbi; +use rustc_target::callconv::FnAbi; use tracing::{debug, instrument}; use crate::traits::*; diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 283740fa66438..027d80350e49d 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -1,5 +1,6 @@ use std::cmp; +use rustc_abi::{self as abi, ExternAbi, HasDataLayout, WrappingRange}; use rustc_ast as ast; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_hir::lang_items::LangItem; @@ -13,9 +14,7 @@ use rustc_middle::{bug, span_bug}; use rustc_session::config::OptLevel; use rustc_span::source_map::Spanned; use rustc_span::{Span, sym}; -use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode, Reg}; -use rustc_target::abi::{self, HasDataLayout, WrappingRange}; -use rustc_target::spec::abi::Abi; +use rustc_target::callconv::{ArgAbi, FnAbi, PassMode, Reg}; use tracing::{debug, info}; use super::operand::OperandRef; @@ -977,7 +976,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { }); // Split the rust-call tupled arguments off. - let (first_args, untuple) = if abi == Abi::RustCall && !args.is_empty() { + let (first_args, untuple) = if abi == ExternAbi::RustCall && !args.is_empty() { let (tup, args) = args.split_last().unwrap(); (args, Some(tup)) } else { diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs index 32cc78187b9eb..c9e38bb80c2ca 100644 --- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs @@ -1,9 +1,9 @@ +use rustc_abi::WrappingRange; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::{bug, span_bug}; use rustc_session::config::OptLevel; use rustc_span::{Span, sym}; -use rustc_target::abi::WrappingRange; -use rustc_target::abi::call::{FnAbi, PassMode}; +use rustc_target::callconv::{FnAbi, PassMode}; use super::FunctionCx; use super::operand::OperandRef; diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index 8bd172a9ce6d3..20fd08923ecd9 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -7,7 +7,7 @@ use rustc_middle::mir::{UnwindTerminateReason, traversal}; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, TyAndLayout}; use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; use rustc_middle::{bug, mir, span_bug}; -use rustc_target::abi::call::{FnAbi, PassMode}; +use rustc_target::callconv::{FnAbi, PassMode}; use tracing::{debug, instrument}; use crate::base; diff --git a/compiler/rustc_codegen_ssa/src/mir/place.rs b/compiler/rustc_codegen_ssa/src/mir/place.rs index 15c8e53446145..b8fa8c0351b1e 100644 --- a/compiler/rustc_codegen_ssa/src/mir/place.rs +++ b/compiler/rustc_codegen_ssa/src/mir/place.rs @@ -1,10 +1,9 @@ use rustc_abi::Primitive::{Int, Pointer}; -use rustc_abi::{Align, FieldsShape, Size, TagEncoding, Variants}; +use rustc_abi::{Align, FieldsShape, Size, TagEncoding, VariantIdx, Variants}; use rustc_middle::mir::tcx::PlaceTy; use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout}; use rustc_middle::ty::{self, Ty}; use rustc_middle::{bug, mir}; -use rustc_target::abi::VariantIdx; use tracing::{debug, instrument}; use super::operand::OperandValue; diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index 86cf0f9614d3e..0e1cd662f9188 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -1,13 +1,13 @@ use std::assert_matches::assert_matches; use arrayvec::ArrayVec; +use rustc_abi::{self as abi, FIRST_VARIANT, FieldIdx}; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout}; use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; use rustc_middle::{bug, mir, span_bug}; use rustc_session::config::OptLevel; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::abi::{self, FIRST_VARIANT, FieldIdx}; use tracing::{debug, instrument}; use super::operand::{OperandRef, OperandValue}; diff --git a/compiler/rustc_codegen_ssa/src/mir/statement.rs b/compiler/rustc_codegen_ssa/src/mir/statement.rs index 6338d16c897f6..1681ea1de5fb6 100644 --- a/compiler/rustc_codegen_ssa/src/mir/statement.rs +++ b/compiler/rustc_codegen_ssa/src/mir/statement.rs @@ -78,7 +78,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let count = self.codegen_operand(bx, count).immediate(); let pointee_layout = dst_val .layout - .pointee_info_at(bx, rustc_target::abi::Size::ZERO) + .pointee_info_at(bx, rustc_abi::Size::ZERO) .expect("Expected pointer"); let bytes = bx.mul(count, bx.const_usize(pointee_layout.size.bytes())); diff --git a/compiler/rustc_codegen_ssa/src/size_of_val.rs b/compiler/rustc_codegen_ssa/src/size_of_val.rs index 827b939217e82..71a2f916db5a5 100644 --- a/compiler/rustc_codegen_ssa/src/size_of_val.rs +++ b/compiler/rustc_codegen_ssa/src/size_of_val.rs @@ -1,10 +1,10 @@ //! Computing the size and alignment of a value. +use rustc_abi::WrappingRange; use rustc_hir::LangItem; use rustc_middle::bug; use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths}; use rustc_middle::ty::{self, Ty}; -use rustc_target::abi::WrappingRange; use tracing::{debug, trace}; use crate::common::IntPredicate; diff --git a/compiler/rustc_codegen_ssa/src/traits/builder.rs b/compiler/rustc_codegen_ssa/src/traits/builder.rs index 768a0439ab51b..74cd522a30ffd 100644 --- a/compiler/rustc_codegen_ssa/src/traits/builder.rs +++ b/compiler/rustc_codegen_ssa/src/traits/builder.rs @@ -7,7 +7,7 @@ use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout}; use rustc_middle::ty::{Instance, Ty}; use rustc_session::config::OptLevel; use rustc_span::Span; -use rustc_target::abi::call::FnAbi; +use rustc_target::callconv::FnAbi; use super::abi::AbiBuilderMethods; use super::asm::AsmBuilderMethods; diff --git a/compiler/rustc_codegen_ssa/src/traits/debuginfo.rs b/compiler/rustc_codegen_ssa/src/traits/debuginfo.rs index c26d4532d0f14..670433a6c3308 100644 --- a/compiler/rustc_codegen_ssa/src/traits/debuginfo.rs +++ b/compiler/rustc_codegen_ssa/src/traits/debuginfo.rs @@ -1,10 +1,10 @@ use std::ops::Range; +use rustc_abi::Size; use rustc_middle::mir; use rustc_middle::ty::{Instance, PolyExistentialTraitRef, Ty}; use rustc_span::{SourceFile, Span, Symbol}; -use rustc_target::abi::Size; -use rustc_target::abi::call::FnAbi; +use rustc_target::callconv::FnAbi; use super::BackendTypes; use crate::mir::debuginfo::{FunctionDebugContext, VariableKind}; diff --git a/compiler/rustc_codegen_ssa/src/traits/intrinsic.rs b/compiler/rustc_codegen_ssa/src/traits/intrinsic.rs index 5b9274b48248c..88cf8dbf0c5c8 100644 --- a/compiler/rustc_codegen_ssa/src/traits/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/traits/intrinsic.rs @@ -1,6 +1,6 @@ use rustc_middle::ty::{self, Ty}; use rustc_span::Span; -use rustc_target::abi::call::FnAbi; +use rustc_target::callconv::FnAbi; use super::BackendTypes; use crate::mir::operand::OperandRef; diff --git a/compiler/rustc_codegen_ssa/src/traits/mod.rs b/compiler/rustc_codegen_ssa/src/traits/mod.rs index 800470286bc94..90fcfbe4da7a1 100644 --- a/compiler/rustc_codegen_ssa/src/traits/mod.rs +++ b/compiler/rustc_codegen_ssa/src/traits/mod.rs @@ -29,7 +29,7 @@ use std::fmt; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout}; -use rustc_target::abi::call::FnAbi; +use rustc_target::callconv::FnAbi; pub use self::abi::AbiBuilderMethods; pub use self::asm::{ diff --git a/compiler/rustc_codegen_ssa/src/traits/statics.rs b/compiler/rustc_codegen_ssa/src/traits/statics.rs index c10733fb0ed54..ece0ea1b2ea85 100644 --- a/compiler/rustc_codegen_ssa/src/traits/statics.rs +++ b/compiler/rustc_codegen_ssa/src/traits/statics.rs @@ -1,5 +1,5 @@ +use rustc_abi::Align; use rustc_hir::def_id::DefId; -use rustc_target::abi::Align; use super::BackendTypes; diff --git a/compiler/rustc_codegen_ssa/src/traits/type_.rs b/compiler/rustc_codegen_ssa/src/traits/type_.rs index f862434c8ef78..44ba226214948 100644 --- a/compiler/rustc_codegen_ssa/src/traits/type_.rs +++ b/compiler/rustc_codegen_ssa/src/traits/type_.rs @@ -1,8 +1,8 @@ +use rustc_abi::{AddressSpace, Float, Integer}; use rustc_middle::bug; use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout}; use rustc_middle::ty::{self, Ty}; -use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg}; -use rustc_target::abi::{AddressSpace, Float, Integer}; +use rustc_target::callconv::{ArgAbi, CastTarget, FnAbi, Reg}; use super::BackendTypes; use super::misc::MiscCodegenMethods; From bbd18e29da5d06db8e2c4d6c8111118aa7efec24 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 2 Nov 2024 19:32:52 -0700 Subject: [PATCH 02/11] compiler: Directly use rustc_abi in const_eval --- .../src/const_eval/dummy_machine.rs | 2 +- compiler/rustc_const_eval/src/const_eval/machine.rs | 5 ++--- compiler/rustc_const_eval/src/const_eval/mod.rs | 2 +- compiler/rustc_const_eval/src/errors.rs | 4 ++-- compiler/rustc_const_eval/src/interpret/call.rs | 13 ++++++------- compiler/rustc_const_eval/src/interpret/cast.rs | 2 +- .../rustc_const_eval/src/interpret/discriminant.rs | 2 +- .../rustc_const_eval/src/interpret/eval_context.rs | 4 ++-- .../rustc_const_eval/src/interpret/intrinsics.rs | 2 +- compiler/rustc_const_eval/src/interpret/machine.rs | 9 ++++----- compiler/rustc_const_eval/src/interpret/memory.rs | 2 +- compiler/rustc_const_eval/src/interpret/operator.rs | 2 +- .../rustc_const_eval/src/interpret/projection.rs | 2 +- compiler/rustc_const_eval/src/interpret/step.rs | 4 ++-- compiler/rustc_const_eval/src/interpret/traits.rs | 2 +- compiler/rustc_const_eval/src/interpret/visitor.rs | 2 +- compiler/rustc_const_eval/src/util/alignment.rs | 2 +- 17 files changed, 29 insertions(+), 32 deletions(-) diff --git a/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs b/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs index bc2661c4fc71f..e49d702127de5 100644 --- a/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs @@ -86,7 +86,7 @@ impl<'tcx> interpret::Machine<'tcx> for DummyMachine { fn find_mir_or_eval_fn( _ecx: &mut InterpCx<'tcx, Self>, _instance: ty::Instance<'tcx>, - _abi: rustc_target::spec::abi::Abi, + _abi: rustc_abi::ExternAbi, _args: &[interpret::FnArg<'tcx, Self::Provenance>], _destination: &interpret::MPlaceTy<'tcx, Self::Provenance>, _target: Option, diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 5f0bc8539ee0b..fa83d9b9d0c5b 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -3,6 +3,7 @@ use std::fmt; use std::hash::Hash; use std::ops::ControlFlow; +use rustc_abi::{Align, ExternAbi, Size}; use rustc_ast::Mutability; use rustc_data_structures::fx::{FxHashMap, FxIndexMap, IndexEntry}; use rustc_hir::def_id::{DefId, LocalDefId}; @@ -14,8 +15,6 @@ use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::{bug, mir}; use rustc_span::Span; use rustc_span::symbol::{Symbol, sym}; -use rustc_target::abi::{Align, Size}; -use rustc_target::spec::abi::Abi as CallAbi; use tracing::debug; use super::error::*; @@ -411,7 +410,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> { fn find_mir_or_eval_fn( ecx: &mut InterpCx<'tcx, Self>, orig_instance: ty::Instance<'tcx>, - _abi: CallAbi, + _abi: ExternAbi, args: &[FnArg<'tcx>], dest: &MPlaceTy<'tcx>, ret: Option, diff --git a/compiler/rustc_const_eval/src/const_eval/mod.rs b/compiler/rustc_const_eval/src/const_eval/mod.rs index e2e4754a45c5e..d5012236c3452 100644 --- a/compiler/rustc_const_eval/src/const_eval/mod.rs +++ b/compiler/rustc_const_eval/src/const_eval/mod.rs @@ -1,9 +1,9 @@ // Not in interpret to make sure we do not use private implementation details +use rustc_abi::VariantIdx; use rustc_middle::query::{Key, TyCtxtAt}; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::{bug, mir}; -use rustc_target::abi::VariantIdx; use tracing::instrument; use crate::interpret::InterpCx; diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs index 38b87b7263414..14e8bebbb180b 100644 --- a/compiler/rustc_const_eval/src/errors.rs +++ b/compiler/rustc_const_eval/src/errors.rs @@ -2,6 +2,7 @@ use std::borrow::Cow; use std::fmt::Write; use either::Either; +use rustc_abi::WrappingRange; use rustc_errors::codes::*; use rustc_errors::{ Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, Level, @@ -15,8 +16,7 @@ use rustc_middle::mir::interpret::{ }; use rustc_middle::ty::{self, Mutability, Ty}; use rustc_span::{Span, Symbol}; -use rustc_target::abi::WrappingRange; -use rustc_target::abi::call::AdjustForForeignAbiError; +use rustc_target::callconv::AdjustForForeignAbiError; use crate::interpret::InternKind; diff --git a/compiler/rustc_const_eval/src/interpret/call.rs b/compiler/rustc_const_eval/src/interpret/call.rs index 1915bf75c95ad..71ec9c2ab19fc 100644 --- a/compiler/rustc_const_eval/src/interpret/call.rs +++ b/compiler/rustc_const_eval/src/interpret/call.rs @@ -4,13 +4,12 @@ use std::assert_matches::assert_matches; use std::borrow::Cow; use either::{Left, Right}; +use rustc_abi::{self as abi, ExternAbi, FieldIdx, Integer}; use rustc_middle::ty::layout::{FnAbiOf, IntegerExt, LayoutOf, TyAndLayout}; use rustc_middle::ty::{self, AdtDef, Instance, Ty}; use rustc_middle::{bug, mir, span_bug}; use rustc_span::sym; -use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode}; -use rustc_target::abi::{self, FieldIdx, Integer}; -use rustc_target::spec::abi::Abi; +use rustc_target::callconv::{ArgAbi, FnAbi, PassMode}; use tracing::{info, instrument, trace}; use super::{ @@ -488,7 +487,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { pub(super) fn init_fn_call( &mut self, fn_val: FnVal<'tcx, M::ExtraFnVal>, - (caller_abi, caller_fn_abi): (Abi, &FnAbi<'tcx, Ty<'tcx>>), + (caller_abi, caller_fn_abi): (ExternAbi, &FnAbi<'tcx, Ty<'tcx>>), args: &[FnArg<'tcx, M::Provenance>], with_caller_location: bool, destination: &MPlaceTy<'tcx, M::Provenance>, @@ -566,7 +565,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // Special handling for the closure ABI: untuple the last argument. let args: Cow<'_, [FnArg<'tcx, M::Provenance>]> = - if caller_abi == Abi::RustCall && !args.is_empty() { + if caller_abi == ExternAbi::RustCall && !args.is_empty() { // Untuple let (untuple_arg, args) = args.split_last().unwrap(); trace!("init_fn_call: Will pass last argument by untupling"); @@ -732,7 +731,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { pub(super) fn init_fn_tail_call( &mut self, fn_val: FnVal<'tcx, M::ExtraFnVal>, - (caller_abi, caller_fn_abi): (Abi, &FnAbi<'tcx, Ty<'tcx>>), + (caller_abi, caller_fn_abi): (ExternAbi, &FnAbi<'tcx, Ty<'tcx>>), args: &[FnArg<'tcx, M::Provenance>], with_caller_location: bool, ) -> InterpResult<'tcx> { @@ -817,7 +816,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { self.init_fn_call( FnVal::Instance(instance), - (Abi::Rust, fn_abi), + (ExternAbi::Rust, fn_abi), &[FnArg::Copy(arg.into())], false, &ret, diff --git a/compiler/rustc_const_eval/src/interpret/cast.rs b/compiler/rustc_const_eval/src/interpret/cast.rs index 60d5e904bd9ab..49559059265f3 100644 --- a/compiler/rustc_const_eval/src/interpret/cast.rs +++ b/compiler/rustc_const_eval/src/interpret/cast.rs @@ -1,5 +1,6 @@ use std::assert_matches::assert_matches; +use rustc_abi::Integer; use rustc_apfloat::ieee::{Double, Half, Quad, Single}; use rustc_apfloat::{Float, FloatConvert}; use rustc_middle::mir::CastKind; @@ -8,7 +9,6 @@ use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::layout::{IntegerExt, LayoutOf, TyAndLayout}; use rustc_middle::ty::{self, FloatTy, Ty}; use rustc_middle::{bug, span_bug}; -use rustc_target::abi::Integer; use rustc_type_ir::TyKind::*; use tracing::trace; diff --git a/compiler/rustc_const_eval/src/interpret/discriminant.rs b/compiler/rustc_const_eval/src/interpret/discriminant.rs index bb4ac9556ea88..f94d0cbb42bec 100644 --- a/compiler/rustc_const_eval/src/interpret/discriminant.rs +++ b/compiler/rustc_const_eval/src/interpret/discriminant.rs @@ -1,9 +1,9 @@ //! Functions for reading and writing discriminants of multi-variant layouts (enums and coroutines). +use rustc_abi::{self as abi, TagEncoding, VariantIdx, Variants}; use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt}; use rustc_middle::ty::{self, CoroutineArgsExt, ScalarInt, Ty}; use rustc_middle::{mir, span_bug}; -use rustc_target::abi::{self, TagEncoding, VariantIdx, Variants}; use tracing::{instrument, trace}; use super::{ diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 9043bd3e28e7d..ff6d5b28b3bc4 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -1,4 +1,5 @@ use either::{Left, Right}; +use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout}; use rustc_errors::DiagCtxtHandle; use rustc_hir::def_id::DefId; use rustc_infer::infer::TyCtxtInferExt; @@ -15,8 +16,7 @@ use rustc_middle::ty::{ use rustc_middle::{mir, span_bug}; use rustc_session::Limit; use rustc_span::Span; -use rustc_target::abi::call::FnAbi; -use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout}; +use rustc_target::callconv::FnAbi; use rustc_trait_selection::traits::ObligationCtxt; use tracing::{debug, instrument, trace}; diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 80e14ee887cb1..c7a56a80e81e4 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -4,6 +4,7 @@ use std::assert_matches::assert_matches; +use rustc_abi::Size; use rustc_apfloat::ieee::{Double, Half, Quad, Single}; use rustc_hir::def_id::DefId; use rustc_middle::mir::{self, BinOp, ConstValue, NonDivergingIntrinsic}; @@ -11,7 +12,6 @@ use rustc_middle::ty::layout::{LayoutOf as _, TyAndLayout, ValidityRequirement}; use rustc_middle::ty::{GenericArgsRef, Ty, TyCtxt}; use rustc_middle::{bug, ty}; use rustc_span::symbol::{Symbol, sym}; -use rustc_target::abi::Size; use tracing::trace; use super::memory::MemoryKind; diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index 89d49ba046e7d..dbe09d55b2d3c 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -6,6 +6,7 @@ use std::borrow::{Borrow, Cow}; use std::fmt::Debug; use std::hash::Hash; +use rustc_abi::{Align, ExternAbi, Size}; use rustc_apfloat::{Float, FloatConvert}; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_middle::query::TyCtxtAt; @@ -14,8 +15,6 @@ use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::{mir, ty}; use rustc_span::Span; use rustc_span::def_id::DefId; -use rustc_target::abi::{Align, Size}; -use rustc_target::spec::abi::Abi as CallAbi; use super::{ AllocBytes, AllocId, AllocKind, AllocRange, Allocation, CTFE_ALLOC_SALT, ConstAllocation, @@ -202,7 +201,7 @@ pub trait Machine<'tcx>: Sized { fn find_mir_or_eval_fn( ecx: &mut InterpCx<'tcx, Self>, instance: ty::Instance<'tcx>, - abi: CallAbi, + abi: ExternAbi, args: &[FnArg<'tcx, Self::Provenance>], destination: &MPlaceTy<'tcx, Self::Provenance>, target: Option, @@ -214,7 +213,7 @@ pub trait Machine<'tcx>: Sized { fn call_extra_fn( ecx: &mut InterpCx<'tcx, Self>, fn_val: Self::ExtraFnVal, - abi: CallAbi, + abi: ExternAbi, args: &[FnArg<'tcx, Self::Provenance>], destination: &MPlaceTy<'tcx, Self::Provenance>, target: Option, @@ -653,7 +652,7 @@ pub macro compile_time_machine(<$tcx: lifetime>) { fn call_extra_fn( _ecx: &mut InterpCx<$tcx, Self>, fn_val: !, - _abi: CallAbi, + _abi: ExternAbi, _args: &[FnArg<$tcx>], _destination: &MPlaceTy<$tcx, Self::Provenance>, _target: Option, diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 7700eb792effb..1ad8ffa4b53fc 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -11,13 +11,13 @@ use std::borrow::{Borrow, Cow}; use std::collections::VecDeque; use std::{fmt, mem, ptr}; +use rustc_abi::{Align, HasDataLayout, Size}; use rustc_ast::Mutability; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_hir::def::DefKind; use rustc_middle::bug; use rustc_middle::mir::display_allocation; use rustc_middle::ty::{self, Instance, ParamEnv, Ty, TyCtxt}; -use rustc_target::abi::{Align, HasDataLayout, Size}; use tracing::{debug, instrument, trace}; use super::{ diff --git a/compiler/rustc_const_eval/src/interpret/operator.rs b/compiler/rustc_const_eval/src/interpret/operator.rs index cf280e0c1aeb7..fbc85d379538a 100644 --- a/compiler/rustc_const_eval/src/interpret/operator.rs +++ b/compiler/rustc_const_eval/src/interpret/operator.rs @@ -1,4 +1,5 @@ use either::Either; +use rustc_abi::Size; use rustc_apfloat::{Float, FloatConvert}; use rustc_middle::mir::NullOp; use rustc_middle::mir::interpret::{InterpResult, PointerArithmetic, Scalar}; @@ -6,7 +7,6 @@ use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; use rustc_middle::ty::{self, FloatTy, ScalarInt, Ty}; use rustc_middle::{bug, mir, span_bug}; use rustc_span::symbol::sym; -use rustc_target::abi::Size; use tracing::trace; use super::{ImmTy, InterpCx, Machine, MemPlaceMeta, interp_ok, throw_ub}; diff --git a/compiler/rustc_const_eval/src/interpret/projection.rs b/compiler/rustc_const_eval/src/interpret/projection.rs index e636090a324ce..65a93784e2cc7 100644 --- a/compiler/rustc_const_eval/src/interpret/projection.rs +++ b/compiler/rustc_const_eval/src/interpret/projection.rs @@ -10,10 +10,10 @@ use std::marker::PhantomData; use std::ops::Range; +use rustc_abi::{self as abi, Size, VariantIdx}; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; use rustc_middle::{bug, mir, span_bug, ty}; -use rustc_target::abi::{self, Size, VariantIdx}; use tracing::{debug, instrument}; use super::{ diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index aa7529556754b..18cff2c5e0f3d 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -3,13 +3,13 @@ //! The main entry point is the `step` method. use either::Either; +use rustc_abi::{FIRST_VARIANT, FieldIdx}; use rustc_index::IndexSlice; use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::{self, Instance, Ty}; use rustc_middle::{bug, mir, span_bug}; use rustc_span::source_map::Spanned; -use rustc_target::abi::call::FnAbi; -use rustc_target::abi::{FIRST_VARIANT, FieldIdx}; +use rustc_target::callconv::FnAbi; use tracing::{info, instrument, trace}; use super::{ diff --git a/compiler/rustc_const_eval/src/interpret/traits.rs b/compiler/rustc_const_eval/src/interpret/traits.rs index da7d6853c0ea7..af8d618b6b5e5 100644 --- a/compiler/rustc_const_eval/src/interpret/traits.rs +++ b/compiler/rustc_const_eval/src/interpret/traits.rs @@ -1,7 +1,7 @@ +use rustc_abi::{Align, Size}; use rustc_middle::mir::interpret::{InterpResult, Pointer}; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, ExistentialPredicateStableCmpExt, Ty, TyCtxt, VtblEntry}; -use rustc_target::abi::{Align, Size}; use tracing::trace; use super::util::ensure_monomorphic_enough; diff --git a/compiler/rustc_const_eval/src/interpret/visitor.rs b/compiler/rustc_const_eval/src/interpret/visitor.rs index 647917dbb67ed..76ab0bb544f05 100644 --- a/compiler/rustc_const_eval/src/interpret/visitor.rs +++ b/compiler/rustc_const_eval/src/interpret/visitor.rs @@ -3,11 +3,11 @@ use std::num::NonZero; +use rustc_abi::{FieldIdx, FieldsShape, VariantIdx, Variants}; use rustc_index::IndexVec; use rustc_middle::mir::interpret::InterpResult; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, Ty}; -use rustc_target::abi::{FieldIdx, FieldsShape, VariantIdx, Variants}; use tracing::trace; use super::{InterpCx, MPlaceTy, Machine, Projectable, interp_ok, throw_inval}; diff --git a/compiler/rustc_const_eval/src/util/alignment.rs b/compiler/rustc_const_eval/src/util/alignment.rs index 5ad55968398eb..6fa7d3692296e 100644 --- a/compiler/rustc_const_eval/src/util/alignment.rs +++ b/compiler/rustc_const_eval/src/util/alignment.rs @@ -1,6 +1,6 @@ +use rustc_abi::Align; use rustc_middle::mir::*; use rustc_middle::ty::{self, TyCtxt}; -use rustc_target::abi::Align; use tracing::debug; /// Returns `true` if this place is allowed to be less aligned From 89ec8c2cfe87d01a23b83fdf3a6269ca2d3107aa Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 2 Nov 2024 19:32:56 -0700 Subject: [PATCH 03/11] compiler: Directly use rustc_abi in hir_{analysis,typeck} --- compiler/rustc_hir_analysis/src/check/check.rs | 8 ++++---- compiler/rustc_hir_analysis/src/check/entry.rs | 6 +++--- compiler/rustc_hir_analysis/src/check/intrinsic.rs | 8 ++++---- compiler/rustc_hir_analysis/src/check/mod.rs | 7 +++---- compiler/rustc_hir_analysis/src/check/wfcheck.rs | 4 ++-- compiler/rustc_hir_analysis/src/collect.rs | 10 +++++----- .../rustc_hir_analysis/src/hir_ty_lowering/cmse.rs | 14 +++++++------- .../rustc_hir_analysis/src/hir_ty_lowering/mod.rs | 3 +-- compiler/rustc_hir_analysis/src/lib.rs | 11 ++++++++--- compiler/rustc_hir_typeck/src/callee.rs | 3 +-- compiler/rustc_hir_typeck/src/check.rs | 8 ++++---- compiler/rustc_hir_typeck/src/closure.rs | 14 +++++++------- compiler/rustc_hir_typeck/src/coercion.rs | 4 ++-- compiler/rustc_hir_typeck/src/expr.rs | 2 +- compiler/rustc_hir_typeck/src/expr_use_visitor.rs | 2 +- compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs | 2 +- compiler/rustc_hir_typeck/src/intrinsicck.rs | 2 +- compiler/rustc_hir_typeck/src/pat.rs | 2 +- compiler/rustc_hir_typeck/src/upvar.rs | 4 ++-- 19 files changed, 58 insertions(+), 56 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 476814c261eba..50ea8018e7601 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -37,7 +37,7 @@ use super::compare_impl_item::{check_type_bounds, compare_impl_method, compare_i use super::*; use crate::check::intrinsicck::InlineAsmCtxt; -pub fn check_abi(tcx: TyCtxt<'_>, span: Span, abi: Abi) { +pub fn check_abi(tcx: TyCtxt<'_>, span: Span, abi: ExternAbi) { if !tcx.sess.target.is_abi_supported(abi) { struct_span_code_err!( tcx.dcx(), @@ -49,7 +49,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, span: Span, abi: Abi) { } } -pub fn check_abi_fn_ptr(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) { +pub fn check_abi_fn_ptr(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: ExternAbi) { if !tcx.sess.target.is_abi_supported(abi) { tcx.node_span_lint(UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS, hir_id, span, |lint| { lint.primary_message(format!( @@ -628,7 +628,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) { def_id, tcx.def_ident_span(def_id).unwrap(), i.name, - Abi::Rust, + ExternAbi::Rust, ) } // Everything else is checked entirely within check_item_body @@ -699,7 +699,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) { check_abi(tcx, it.span, abi); match abi { - Abi::RustIntrinsic => { + ExternAbi::RustIntrinsic => { for item in items { intrinsic::check_intrinsic_type( tcx, diff --git a/compiler/rustc_hir_analysis/src/check/entry.rs b/compiler/rustc_hir_analysis/src/check/entry.rs index 0beb1f98d56de..f3dd13c84b958 100644 --- a/compiler/rustc_hir_analysis/src/check/entry.rs +++ b/compiler/rustc_hir_analysis/src/check/entry.rs @@ -1,5 +1,6 @@ use std::ops::Not; +use rustc_abi::ExternAbi; use rustc_hir as hir; use rustc_hir::Node; use rustc_infer::infer::TyCtxtInferExt; @@ -9,7 +10,6 @@ use rustc_session::config::EntryFnType; use rustc_span::Span; use rustc_span::def_id::{CRATE_DEF_ID, DefId, LocalDefId}; use rustc_span::symbol::sym; -use rustc_target::spec::abi::Abi; use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode}; @@ -158,7 +158,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { expected_return_type, false, hir::Safety::Safe, - Abi::Rust, + ExternAbi::Rust, )); if check_function_signature( @@ -254,7 +254,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) { tcx.types.isize, false, hir::Safety::Safe, - Abi::Rust, + ExternAbi::Rust, )); let _ = check_function_signature( diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index c75bdcec38808..680e12b02fc5e 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -1,6 +1,7 @@ //! Type-checking for the rust-intrinsic and platform-intrinsic //! intrinsics that the compiler exposes. +use rustc_abi::ExternAbi; use rustc_errors::codes::*; use rustc_errors::{DiagMessage, struct_span_code_err}; use rustc_hir as hir; @@ -10,7 +11,6 @@ use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::sym; use rustc_span::{Span, Symbol}; -use rustc_target::spec::abi::Abi; use crate::check::check_function_signature; use crate::errors::{ @@ -163,7 +163,7 @@ pub fn check_intrinsic_type( intrinsic_id: LocalDefId, span: Span, intrinsic_name: Symbol, - abi: Abi, + abi: ExternAbi, ) { let generics = tcx.generics_of(intrinsic_id); let param = |n| { @@ -533,14 +533,14 @@ pub fn check_intrinsic_type( tcx.types.unit, false, hir::Safety::Safe, - Abi::Rust, + ExternAbi::Rust, )); let catch_fn_ty = ty::Binder::dummy(tcx.mk_fn_sig( [mut_u8, mut_u8], tcx.types.unit, false, hir::Safety::Safe, - Abi::Rust, + ExternAbi::Rust, )); ( 0, diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index e9eea36a0e66c..375cbfd1c4fb8 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -74,7 +74,7 @@ pub mod wfcheck; use std::num::NonZero; pub use check::{check_abi, check_abi_fn_ptr}; -use rustc_abi::VariantIdx; +use rustc_abi::{ExternAbi, VariantIdx}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_errors::{Diag, ErrorGuaranteed, pluralize, struct_span_code_err}; use rustc_hir::def_id::{DefId, LocalDefId}; @@ -91,7 +91,6 @@ use rustc_session::parse::feature_err; use rustc_span::def_id::CRATE_DEF_ID; use rustc_span::symbol::{Ident, kw, sym}; use rustc_span::{BytePos, DUMMY_SP, Span, Symbol}; -use rustc_target::spec::abi::Abi; use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::error_reporting::infer::ObligationCauseExt as _; use rustc_trait_selection::error_reporting::traits::suggestions::ReturnsVisitor; @@ -142,8 +141,8 @@ fn get_owner_return_paths( /// Forbid defining intrinsics in Rust code, /// as they must always be defined by the compiler. // FIXME: Move this to a more appropriate place. -pub fn forbid_intrinsic_abi(tcx: TyCtxt<'_>, sp: Span, abi: Abi) { - if let Abi::RustIntrinsic = abi { +pub fn forbid_intrinsic_abi(tcx: TyCtxt<'_>, sp: Span, abi: ExternAbi) { + if let ExternAbi::RustIntrinsic = abi { tcx.dcx().span_err(sp, "intrinsic must be in `extern \"rust-intrinsic\" { ... }` block"); } } diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index d01c3784adec5..bf7cc71384159 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -2,6 +2,7 @@ use std::cell::LazyCell; use std::ops::{ControlFlow, Deref}; use hir::intravisit::{self, Visitor}; +use rustc_abi::ExternAbi; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_errors::codes::*; use rustc_errors::{Applicability, ErrorGuaranteed, pluralize, struct_span_code_err}; @@ -23,7 +24,6 @@ use rustc_middle::{bug, span_bug}; use rustc_session::parse::feature_err; use rustc_span::symbol::{Ident, sym}; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::spec::abi::Abi; use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::regions::InferCtxtRegionExt; use rustc_trait_selection::traits::misc::{ @@ -1644,7 +1644,7 @@ fn check_fn_or_method<'tcx>( check_where_clauses(wfcx, span, def_id); - if sig.abi == Abi::RustCall { + if sig.abi == ExternAbi::RustCall { let span = tcx.def_span(def_id); let has_implicit_self = hir_decl.implicit_self != hir::ImplicitSelfKind::None; let mut inputs = sig.inputs().iter().skip(if has_implicit_self { 1 } else { 0 }); diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 3f6198dbd3196..e89c7fc9cb787 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -18,6 +18,7 @@ use std::cell::Cell; use std::iter; use std::ops::Bound; +use rustc_abi::ExternAbi; use rustc_ast::Recovered; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; @@ -38,7 +39,6 @@ use rustc_middle::ty::{self, AdtKind, Const, IsSuggestable, Ty, TyCtxt, TypingMo use rustc_middle::{bug, span_bug}; use rustc_span::symbol::{Ident, Symbol, kw, sym}; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::spec::abi; use rustc_trait_selection::error_reporting::traits::suggestions::NextTypeParamName; use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::traits::ObligationCtxt; @@ -1361,7 +1361,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_, ty::PolyFn (Bound::Unbounded, Bound::Unbounded) => hir::Safety::Safe, _ => hir::Safety::Unsafe, }; - ty::Binder::dummy(tcx.mk_fn_sig(inputs, ty, false, safety, abi::Abi::Rust)) + ty::Binder::dummy(tcx.mk_fn_sig(inputs, ty, false, safety, ExternAbi::Rust)) } Expr(&hir::Expr { kind: hir::ExprKind::Closure { .. }, .. }) => { @@ -1686,10 +1686,10 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, decl: &'tcx hir::FnDecl<'tcx>, - abi: abi::Abi, + abi: ExternAbi, safety: hir::Safety, ) -> ty::PolyFnSig<'tcx> { - let safety = if abi == abi::Abi::RustIntrinsic { + let safety = if abi == ExternAbi::RustIntrinsic { intrinsic_operation_unsafety(tcx, def_id) } else { safety @@ -1700,7 +1700,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( // Feature gate SIMD types in FFI, since I am not sure that the // ABIs are handled at all correctly. -huonw - if abi != abi::Abi::RustIntrinsic && !tcx.features().simd_ffi() { + if abi != ExternAbi::RustIntrinsic && !tcx.features().simd_ffi() { let check = |hir_ty: &hir::Ty<'_>, ty: Ty<'_>| { if ty.is_simd() { let snip = tcx diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs index 672dc8ddeda11..92f38a7dde051 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs @@ -1,9 +1,9 @@ +use rustc_abi::ExternAbi; use rustc_errors::{DiagCtxtHandle, E0781, struct_span_code_err}; use rustc_hir::{self as hir, HirId}; use rustc_middle::bug; use rustc_middle::ty::layout::LayoutError; use rustc_middle::ty::{self, ParamEnv, TyCtxt}; -use rustc_target::spec::abi; use crate::errors; @@ -14,13 +14,13 @@ pub(crate) fn validate_cmse_abi<'tcx>( tcx: TyCtxt<'tcx>, dcx: DiagCtxtHandle<'_>, hir_id: HirId, - abi: abi::Abi, + abi: ExternAbi, fn_sig: ty::PolyFnSig<'tcx>, ) { let abi_name = abi.name(); match abi { - abi::Abi::CCmseNonSecureCall => { + ExternAbi::CCmseNonSecureCall => { let hir_node = tcx.hir_node(hir_id); let hir::Node::Ty(hir::Ty { span: bare_fn_span, @@ -78,7 +78,7 @@ pub(crate) fn validate_cmse_abi<'tcx>( } }; } - abi::Abi::CCmseNonSecureEntry => { + ExternAbi::CCmseNonSecureEntry => { let hir_node = tcx.hir_node(hir_id); let Some(hir::FnSig { decl, span: fn_sig_span, .. }) = hir_node.fn_sig() else { // might happen when this ABI is used incorrectly. That will be handled elsewhere @@ -195,17 +195,17 @@ fn is_valid_cmse_output<'tcx>( Ok(ret_ty == tcx.types.i64 || ret_ty == tcx.types.u64 || ret_ty == tcx.types.f64) } -fn should_emit_generic_error<'tcx>(abi: abi::Abi, layout_err: &'tcx LayoutError<'tcx>) -> bool { +fn should_emit_generic_error<'tcx>(abi: ExternAbi, layout_err: &'tcx LayoutError<'tcx>) -> bool { use LayoutError::*; match layout_err { Unknown(ty) => { match abi { - abi::Abi::CCmseNonSecureCall => { + ExternAbi::CCmseNonSecureCall => { // prevent double reporting of this error !ty.is_impl_trait() } - abi::Abi::CCmseNonSecureEntry => true, + ExternAbi::CCmseNonSecureEntry => true, _ => bug!("invalid ABI: {abi}"), } } diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index fb23ad1b24894..6583d1ee0c01c 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -47,7 +47,6 @@ use rustc_session::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::symbol::{Ident, Symbol, kw}; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::spec::abi; use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::traits::wf::object_region_bounds; use rustc_trait_selection::traits::{self, ObligationCtxt}; @@ -2353,7 +2352,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { &self, hir_id: HirId, safety: hir::Safety, - abi: abi::Abi, + abi: rustc_abi::ExternAbi, decl: &hir::FnDecl<'tcx>, generics: Option<&hir::Generics<'_>>, hir_ty: Option<&hir::Ty<'_>>, diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 339eddeeade09..5830636c6e899 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -91,6 +91,7 @@ mod impl_wf_check; mod outlives; mod variance; +use rustc_abi::ExternAbi; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_middle::middle; @@ -100,19 +101,23 @@ use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::parse::feature_err; use rustc_span::Span; use rustc_span::symbol::sym; -use rustc_target::spec::abi::Abi; use rustc_trait_selection::traits; rustc_fluent_macro::fluent_messages! { "../messages.ftl" } -fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) { +fn require_c_abi_if_c_variadic( + tcx: TyCtxt<'_>, + decl: &hir::FnDecl<'_>, + abi: ExternAbi, + span: Span, +) { const CONVENTIONS_UNSTABLE: &str = "`C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`"; const CONVENTIONS_STABLE: &str = "`C` or `cdecl`"; const UNSTABLE_EXPLAIN: &str = "using calling conventions other than `C` or `cdecl` for varargs functions is unstable"; - if !decl.c_variadic || matches!(abi, Abi::C { .. } | Abi::Cdecl { .. }) { + if !decl.c_variadic || matches!(abi, ExternAbi::C { .. } | ExternAbi::Cdecl { .. }) { return; } diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index f9a21a9bef31d..421dca236a5c5 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -16,7 +16,6 @@ use rustc_middle::{bug, span_bug}; use rustc_span::Span; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::{Ident, sym}; -use rustc_target::spec::abi; use rustc_trait_selection::error_reporting::traits::DefIdOrName; use rustc_trait_selection::infer::InferCtxtExt as _; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; @@ -509,7 +508,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { def_id, ); - if fn_sig.abi == abi::Abi::RustCall { + if fn_sig.abi == rustc_abi::ExternAbi::RustCall { let sp = arg_exprs.last().map_or(call_expr.span, |expr| expr.span); if let Some(ty) = fn_sig.inputs().last().copied() { self.register_bound( diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs index 2d8943c615920..a49deaa267881 100644 --- a/compiler/rustc_hir_typeck/src/check.rs +++ b/compiler/rustc_hir_typeck/src/check.rs @@ -1,5 +1,6 @@ use std::cell::RefCell; +use rustc_abi::ExternAbi; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::intravisit::Visitor; @@ -10,7 +11,6 @@ use rustc_infer::traits::WellFormedLoc; use rustc_middle::ty::{self, Binder, Ty, TyCtxt}; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::sym; -use rustc_target::spec::abi::Abi; use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode}; use tracing::{debug, instrument}; @@ -211,7 +211,7 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_> ty::BoundVariableKind::Region(ty::BrAnon), ]); let expected_sig = ty::Binder::bind_with_vars( - tcx.mk_fn_sig([panic_info_ref_ty], tcx.types.never, false, fn_sig.safety, Abi::Rust), + tcx.mk_fn_sig([panic_info_ref_ty], tcx.types.never, false, fn_sig.safety, ExternAbi::Rust), bounds, ); @@ -234,7 +234,7 @@ fn check_lang_start_fn<'tcx>(tcx: TyCtxt<'tcx>, fn_sig: ty::FnSig<'tcx>, def_id: let generic_ty = Ty::new_param(tcx, fn_generic.index, fn_generic.name); let main_fn_ty = Ty::new_fn_ptr( tcx, - Binder::dummy(tcx.mk_fn_sig([], generic_ty, false, hir::Safety::Safe, Abi::Rust)), + Binder::dummy(tcx.mk_fn_sig([], generic_ty, false, hir::Safety::Safe, ExternAbi::Rust)), ); let expected_sig = ty::Binder::dummy(tcx.mk_fn_sig( @@ -247,7 +247,7 @@ fn check_lang_start_fn<'tcx>(tcx: TyCtxt<'tcx>, fn_sig: ty::FnSig<'tcx>, def_id: tcx.types.isize, false, fn_sig.safety, - Abi::Rust, + ExternAbi::Rust, )); let _ = check_function_signature( diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index fd6ac7de14a7c..e715a7f7e1588 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -3,6 +3,7 @@ use std::iter; use std::ops::ControlFlow; +use rustc_abi::ExternAbi; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_hir::lang_items::LangItem; @@ -15,7 +16,6 @@ use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt}; use rustc_middle::ty::{self, GenericArgs, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor}; use rustc_span::def_id::LocalDefId; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::spec::abi::Abi; use rustc_trait_selection::error_reporting::traits::ArgKind; use rustc_trait_selection::traits; use rustc_type_ir::ClosureKind; @@ -508,7 +508,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ret_param_ty, false, hir::Safety::Safe, - Abi::Rust, + ExternAbi::Rust, )); Some(ExpectedSig { cause_span, sig }) @@ -594,7 +594,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return_ty, false, hir::Safety::Safe, - Abi::Rust, + ExternAbi::Rust, )); Some(ExpectedSig { cause_span, sig }) @@ -706,7 +706,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { sig.output(), sig.c_variadic, hir::Safety::Safe, - Abi::RustCall, + ExternAbi::RustCall, ) }); @@ -845,7 +845,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { supplied_output_ty, expected_sigs.liberated_sig.c_variadic, hir::Safety::Safe, - Abi::RustCall, + ExternAbi::RustCall, ); Ok(InferOk { value: expected_sigs, obligations: all_obligations }) @@ -922,7 +922,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { supplied_return, decl.c_variadic, hir::Safety::Safe, - Abi::RustCall, + ExternAbi::RustCall, ), bound_vars, ); @@ -1086,7 +1086,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err_ty, decl.c_variadic, hir::Safety::Safe, - Abi::RustCall, + ExternAbi::RustCall, )); debug!("supplied_sig_of_closure: result={:?}", result); diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 87798ca3fd964..11e03229265a9 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -37,6 +37,7 @@ use std::ops::Deref; +use rustc_abi::ExternAbi; use rustc_errors::codes::*; use rustc_errors::{Applicability, Diag, struct_span_code_err}; use rustc_hir as hir; @@ -60,7 +61,6 @@ use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt}; use rustc_session::parse::feature_err; use rustc_span::symbol::sym; use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, Span}; -use rustc_target::spec::abi::Abi; use rustc_trait_selection::infer::InferCtxtExt as _; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; use rustc_trait_selection::traits::{ @@ -1244,7 +1244,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; if let (Some(a_sig), Some(b_sig)) = (a_sig, b_sig) { // Intrinsics are not coercible to function pointers. - if a_sig.abi() == Abi::RustIntrinsic || b_sig.abi() == Abi::RustIntrinsic { + if a_sig.abi() == ExternAbi::RustIntrinsic || b_sig.abi() == ExternAbi::RustIntrinsic { return Err(TypeError::IntrinsicCast); } // The signature must match. diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index d6e5fab610ed6..915dca614d6b9 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -5,6 +5,7 @@ //! //! See [`rustc_hir_analysis::check`] for more context on type checking in general. +use rustc_abi::{FIRST_VARIANT, FieldIdx}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::unord::UnordMap; @@ -34,7 +35,6 @@ use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::hygiene::DesugaringKind; use rustc_span::source_map::Spanned; use rustc_span::symbol::{Ident, Symbol, kw, sym}; -use rustc_target::abi::{FIRST_VARIANT, FieldIdx}; use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt}; use tracing::{debug, instrument, trace}; diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index 041ccfcddbb9a..361fd55d5deb5 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -9,6 +9,7 @@ use std::slice::from_ref; use hir::Expr; use hir::def::DefKind; use hir::pat_util::EnumerateAndAdjustIterator as _; +use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx}; use rustc_data_structures::fx::FxIndexMap; use rustc_hir as hir; use rustc_hir::def::{CtorOf, Res}; @@ -24,7 +25,6 @@ use rustc_middle::ty::{ }; use rustc_middle::{bug, span_bug}; use rustc_span::{ErrorGuaranteed, Span}; -use rustc_target::abi::{FIRST_VARIANT, FieldIdx, VariantIdx}; use rustc_trait_selection::infer::InferCtxtExt; use tracing::{debug, trace}; use ty::BorrowKind::ImmBorrow; diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index a1a78371fbd25..2753bee499b32 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -1,6 +1,7 @@ use std::collections::hash_map::Entry; use std::slice; +use rustc_abi::FieldIdx; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, StashKey}; use rustc_hir as hir; @@ -32,7 +33,6 @@ use rustc_span::Span; use rustc_span::def_id::LocalDefId; use rustc_span::hygiene::DesugaringKind; use rustc_span::symbol::kw; -use rustc_target::abi::FieldIdx; use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded; use rustc_trait_selection::traits::{ self, NormalizeExt, ObligationCauseCode, StructurallyNormalizeExt, diff --git a/compiler/rustc_hir_typeck/src/intrinsicck.rs b/compiler/rustc_hir_typeck/src/intrinsicck.rs index 8a7005ac32893..a754f7fddc915 100644 --- a/compiler/rustc_hir_typeck/src/intrinsicck.rs +++ b/compiler/rustc_hir_typeck/src/intrinsicck.rs @@ -1,5 +1,6 @@ use hir::HirId; use rustc_abi::Primitive::Pointer; +use rustc_abi::VariantIdx; use rustc_errors::codes::*; use rustc_errors::struct_span_code_err; use rustc_hir as hir; @@ -7,7 +8,6 @@ use rustc_index::Idx; use rustc_middle::bug; use rustc_middle::ty::layout::{LayoutError, SizeSkeleton}; use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; -use rustc_target::abi::VariantIdx; use tracing::trace; use super::FnCtxt; diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index cba6586f01dd8..03590b6a45522 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -1,6 +1,7 @@ use std::cmp; use std::collections::hash_map::Entry::{Occupied, Vacant}; +use rustc_abi::FieldIdx; use rustc_ast as ast; use rustc_data_structures::fx::FxHashMap; use rustc_errors::codes::*; @@ -20,7 +21,6 @@ use rustc_span::hygiene::DesugaringKind; use rustc_span::source_map::Spanned; use rustc_span::symbol::{Ident, kw, sym}; use rustc_span::{BytePos, DUMMY_SP, Span}; -use rustc_target::abi::FieldIdx; use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode}; use tracing::{debug, instrument, trace}; diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 88982661c8f7a..fbb427da1037e 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -32,6 +32,7 @@ use std::iter; +use rustc_abi::FIRST_VARIANT; use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::unord::{ExtendUnord, UnordSet}; use rustc_errors::{Applicability, MultiSpan}; @@ -49,7 +50,6 @@ use rustc_middle::ty::{ use rustc_middle::{bug, span_bug}; use rustc_session::lint; use rustc_span::{BytePos, Pos, Span, Symbol, sym}; -use rustc_target::abi::FIRST_VARIANT; use rustc_trait_selection::infer::InferCtxtExt; use tracing::{debug, instrument}; @@ -438,7 +438,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { tupled_upvars_ty_for_borrow, false, hir::Safety::Safe, - rustc_target::spec::abi::Abi::Rust, + rustc_abi::ExternAbi::Rust, ), self.tcx.mk_bound_variable_kinds(&[ty::BoundVariableKind::Region( ty::BoundRegionKind::BrEnv, From 236fe33345072e6363560fd2b535a10947af86f7 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 2 Nov 2024 19:33:00 -0700 Subject: [PATCH 04/11] compiler: Directly use rustc_abi in metadata and middle Stop reexporting ReprOptions from middle::ty --- compiler/rustc_metadata/src/native_libs.rs | 22 ++++---- compiler/rustc_metadata/src/rmeta/mod.rs | 4 +- compiler/rustc_middle/src/arena.rs | 2 +- compiler/rustc_middle/src/hir/map/mod.rs | 4 +- compiler/rustc_middle/src/hir/place.rs | 2 +- .../src/middle/codegen_fn_attrs.rs | 2 +- compiler/rustc_middle/src/mir/consts.rs | 2 +- .../src/mir/interpret/allocation.rs | 2 +- .../src/mir/interpret/allocation/init_mask.rs | 2 +- .../interpret/allocation/provenance_map.rs | 2 +- .../rustc_middle/src/mir/interpret/error.rs | 4 +- .../rustc_middle/src/mir/interpret/mod.rs | 2 +- .../rustc_middle/src/mir/interpret/pointer.rs | 2 +- .../rustc_middle/src/mir/interpret/value.rs | 2 +- compiler/rustc_middle/src/mir/mod.rs | 2 +- compiler/rustc_middle/src/mir/pretty.rs | 2 +- compiler/rustc_middle/src/mir/query.rs | 2 +- compiler/rustc_middle/src/mir/syntax.rs | 2 +- compiler/rustc_middle/src/query/erase.rs | 10 ++-- compiler/rustc_middle/src/query/keys.rs | 3 +- compiler/rustc_middle/src/query/mod.rs | 7 ++- compiler/rustc_middle/src/thir.rs | 4 +- compiler/rustc_middle/src/ty/adjustment.rs | 2 +- compiler/rustc_middle/src/ty/adt.rs | 2 +- compiler/rustc_middle/src/ty/codec.rs | 2 +- compiler/rustc_middle/src/ty/consts/int.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 15 +++--- compiler/rustc_middle/src/ty/layout.rs | 54 +++++++++---------- compiler/rustc_middle/src/ty/mod.rs | 3 +- compiler/rustc_middle/src/ty/print/pretty.rs | 5 +- .../rustc_middle/src/ty/structural_impls.rs | 10 ++-- compiler/rustc_middle/src/ty/sty.rs | 5 +- .../rustc_middle/src/ty/typeck_results.rs | 2 +- compiler/rustc_middle/src/ty/util.rs | 5 +- compiler/rustc_middle/src/values.rs | 2 +- 35 files changed, 93 insertions(+), 102 deletions(-) diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 1e6bc413118ec..b7695216f3cea 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -1,6 +1,7 @@ use std::ops::ControlFlow; use std::path::{Path, PathBuf}; +use rustc_abi::ExternAbi; use rustc_ast::CRATE_NODE_ID; use rustc_attr as attr; use rustc_data_structures::fx::FxHashSet; @@ -17,7 +18,6 @@ use rustc_session::utils::NativeLibKind; use rustc_span::def_id::{DefId, LOCAL_CRATE}; use rustc_span::symbol::{Symbol, sym}; use rustc_target::spec::LinkSelfContainedComponents; -use rustc_target::spec::abi::Abi; use crate::{errors, fluent_generated}; @@ -203,7 +203,7 @@ impl<'tcx> Collector<'tcx> { let sess = self.tcx.sess; - if matches!(abi, Abi::Rust | Abi::RustIntrinsic) { + if matches!(abi, ExternAbi::Rust | ExternAbi::RustIntrinsic) { return; } @@ -625,7 +625,7 @@ impl<'tcx> Collector<'tcx> { fn build_dll_import( &self, - abi: Abi, + abi: ExternAbi, import_name_type: Option, item: DefId, ) -> DllImport { @@ -634,12 +634,14 @@ impl<'tcx> Collector<'tcx> { // this logic is similar to `Target::adjust_abi` (in rustc_target/src/spec/mod.rs) but errors on unsupported inputs let calling_convention = if self.tcx.sess.target.arch == "x86" { match abi { - Abi::C { .. } | Abi::Cdecl { .. } => DllCallingConvention::C, - Abi::Stdcall { .. } => DllCallingConvention::Stdcall(self.i686_arg_list_size(item)), + ExternAbi::C { .. } | ExternAbi::Cdecl { .. } => DllCallingConvention::C, + ExternAbi::Stdcall { .. } => { + DllCallingConvention::Stdcall(self.i686_arg_list_size(item)) + } // On Windows, `extern "system"` behaves like msvc's `__stdcall`. // `__stdcall` only applies on x86 and on non-variadic functions: // https://learn.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-170 - Abi::System { .. } => { + ExternAbi::System { .. } => { let c_variadic = self.tcx.type_of(item).instantiate_identity().fn_sig(self.tcx).c_variadic(); @@ -649,10 +651,10 @@ impl<'tcx> Collector<'tcx> { DllCallingConvention::Stdcall(self.i686_arg_list_size(item)) } } - Abi::Fastcall { .. } => { + ExternAbi::Fastcall { .. } => { DllCallingConvention::Fastcall(self.i686_arg_list_size(item)) } - Abi::Vectorcall { .. } => { + ExternAbi::Vectorcall { .. } => { DllCallingConvention::Vectorcall(self.i686_arg_list_size(item)) } _ => { @@ -661,7 +663,9 @@ impl<'tcx> Collector<'tcx> { } } else { match abi { - Abi::C { .. } | Abi::Win64 { .. } | Abi::System { .. } => DllCallingConvention::C, + ExternAbi::C { .. } | ExternAbi::Win64 { .. } | ExternAbi::System { .. } => { + DllCallingConvention::C + } _ => { self.tcx.dcx().emit_fatal(errors::UnsupportedAbi { span }); } diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 949e26f5f609b..58f58efb116fe 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -6,7 +6,7 @@ use decoder::{DecodeContext, Metadata}; use def_path_hash_map::DefPathHashMapRef; use encoder::EncodeContext; pub use encoder::{EncodedMetadata, encode_metadata, rendered_const}; -use rustc_abi::{FieldIdx, VariantIdx}; +use rustc_abi::{FieldIdx, ReprOptions, VariantIdx}; use rustc_ast::expand::StrippedCfgItem; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::svh::Svh; @@ -27,7 +27,7 @@ use rustc_middle::middle::lib_features::FeatureStability; use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault; use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::{ - self, DeducedParamAttrs, ParameterizedOverTcx, ReprOptions, Ty, TyCtxt, UnusedGenericParams, + self, DeducedParamAttrs, ParameterizedOverTcx, Ty, TyCtxt, UnusedGenericParams, }; use rustc_middle::util::Providers; use rustc_middle::{mir, trivially_parameterized_over_tcx}; diff --git a/compiler/rustc_middle/src/arena.rs b/compiler/rustc_middle/src/arena.rs index 7e77923fcdf67..b664230d10bce 100644 --- a/compiler/rustc_middle/src/arena.rs +++ b/compiler/rustc_middle/src/arena.rs @@ -9,7 +9,7 @@ macro_rules! arena_types { ($macro:path) => ( $macro!([ [] layout: rustc_abi::LayoutData, - [] fn_abi: rustc_target::abi::call::FnAbi<'tcx, rustc_middle::ty::Ty<'tcx>>, + [] fn_abi: rustc_target::callconv::FnAbi<'tcx, rustc_middle::ty::Ty<'tcx>>, // AdtDef are interned and compared by address [decode] adt_def: rustc_middle::ty::AdtDefData, [] steal_thir: rustc_data_structures::steal::Steal>, diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 926691013dd8f..007e6f46006e3 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -1,3 +1,4 @@ +use rustc_abi::ExternAbi; use rustc_ast::visit::{VisitorResult, walk_list}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -12,7 +13,6 @@ use rustc_middle::hir::nested_filter; use rustc_span::def_id::StableCrateId; use rustc_span::symbol::{Ident, Symbol, kw, sym}; use rustc_span::{ErrorGuaranteed, Span}; -use rustc_target::spec::abi::Abi; use {rustc_ast as ast, rustc_hir_pretty as pprust_hir}; use crate::hir::ModuleItems; @@ -668,7 +668,7 @@ impl<'hir> Map<'hir> { } } - pub fn get_foreign_abi(self, hir_id: HirId) -> Abi { + pub fn get_foreign_abi(self, hir_id: HirId) -> ExternAbi { let parent = self.get_parent_item(hir_id); if let OwnerNode::Item(Item { kind: ItemKind::ForeignMod { abi, .. }, .. }) = self.tcx.hir_owner_node(parent) diff --git a/compiler/rustc_middle/src/hir/place.rs b/compiler/rustc_middle/src/hir/place.rs index 4c7af0bc3726d..66b701523b71f 100644 --- a/compiler/rustc_middle/src/hir/place.rs +++ b/compiler/rustc_middle/src/hir/place.rs @@ -1,6 +1,6 @@ +use rustc_abi::{FieldIdx, VariantIdx}; use rustc_hir::HirId; use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; -use rustc_target::abi::{FieldIdx, VariantIdx}; use crate::ty; use crate::ty::Ty; diff --git a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs index 90dff0f5c7da8..44428471a5fea 100644 --- a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs +++ b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs @@ -1,7 +1,7 @@ +use rustc_abi::Align; use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr}; use rustc_macros::{HashStable, TyDecodable, TyEncodable}; use rustc_span::symbol::Symbol; -use rustc_target::abi::Align; use rustc_target::spec::SanitizerSet; use crate::mir::mono::Linkage; diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index 465aa0eee0344..1ae0bd6740dc9 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -1,12 +1,12 @@ use std::fmt::{self, Debug, Display, Formatter}; use either::Either; +use rustc_abi::{HasDataLayout, Size}; use rustc_hir::def_id::DefId; use rustc_macros::{HashStable, Lift, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; use rustc_session::RemapFileNameExt; use rustc_session::config::RemapPathScopeComponents; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::abi::{HasDataLayout, Size}; use crate::mir::interpret::{AllocId, ConstAllocation, ErrorHandled, Scalar, alloc_range}; use crate::mir::{Promoted, pretty_print_const_value}; diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs index ac3baf74ca7c4..509f2667b35b2 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs @@ -12,10 +12,10 @@ use either::{Left, Right}; use init_mask::*; pub use init_mask::{InitChunk, InitChunkIter}; use provenance_map::*; +use rustc_abi::{Align, HasDataLayout, Size}; use rustc_ast::Mutability; use rustc_data_structures::intern::Interned; use rustc_macros::{HashStable, TyDecodable, TyEncodable}; -use rustc_target::abi::{Align, HasDataLayout, Size}; use super::{ AllocId, BadBytesAccess, CtfeProvenance, InterpErrorKind, InterpResult, Pointer, diff --git a/compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs b/compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs index dfaf96e14f662..cc6389e2989ef 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs @@ -4,9 +4,9 @@ mod tests; use std::ops::Range; use std::{hash, iter}; +use rustc_abi::Size; use rustc_macros::{HashStable, TyDecodable, TyEncodable}; use rustc_serialize::{Decodable, Encodable}; -use rustc_target::abi::Size; use rustc_type_ir::{TyDecoder, TyEncoder}; use super::AllocRange; diff --git a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs index b3940530f69cc..5c47fc6a399e4 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs @@ -3,10 +3,10 @@ use std::cmp; +use rustc_abi::{HasDataLayout, Size}; use rustc_data_structures::sorted_map::SortedMap; use rustc_macros::HashStable; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; -use rustc_target::abi::{HasDataLayout, Size}; use tracing::trace; use super::{AllocError, AllocRange, AllocResult, CtfeProvenance, Provenance, alloc_range}; diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index b520f21ce20c9..8ec7e1851a51b 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -4,6 +4,7 @@ use std::borrow::Cow; use std::{convert, fmt, mem, ops}; use either::Either; +use rustc_abi::{Align, Size, VariantIdx, WrappingRange}; use rustc_ast_ir::Mutability; use rustc_data_structures::sync::Lock; use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg}; @@ -11,7 +12,6 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable}; use rustc_session::CtfeBacktrace; use rustc_span::def_id::DefId; use rustc_span::{DUMMY_SP, Span, Symbol}; -use rustc_target::abi::{Align, Size, VariantIdx, WrappingRange, call}; use super::{AllocId, AllocRange, ConstAllocation, Pointer, Scalar}; use crate::error; @@ -217,7 +217,7 @@ pub enum InvalidProgramInfo<'tcx> { /// An error occurred during FnAbi computation: the passed --target lacks FFI support /// (which unfortunately typeck does not reject). /// Not using `FnAbiError` as that contains a nested `LayoutError`. - FnAbiAdjustForForeignAbi(call::AdjustForForeignAbiError), + FnAbiAdjustForForeignAbi(rustc_target::callconv::AdjustForForeignAbiError), } /// Details of why a pointer had to be in-bounds. diff --git a/compiler/rustc_middle/src/mir/interpret/mod.rs b/compiler/rustc_middle/src/mir/interpret/mod.rs index 790ff3e2fe030..b0c0e1be50064 100644 --- a/compiler/rustc_middle/src/mir/interpret/mod.rs +++ b/compiler/rustc_middle/src/mir/interpret/mod.rs @@ -12,6 +12,7 @@ use std::io::{Read, Write}; use std::num::NonZero; use std::{fmt, io}; +use rustc_abi::{AddressSpace, Endian, HasDataLayout}; use rustc_ast::LitKind; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lock; @@ -20,7 +21,6 @@ use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_serialize::{Decodable, Encodable}; -use rustc_target::abi::{AddressSpace, Endian, HasDataLayout}; use tracing::{debug, trace}; // Also make the error macros available from this module. pub use { diff --git a/compiler/rustc_middle/src/mir/interpret/pointer.rs b/compiler/rustc_middle/src/mir/interpret/pointer.rs index 1700b0f02ecc8..1d5afe22573e0 100644 --- a/compiler/rustc_middle/src/mir/interpret/pointer.rs +++ b/compiler/rustc_middle/src/mir/interpret/pointer.rs @@ -1,9 +1,9 @@ use std::fmt; use std::num::NonZero; +use rustc_abi::{HasDataLayout, Size}; use rustc_data_structures::static_assert_size; use rustc_macros::{HashStable, TyDecodable, TyEncodable}; -use rustc_target::abi::{HasDataLayout, Size}; use super::AllocId; diff --git a/compiler/rustc_middle/src/mir/interpret/value.rs b/compiler/rustc_middle/src/mir/interpret/value.rs index 061a55bfda8d6..9d462093b9ea1 100644 --- a/compiler/rustc_middle/src/mir/interpret/value.rs +++ b/compiler/rustc_middle/src/mir/interpret/value.rs @@ -1,10 +1,10 @@ use std::fmt; use either::{Either, Left, Right}; +use rustc_abi::{HasDataLayout, Size}; use rustc_apfloat::Float; use rustc_apfloat::ieee::{Double, Half, Quad, Single}; use rustc_macros::{HashStable, TyDecodable, TyEncodable}; -use rustc_target::abi::{HasDataLayout, Size}; use super::{ AllocId, CtfeProvenance, InterpResult, Pointer, PointerArithmetic, Provenance, diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 978abab8b08d9..260c6543f9844 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -10,6 +10,7 @@ use std::{iter, mem}; pub use basic_blocks::BasicBlocks; use either::Either; use polonius_engine::Atom; +use rustc_abi::{FieldIdx, VariantIdx}; pub use rustc_ast::Mutability; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -27,7 +28,6 @@ use rustc_serialize::{Decodable, Encodable}; use rustc_span::source_map::Spanned; use rustc_span::symbol::Symbol; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::abi::{FieldIdx, VariantIdx}; use tracing::trace; pub use self::query::*; diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 80ae5a7146dad..d0f93c19e44e6 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -4,6 +4,7 @@ use std::fs; use std::io::{self, Write as _}; use std::path::{Path, PathBuf}; +use rustc_abi::Size; use rustc_ast::InlineAsmTemplatePiece; use rustc_middle::mir::interpret::{ AllocBytes, AllocId, Allocation, GlobalAlloc, Pointer, Provenance, alloc_range, @@ -11,7 +12,6 @@ use rustc_middle::mir::interpret::{ }; use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::*; -use rustc_target::abi::Size; use tracing::trace; use super::graphviz::write_mir_fn_graphviz; diff --git a/compiler/rustc_middle/src/mir/query.rs b/compiler/rustc_middle/src/mir/query.rs index 70331214ac5a8..c34bdf041af02 100644 --- a/compiler/rustc_middle/src/mir/query.rs +++ b/compiler/rustc_middle/src/mir/query.rs @@ -4,6 +4,7 @@ use std::cell::Cell; use std::fmt::{self, Debug}; use derive_where::derive_where; +use rustc_abi::{FieldIdx, VariantIdx}; use rustc_data_structures::fx::FxIndexMap; use rustc_errors::ErrorGuaranteed; use rustc_hir::def_id::LocalDefId; @@ -12,7 +13,6 @@ use rustc_index::{Idx, IndexVec}; use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; use rustc_span::Span; use rustc_span::symbol::Symbol; -use rustc_target::abi::{FieldIdx, VariantIdx}; use smallvec::SmallVec; use super::{ConstValue, SourceInfo}; diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 85beb6ef1e79b..f01ac305d3f5a 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -3,6 +3,7 @@ //! This is in a dedicated file so that changes to this file can be reviewed more carefully. //! The intention is that this file only contains datatype declarations, no code. +use rustc_abi::{FieldIdx, VariantIdx}; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece, Mutability}; use rustc_data_structures::packed::Pu128; use rustc_hir::CoroutineKind; @@ -13,7 +14,6 @@ use rustc_span::Span; use rustc_span::def_id::LocalDefId; use rustc_span::source_map::Spanned; use rustc_span::symbol::Symbol; -use rustc_target::abi::{FieldIdx, VariantIdx}; use rustc_target::asm::InlineAsmRegOrRegClass; use smallvec::SmallVec; diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs index 8cfc7f1e33ecf..1d4c36e28bdba 100644 --- a/compiler/rustc_middle/src/query/erase.rs +++ b/compiler/rustc_middle/src/query/erase.rs @@ -132,12 +132,10 @@ impl EraseType for Result> { type Result = [u8; size_of::>>()]; } -impl EraseType - for Result>, &ty::layout::LayoutError<'_>> -{ +impl EraseType for Result>, &ty::layout::LayoutError<'_>> { type Result = [u8; size_of::< Result< - rustc_target::abi::TyAndLayout<'static, Ty<'static>>, + rustc_abi::TyAndLayout<'static, Ty<'static>>, &'static ty::layout::LayoutError<'static>, >, >()]; @@ -253,13 +251,14 @@ trivial! { Option, Option, Option, - Option, + Option, Option, Option, Option, Result<(), rustc_errors::ErrorGuaranteed>, Result<(), rustc_middle::traits::query::NoSolution>, Result, + rustc_abi::ReprOptions, rustc_ast::expand::allocator::AllocatorKind, rustc_attr::ConstStability, rustc_attr::DefaultBodyStability, @@ -311,7 +310,6 @@ trivial! { rustc_middle::ty::fast_reject::SimplifiedType, rustc_middle::ty::ImplPolarity, rustc_middle::ty::Representability, - rustc_middle::ty::ReprOptions, rustc_middle::ty::UnusedGenericParams, rustc_middle::ty::util::AlwaysRequiresDrop, rustc_middle::ty::Visibility, diff --git a/compiler/rustc_middle/src/query/keys.rs b/compiler/rustc_middle/src/query/keys.rs index ba7b57c891c52..fe28ef0f70c79 100644 --- a/compiler/rustc_middle/src/query/keys.rs +++ b/compiler/rustc_middle/src/query/keys.rs @@ -5,7 +5,6 @@ use rustc_hir::hir_id::{HirId, OwnerId}; use rustc_query_system::query::{DefIdCache, DefaultCache, SingleCache, VecCache}; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::abi; use crate::infer::canonical::CanonicalQueryInput; use crate::ty::fast_reject::SimplifiedType; @@ -509,7 +508,7 @@ impl<'tcx> Key for (DefId, Ty<'tcx>, GenericArgsRef<'tcx>, ty::ParamEnv<'tcx>) { } } -impl<'tcx> Key for (Ty<'tcx>, abi::VariantIdx) { +impl<'tcx> Key for (Ty<'tcx>, rustc_abi::VariantIdx) { type Cache = DefaultCache; fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 088b5d4ec965f..41d0b47388cce 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -42,9 +42,8 @@ use rustc_session::lint::LintExpectationId; use rustc_span::def_id::LOCAL_CRATE; use rustc_span::symbol::Symbol; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::abi; use rustc_target::spec::PanicStrategy; -use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; +use {rustc_abi as abi, rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; use crate::infer::canonical::{self, Canonical}; use crate::lint::LintExpectation; @@ -1465,7 +1464,7 @@ rustc_queries! { /// instead, where the instance is an `InstanceKind::Virtual`. query fn_abi_of_fn_ptr( key: ty::ParamEnvAnd<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List>)> - ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> { + ) -> Result<&'tcx rustc_target::callconv::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> { desc { "computing call ABI of `{}` function pointers", key.value.0 } } @@ -1476,7 +1475,7 @@ rustc_queries! { /// to an `InstanceKind::Virtual` instance (of `::fn`). query fn_abi_of_instance( key: ty::ParamEnvAnd<'tcx, (ty::Instance<'tcx>, &'tcx ty::List>)> - ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> { + ) -> Result<&'tcx rustc_target::callconv::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> { desc { "computing call ABI of `{}`", key.value.0 } } diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index fe865b8a51508..45ceb0a555d33 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -12,6 +12,7 @@ use std::cmp::Ordering; use std::fmt; use std::ops::Index; +use rustc_abi::{FieldIdx, Integer, Size, VariantIdx}; use rustc_ast::{AsmMacro, InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_hir as hir; use rustc_hir::def_id::DefId; @@ -29,7 +30,6 @@ use rustc_middle::ty::{ }; use rustc_span::def_id::LocalDefId; use rustc_span::{ErrorGuaranteed, Span, Symbol}; -use rustc_target::abi::{FieldIdx, Integer, Size, VariantIdx}; use rustc_target::asm::InlineAsmRegOrRegClass; use tracing::instrument; @@ -1063,7 +1063,7 @@ impl<'tcx> PatRangeBoundary<'tcx> { a.partial_cmp(&b) } ty::Int(ity) => { - let size = rustc_target::abi::Integer::from_int_ty(&tcx, *ity).size(); + let size = rustc_abi::Integer::from_int_ty(&tcx, *ity).size(); let a = size.sign_extend(a) as i128; let b = size.sign_extend(b) as i128; Some(a.cmp(&b)) diff --git a/compiler/rustc_middle/src/ty/adjustment.rs b/compiler/rustc_middle/src/ty/adjustment.rs index c56038d358c8e..ce27e81813ca1 100644 --- a/compiler/rustc_middle/src/ty/adjustment.rs +++ b/compiler/rustc_middle/src/ty/adjustment.rs @@ -1,8 +1,8 @@ +use rustc_abi::FieldIdx; use rustc_hir as hir; use rustc_hir::lang_items::LangItem; use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; use rustc_span::Span; -use rustc_target::abi::FieldIdx; use crate::ty::{self, Ty, TyCtxt}; diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index 3322a2643d7d3..0773eb7a3bef6 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -3,6 +3,7 @@ use std::hash::{Hash, Hasher}; use std::ops::Range; use std::str; +use rustc_abi::{FIRST_VARIANT, ReprOptions, VariantIdx}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; @@ -17,7 +18,6 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable}; use rustc_query_system::ich::StableHashingContext; use rustc_session::DataTypeKind; use rustc_span::symbol::sym; -use rustc_target::abi::{FIRST_VARIANT, ReprOptions, VariantIdx}; use tracing::{debug, info, trace}; use super::{ diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index ef9dfdd2f9624..b5358f0ca35e9 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -10,12 +10,12 @@ use std::hash::Hash; use std::intrinsics; use std::marker::DiscriminantKind; +use rustc_abi::{FieldIdx, VariantIdx}; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::LocalDefId; use rustc_middle::ty::TyCtxt; use rustc_serialize::{Decodable, Encodable}; use rustc_span::Span; -use rustc_target::abi::{FieldIdx, VariantIdx}; pub use rustc_type_ir::{TyDecoder, TyEncoder}; use crate::arena::ArenaAllocatable; diff --git a/compiler/rustc_middle/src/ty/consts/int.rs b/compiler/rustc_middle/src/ty/consts/int.rs index 1732374ab8c26..b72edc1c53255 100644 --- a/compiler/rustc_middle/src/ty/consts/int.rs +++ b/compiler/rustc_middle/src/ty/consts/int.rs @@ -1,11 +1,11 @@ use std::fmt; use std::num::NonZero; +use rustc_abi::Size; use rustc_apfloat::Float; use rustc_apfloat::ieee::{Double, Half, Quad, Single}; use rustc_errors::{DiagArgValue, IntoDiagArg}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; -use rustc_target::abi::Size; use crate::ty::TyCtxt; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 9abad6d1a680b..1d76d27cbd234 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -12,7 +12,7 @@ use std::marker::PhantomData; use std::ops::{Bound, Deref}; use std::{fmt, iter, mem}; -use rustc_abi::{FieldIdx, Layout, LayoutData, TargetDataLayout, VariantIdx}; +use rustc_abi::{ExternAbi, FieldIdx, Layout, LayoutData, TargetDataLayout, VariantIdx}; use rustc_ast::{self as ast, attr}; use rustc_data_structures::defer; use rustc_data_structures::fingerprint::Fingerprint; @@ -49,7 +49,6 @@ use rustc_session::{Limit, MetadataKind, Session}; use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId}; use rustc_span::symbol::{Ident, Symbol, kw, sym}; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::spec::abi; use rustc_type_ir::TyKind::*; use rustc_type_ir::fold::TypeFoldable; use rustc_type_ir::lang_items::TraitSolverLangItem; @@ -136,7 +135,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> { type AllocId = crate::mir::interpret::AllocId; type Pat = Pattern<'tcx>; type Safety = hir::Safety; - type Abi = abi::Abi; + type Abi = ExternAbi; type Const = ty::Const<'tcx>; type PlaceholderConst = ty::PlaceholderConst; @@ -695,13 +694,13 @@ impl<'tcx> rustc_type_ir::inherent::DefId> for DefId { } } -impl<'tcx> rustc_type_ir::inherent::Abi> for abi::Abi { +impl<'tcx> rustc_type_ir::inherent::Abi> for ExternAbi { fn rust() -> Self { - abi::Abi::Rust + ExternAbi::Rust } fn is_rust(self) -> bool { - matches!(self, abi::Abi::Rust) + matches!(self, ExternAbi::Rust) } } @@ -2557,7 +2556,7 @@ impl<'tcx> TyCtxt<'tcx> { ty::Tuple(params) => *params, _ => bug!(), }; - self.mk_fn_sig(params, s.output(), s.c_variadic, safety, abi::Abi::Rust) + self.mk_fn_sig(params, s.output(), s.c_variadic, safety, ExternAbi::Rust) }) } @@ -2819,7 +2818,7 @@ impl<'tcx> TyCtxt<'tcx> { output: I::Item, c_variadic: bool, safety: hir::Safety, - abi: abi::Abi, + abi: ExternAbi, ) -> T::Output where I: IntoIterator, diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 0560ffe058a37..76e3183fcbbd2 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -2,11 +2,10 @@ use std::num::NonZero; use std::ops::Bound; use std::{cmp, fmt}; -use rustc_abi::Primitive::{self, Float, Int, Pointer}; use rustc_abi::{ - AddressSpace, Align, BackendRepr, FieldsShape, HasDataLayout, Integer, LayoutCalculator, - LayoutData, PointeeInfo, PointerKind, ReprOptions, Scalar, Size, TagEncoding, TargetDataLayout, - Variants, + AddressSpace, Align, BackendRepr, ExternAbi, FieldIdx, FieldsShape, HasDataLayout, LayoutData, + PointeeInfo, PointerKind, Primitive, ReprOptions, Scalar, Size, TagEncoding, TargetDataLayout, + TyAbiInterface, VariantIdx, Variants, }; use rustc_error_messages::DiagMessage; use rustc_errors::{ @@ -19,9 +18,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable, extension}; use rustc_session::config::OptLevel; use rustc_span::symbol::{Symbol, sym}; use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span}; -use rustc_target::abi::call::FnAbi; -use rustc_target::abi::{FieldIdx, TyAbiInterface, VariantIdx, call}; -use rustc_target::spec::abi::Abi as SpecAbi; +use rustc_target::callconv::FnAbi; use rustc_target::spec::{ HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, PanicStrategy, Target, WasmCAbi, X86Abi, }; @@ -86,16 +83,16 @@ impl abi::Integer { repr: &ReprOptions, min: i128, max: i128, - ) -> (Integer, bool) { + ) -> (abi::Integer, bool) { // Theoretically, negative values could be larger in unsigned representation // than the unsigned representation of the signed minimum. However, if there // are any negative values, the only valid unsigned representation is u128 // which can fit all i128 values, so the result remains unaffected. - let unsigned_fit = Integer::fit_unsigned(cmp::max(min as u128, max as u128)); - let signed_fit = cmp::max(Integer::fit_signed(min), Integer::fit_signed(max)); + let unsigned_fit = abi::Integer::fit_unsigned(cmp::max(min as u128, max as u128)); + let signed_fit = cmp::max(abi::Integer::fit_signed(min), abi::Integer::fit_signed(max)); if let Some(ity) = repr.int { - let discr = Integer::from_attr(&tcx, ity); + let discr = abi::Integer::from_attr(&tcx, ity); let fit = if ity.is_signed() { signed_fit } else { unsigned_fit }; if discr < fit { bug!( @@ -113,7 +110,7 @@ impl abi::Integer { tcx.data_layout().c_enum_min_size } else { // repr(Rust) enums try to be as small as possible - Integer::I8 + abi::Integer::I8 }; // If there are no negative values, we can use the unsigned fit. @@ -154,10 +151,10 @@ impl Primitive { #[inline] fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match *self { - Int(i, signed) => i.to_ty(tcx, signed), - Float(f) => f.to_ty(tcx), + Primitive::Int(i, signed) => i.to_ty(tcx, signed), + Primitive::Float(f) => f.to_ty(tcx), // FIXME(erikdesjardins): handle non-default addrspace ptr sizes - Pointer(_) => Ty::new_mut_ptr(tcx, tcx.types.unit), + Primitive::Pointer(_) => Ty::new_mut_ptr(tcx, tcx.types.unit), } } @@ -166,13 +163,13 @@ impl Primitive { #[inline] fn to_int_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match *self { - Int(i, signed) => i.to_ty(tcx, signed), + Primitive::Int(i, signed) => i.to_ty(tcx, signed), // FIXME(erikdesjardins): handle non-default addrspace ptr sizes - Pointer(_) => { + Primitive::Pointer(_) => { let signed = false; tcx.data_layout().ptr_sized_integer().to_ty(tcx, signed) } - Float(_) => bug!("floats do not have an int type"), + Primitive::Float(_) => bug!("floats do not have an int type"), } } } @@ -299,13 +296,13 @@ impl<'tcx> IntoDiagArg for LayoutError<'tcx> { #[derive(Clone, Copy)] pub struct LayoutCx<'tcx> { - pub calc: LayoutCalculator>, + pub calc: abi::LayoutCalculator>, pub param_env: ty::ParamEnv<'tcx>, } impl<'tcx> LayoutCx<'tcx> { pub fn new(tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Self { - Self { calc: LayoutCalculator::new(tcx), param_env } + Self { calc: abi::LayoutCalculator::new(tcx), param_env } } } @@ -645,7 +642,7 @@ impl MaybeResult for Result { } } -pub type TyAndLayout<'tcx> = rustc_target::abi::TyAndLayout<'tcx, Ty<'tcx>>; +pub type TyAndLayout<'tcx> = rustc_abi::TyAndLayout<'tcx, Ty<'tcx>>; /// Trait for contexts that want to be able to compute layouts of types. /// This automatically gives access to `LayoutOf`, through a blanket `impl`. @@ -1048,7 +1045,7 @@ where if let Some(variant) = data_variant { // FIXME(erikdesjardins): handle non-default addrspace ptr sizes // (requires passing in the expected address space from the caller) - let ptr_end = offset + Pointer(AddressSpace::DATA).size(cx); + let ptr_end = offset + Primitive::Pointer(AddressSpace::DATA).size(cx); for i in 0..variant.fields.count() { let field_start = variant.fields.offset(i); if field_start <= offset { @@ -1163,7 +1160,7 @@ where /// affects various optimizations and codegen. #[inline] #[tracing::instrument(level = "debug", skip(tcx))] -pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option, abi: SpecAbi) -> bool { +pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option, abi: ExternAbi) -> bool { if let Some(did) = fn_def_id { // Special attribute for functions which can't unwind. if tcx.codegen_fn_attrs(did).flags.contains(CodegenFnAttrFlags::NEVER_UNWIND) { @@ -1195,7 +1192,7 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option, abi: SpecAbi) -> // ABIs have such an option. Otherwise the only other thing here is Rust // itself, and those ABIs are determined by the panic strategy configured // for this compilation. - use SpecAbi::*; + use ExternAbi::*; match abi { C { unwind } | System { unwind } @@ -1231,17 +1228,16 @@ pub enum FnAbiError<'tcx> { Layout(LayoutError<'tcx>), /// Error produced by attempting to adjust a `FnAbi`, for a "foreign" ABI. - AdjustForForeignAbi(call::AdjustForForeignAbiError), + AdjustForForeignAbi(rustc_target::callconv::AdjustForForeignAbiError), } impl<'a, 'b, G: EmissionGuarantee> Diagnostic<'a, G> for FnAbiError<'b> { fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { match self { Self::Layout(e) => e.into_diagnostic().into_diag(dcx, level), - Self::AdjustForForeignAbi(call::AdjustForForeignAbiError::Unsupported { - arch, - abi, - }) => UnsupportedFnAbi { arch, abi: abi.name() }.into_diag(dcx, level), + Self::AdjustForForeignAbi( + rustc_target::callconv::AdjustForForeignAbiError::Unsupported { arch, abi }, + ) => UnsupportedFnAbi { arch, abi: abi.name() }.into_diag(dcx, level), } } } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index dac81a6dfbb12..8a324be32e777 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -24,6 +24,7 @@ pub use assoc::*; pub use generic_args::{GenericArgKind, TermKind, *}; pub use generics::*; pub use intrinsic::IntrinsicDef; +use rustc_abi::{Align, FieldIdx, Integer, IntegerType, ReprFlags, ReprOptions, VariantIdx}; use rustc_ast::expand::StrippedCfgItem; use rustc_ast::node_id::NodeMap; pub use rustc_ast_ir::{Movability, Mutability, try_visit}; @@ -48,8 +49,6 @@ pub use rustc_session::lint::RegisteredTools; use rustc_span::hygiene::MacroKind; use rustc_span::symbol::{Ident, Symbol, kw, sym}; use rustc_span::{ExpnId, ExpnKind, Span}; -use rustc_target::abi::{Align, FieldIdx, Integer, IntegerType, VariantIdx}; -pub use rustc_target::abi::{ReprFlags, ReprOptions}; pub use rustc_type_ir::ConstKind::{ Bound as BoundCt, Error as ErrorCt, Expr as ExprCt, Infer as InferCt, Param as ParamCt, Placeholder as PlaceholderCt, Unevaluated, Value, diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 2480cee3dc4b6..d8725cb6ba0e5 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -3,6 +3,7 @@ use std::fmt::{self, Write as _}; use std::iter; use std::ops::{Deref, DerefMut}; +use rustc_abi::{ExternAbi, Size}; use rustc_apfloat::Float; use rustc_apfloat::ieee::{Double, Half, Quad, Single}; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; @@ -17,8 +18,6 @@ use rustc_session::Limit; use rustc_session::cstore::{ExternCrate, ExternCrateSource}; use rustc_span::FileNameDisplayPreference; use rustc_span::symbol::{Ident, Symbol, kw}; -use rustc_target::abi::Size; -use rustc_target::spec::abi::Abi; use rustc_type_ir::{Upcast as _, elaborate}; use smallvec::SmallVec; @@ -3029,7 +3028,7 @@ define_print! { ty::FnSig<'tcx> { p!(write("{}", self.safety.prefix_str())); - if self.abi != Abi::Rust { + if self.abi != ExternAbi::Rust { p!(write("extern {} ", self.abi)); } diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 4872d8c89eb84..3268dabd165ae 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -5,11 +5,11 @@ use std::fmt::{self, Debug}; +use rustc_abi::TyAndLayout; use rustc_ast_ir::try_visit; use rustc_ast_ir::visit::VisitorResult; use rustc_hir::def::Namespace; use rustc_span::source_map::Spanned; -use rustc_target::abi::TyAndLayout; use rustc_type_ir::ConstKind; use super::print::PrettyPrinter; @@ -218,8 +218,8 @@ TrivialLiftImpls! { // provide any traversal implementations, we need to provide a traversal // implementation (only for TyCtxt<'_> interners). TrivialTypeTraversalImpls! { - ::rustc_target::abi::FieldIdx, - ::rustc_target::abi::VariantIdx, + ::rustc_abi::FieldIdx, + ::rustc_abi::VariantIdx, crate::middle::region::Scope, ::rustc_ast::InlineAsmOptions, ::rustc_ast::InlineAsmTemplatePiece, @@ -271,12 +271,12 @@ TrivialTypeTraversalAndLiftImpls! { interpret::AllocId, interpret::CtfeProvenance, interpret::Scalar, - rustc_target::abi::Size, + rustc_abi::Size, } TrivialLiftImpls! { ::rustc_hir::Safety, - ::rustc_target::spec::abi::Abi, + ::rustc_abi::ExternAbi, } /////////////////////////////////////////////////////////////////////////// diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index f54afdbc929fa..e27bb2fd1350a 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -8,6 +8,7 @@ use std::iter; use std::ops::{ControlFlow, Range}; use hir::def::{CtorKind, DefKind}; +use rustc_abi::{ExternAbi, FIRST_VARIANT, FieldIdx, VariantIdx}; use rustc_data_structures::captures::Captures; use rustc_errors::{ErrorGuaranteed, MultiSpan}; use rustc_hir as hir; @@ -16,8 +17,6 @@ use rustc_hir::def_id::DefId; use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, extension}; use rustc_span::symbol::{Symbol, sym}; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::abi::{FIRST_VARIANT, FieldIdx, VariantIdx}; -use rustc_target::spec::abi; use rustc_type_ir::TyKind::*; use rustc_type_ir::visit::TypeVisitableExt; use rustc_type_ir::{self as ir, BoundVar, CollectAndApply, DynKind}; @@ -1365,7 +1364,7 @@ impl<'tcx> Ty<'tcx> { inputs_and_output: ty::List::empty(), c_variadic: false, safety: hir::Safety::Safe, - abi: abi::Abi::Rust, + abi: ExternAbi::Rust, }) } Closure(..) => bug!( diff --git a/compiler/rustc_middle/src/ty/typeck_results.rs b/compiler/rustc_middle/src/ty/typeck_results.rs index 6aa2b2cd48051..8cba5f332784c 100644 --- a/compiler/rustc_middle/src/ty/typeck_results.rs +++ b/compiler/rustc_middle/src/ty/typeck_results.rs @@ -2,6 +2,7 @@ use std::collections::hash_map::Entry; use std::hash::Hash; use std::iter; +use rustc_abi::{FieldIdx, VariantIdx}; use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::unord::{ExtendUnord, UnordItems, UnordSet}; use rustc_errors::ErrorGuaranteed; @@ -16,7 +17,6 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisit use rustc_middle::mir::FakeReadCause; use rustc_session::Session; use rustc_span::Span; -use rustc_target::abi::{FieldIdx, VariantIdx}; use super::RvalueScopes; use crate::hir::place::Place as HirPlace; diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 7fd7e463acf89..83276808a28e6 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -2,6 +2,7 @@ use std::{fmt, iter}; +use rustc_abi::{ExternAbi, Float, Integer, IntegerType, Size}; use rustc_apfloat::Float as _; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher}; @@ -14,8 +15,6 @@ use rustc_index::bit_set::GrowableBitSet; use rustc_macros::{HashStable, TyDecodable, TyEncodable, extension}; use rustc_session::Limit; use rustc_span::sym; -use rustc_target::abi::{Float, Integer, IntegerType, Size}; -use rustc_target::spec::abi::Abi; use smallvec::{SmallVec, smallvec}; use tracing::{debug, instrument}; @@ -1783,7 +1782,7 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool { /// the compiler to make some assumptions about its shape; if the user doesn't use a feature gate, they may /// cause an ICE that we otherwise may want to prevent. pub fn intrinsic_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option { - if (matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic) + if (matches!(tcx.fn_sig(def_id).skip_binder().abi(), ExternAbi::RustIntrinsic) && tcx.features().intrinsics()) || (tcx.has_attr(def_id, sym::rustc_intrinsic) && tcx.features().rustc_attrs()) { diff --git a/compiler/rustc_middle/src/values.rs b/compiler/rustc_middle/src/values.rs index 48ca38344cf2e..48d744a9ef6cd 100644 --- a/compiler/rustc_middle/src/values.rs +++ b/compiler/rustc_middle/src/values.rs @@ -67,7 +67,7 @@ impl<'tcx> Value> for ty::Binder<'_, ty::FnSig<'_>> { err, false, rustc_hir::Safety::Safe, - rustc_target::spec::abi::Abi::Rust, + rustc_abi::ExternAbi::Rust, )); // SAFETY: This is never called when `Self` is not `ty::Binder<'tcx, ty::FnSig<'tcx>>`. From 843b6e08592affd76a15c6e0e9ceaf73b98d7d5a Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 2 Nov 2024 19:33:00 -0700 Subject: [PATCH 05/11] compiler: Directly use rustc_abi in mir_transform --- .../src/abort_unwinding_calls.rs | 12 ++++++------ compiler/rustc_mir_transform/src/coroutine.rs | 2 +- .../src/coroutine/by_move_body.rs | 2 +- .../rustc_mir_transform/src/dataflow_const_prop.rs | 2 +- .../src/elaborate_box_derefs.rs | 2 +- .../rustc_mir_transform/src/elaborate_drops.rs | 2 +- .../rustc_mir_transform/src/ffi_unwind_calls.rs | 14 +++++++++----- .../src/function_item_references.rs | 4 ++-- compiler/rustc_mir_transform/src/inline.rs | 7 +++---- compiler/rustc_mir_transform/src/instsimplify.rs | 6 +++--- compiler/rustc_mir_transform/src/jump_threading.rs | 2 +- compiler/rustc_mir_transform/src/large_enums.rs | 10 +++++----- compiler/rustc_mir_transform/src/match_branches.rs | 2 +- .../rustc_mir_transform/src/remove_uninit_drops.rs | 2 +- compiler/rustc_mir_transform/src/shim.rs | 5 ++--- .../src/shim/async_destructor_ctor.rs | 2 +- compiler/rustc_mir_transform/src/sroa.rs | 2 +- .../rustc_mir_transform/src/unreachable_prop.rs | 2 +- compiler/rustc_mir_transform/src/validate.rs | 9 ++++----- 19 files changed, 45 insertions(+), 44 deletions(-) diff --git a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs index 84c8a91b08252..03f11885d58ae 100644 --- a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs +++ b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs @@ -1,9 +1,9 @@ +use rustc_abi::ExternAbi; use rustc_ast::InlineAsmOptions; use rustc_middle::mir::*; use rustc_middle::span_bug; use rustc_middle::ty::{self, TyCtxt, layout}; use rustc_target::spec::PanicStrategy; -use rustc_target::spec::abi::Abi; /// A pass that runs which is targeted at ensuring that codegen guarantees about /// unwinding are upheld for compilations of panic=abort programs. @@ -38,9 +38,9 @@ impl<'tcx> crate::MirPass<'tcx> for AbortUnwindingCalls { let body_ty = tcx.type_of(def_id).skip_binder(); let body_abi = match body_ty.kind() { ty::FnDef(..) => body_ty.fn_sig(tcx).abi(), - ty::Closure(..) => Abi::RustCall, - ty::CoroutineClosure(..) => Abi::RustCall, - ty::Coroutine(..) => Abi::Rust, + ty::Closure(..) => ExternAbi::RustCall, + ty::CoroutineClosure(..) => ExternAbi::RustCall, + ty::Coroutine(..) => ExternAbi::Rust, ty::Error(_) => return, _ => span_bug!(body.span, "unexpected body ty: {:?}", body_ty), }; @@ -79,10 +79,10 @@ impl<'tcx> crate::MirPass<'tcx> for AbortUnwindingCalls { } TerminatorKind::Drop { .. } => { tcx.sess.opts.unstable_opts.panic_in_drop == PanicStrategy::Unwind - && layout::fn_can_unwind(tcx, None, Abi::Rust) + && layout::fn_can_unwind(tcx, None, ExternAbi::Rust) } TerminatorKind::Assert { .. } | TerminatorKind::FalseUnwind { .. } => { - layout::fn_can_unwind(tcx, None, Abi::Rust) + layout::fn_can_unwind(tcx, None, ExternAbi::Rust) } TerminatorKind::InlineAsm { options, .. } => { options.contains(InlineAsmOptions::MAY_UNWIND) diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index 6d5665b43317f..063f220501f80 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -54,6 +54,7 @@ mod by_move_body; use std::{iter, ops}; pub(super) use by_move_body::coroutine_by_move_body_def_id; +use rustc_abi::{FieldIdx, VariantIdx}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::pluralize; use rustc_hir as hir; @@ -75,7 +76,6 @@ use rustc_mir_dataflow::storage::always_storage_live_locals; use rustc_span::Span; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::symbol::sym; -use rustc_target::abi::{FieldIdx, VariantIdx}; use rustc_target::spec::PanicStrategy; use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::infer::TyCtxtInferExt as _; diff --git a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs index 2c622b1927e52..36eb435c63a10 100644 --- a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs +++ b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs @@ -69,6 +69,7 @@ //! in case precise captures (edition 2021 closure capture rules) caused the inner coroutine //! to split one field capture into two. +use rustc_abi::{FieldIdx, VariantIdx}; use rustc_data_structures::steal::Steal; use rustc_data_structures::unord::UnordMap; use rustc_hir as hir; @@ -80,7 +81,6 @@ use rustc_middle::mir::visit::MutVisitor; use rustc_middle::mir::{self, dump_mir}; use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::symbol::kw; -use rustc_target::abi::{FieldIdx, VariantIdx}; pub(crate) fn coroutine_by_move_body_def_id<'tcx>( tcx: TyCtxt<'tcx>, diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index dd85d06540d12..7d073f1fa5794 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -662,7 +662,7 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> { // Exactly one side is known, attempt some algebraic simplifications. (FlatSet::Elem(const_arg), _) | (_, FlatSet::Elem(const_arg)) => { let layout = const_arg.layout; - if !matches!(layout.backend_repr, rustc_target::abi::BackendRepr::Scalar(..)) { + if !matches!(layout.backend_repr, rustc_abi::BackendRepr::Scalar(..)) { return (FlatSet::Top, FlatSet::Top); } diff --git a/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs b/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs index 57f7a9ef7f5fc..b909dfa132052 100644 --- a/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs +++ b/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs @@ -2,13 +2,13 @@ //! //! Box is not actually a pointer so it is incorrect to dereference it directly. +use rustc_abi::FieldIdx; use rustc_hir::def_id::DefId; use rustc_middle::mir::patch::MirPatch; use rustc_middle::mir::visit::MutVisitor; use rustc_middle::mir::*; use rustc_middle::span_bug; use rustc_middle::ty::{Ty, TyCtxt}; -use rustc_target::abi::FieldIdx; /// Constructs the types used when accessing a Box's pointer fn build_ptr_tys<'tcx>( diff --git a/compiler/rustc_mir_transform/src/elaborate_drops.rs b/compiler/rustc_mir_transform/src/elaborate_drops.rs index 58e1db194380f..74572100db3f9 100644 --- a/compiler/rustc_mir_transform/src/elaborate_drops.rs +++ b/compiler/rustc_mir_transform/src/elaborate_drops.rs @@ -1,5 +1,6 @@ use std::fmt; +use rustc_abi::{FieldIdx, VariantIdx}; use rustc_index::IndexVec; use rustc_index::bit_set::BitSet; use rustc_middle::mir::patch::MirPatch; @@ -14,7 +15,6 @@ use rustc_mir_dataflow::{ Analysis, MoveDataParamEnv, ResultsCursor, on_all_children_bits, on_lookup_result_bits, }; use rustc_span::Span; -use rustc_target::abi::{FieldIdx, VariantIdx}; use tracing::{debug, instrument}; use crate::deref_separator::deref_finder; diff --git a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs index 99892a1296be4..3d560bdf75c31 100644 --- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs +++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs @@ -1,3 +1,4 @@ +use rustc_abi::ExternAbi; use rustc_hir::def_id::{LOCAL_CRATE, LocalDefId}; use rustc_middle::mir::*; use rustc_middle::query::{LocalCrate, Providers}; @@ -5,7 +6,6 @@ use rustc_middle::ty::{self, TyCtxt, layout}; use rustc_middle::{bug, span_bug}; use rustc_session::lint::builtin::FFI_UNWIND_CALLS; use rustc_target::spec::PanicStrategy; -use rustc_target::spec::abi::Abi; use tracing::debug; use crate::errors; @@ -26,9 +26,9 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { let body_ty = tcx.type_of(def_id).skip_binder(); let body_abi = match body_ty.kind() { ty::FnDef(..) => body_ty.fn_sig(tcx).abi(), - ty::Closure(..) => Abi::RustCall, - ty::CoroutineClosure(..) => Abi::RustCall, - ty::Coroutine(..) => Abi::Rust, + ty::Closure(..) => ExternAbi::RustCall, + ty::CoroutineClosure(..) => ExternAbi::RustCall, + ty::Coroutine(..) => ExternAbi::Rust, ty::Error(_) => return false, _ => span_bug!(body.span, "unexpected body ty: {:?}", body_ty), }; @@ -53,7 +53,11 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { // Rust calls cannot themselves create foreign unwinds. // We assume this is true for intrinsics as well. - if let Abi::RustIntrinsic | Abi::Rust | Abi::RustCall | Abi::RustCold = sig.abi() { + if let ExternAbi::RustIntrinsic + | ExternAbi::Rust + | ExternAbi::RustCall + | ExternAbi::RustCold = sig.abi() + { continue; }; diff --git a/compiler/rustc_mir_transform/src/function_item_references.rs b/compiler/rustc_mir_transform/src/function_item_references.rs index e55aeeac6e069..2945fc6f3d564 100644 --- a/compiler/rustc_mir_transform/src/function_item_references.rs +++ b/compiler/rustc_mir_transform/src/function_item_references.rs @@ -1,4 +1,5 @@ use itertools::Itertools; +use rustc_abi::ExternAbi; use rustc_hir::def_id::DefId; use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::*; @@ -7,7 +8,6 @@ use rustc_session::lint::builtin::FUNCTION_ITEM_REFERENCES; use rustc_span::Span; use rustc_span::source_map::Spanned; use rustc_span::symbol::sym; -use rustc_target::spec::abi::Abi; use crate::errors; @@ -161,7 +161,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> { let fn_sig = self.tcx.fn_sig(fn_id).instantiate(self.tcx, fn_args); let unsafety = fn_sig.safety().prefix_str(); let abi = match fn_sig.abi() { - Abi::Rust => String::from(""), + ExternAbi::Rust => String::from(""), other_abi => { let mut s = String::from("extern \""); s.push_str(other_abi.name()); diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 404470db5c5bb..e95ab4ffe16cc 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -3,6 +3,7 @@ use std::iter; use std::ops::{Range, RangeFrom}; +use rustc_abi::{ExternAbi, FieldIdx}; use rustc_attr::InlineAttr; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; @@ -18,8 +19,6 @@ use rustc_middle::ty::{ use rustc_session::config::{DebugInfo, OptLevel}; use rustc_span::source_map::Spanned; use rustc_span::sym; -use rustc_target::abi::FieldIdx; -use rustc_target::spec::abi::Abi; use tracing::{debug, instrument, trace, trace_span}; use crate::cost_checker::CostChecker; @@ -254,7 +253,7 @@ impl<'tcx> Inliner<'tcx> { trace!(?output_type, ?destination_ty); return Err("failed to normalize return type"); } - if callsite.fn_sig.abi() == Abi::RustCall { + if callsite.fn_sig.abi() == ExternAbi::RustCall { // FIXME: Don't inline user-written `extern "rust-call"` functions, // since this is generally perf-negative on rustc, and we hope that // LLVM will inline these functions instead. @@ -808,7 +807,7 @@ impl<'tcx> Inliner<'tcx> { // tmp2 = tuple_tmp.2 // // and the vector is `[closure_ref, tmp0, tmp1, tmp2]`. - if callsite.fn_sig.abi() == Abi::RustCall && callee_body.spread_arg.is_none() { + if callsite.fn_sig.abi() == ExternAbi::RustCall && callee_body.spread_arg.is_none() { // FIXME(edition_2024): switch back to a normal method call. let mut args = <_>::into_iter(args); let self_ = self.create_temp_if_necessary( diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index 8bcc91b448858..9471c1b2a9a14 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -1,5 +1,6 @@ //! Performs various peephole optimizations. +use rustc_abi::ExternAbi; use rustc_ast::attr; use rustc_hir::LangItem; use rustc_middle::bug; @@ -8,7 +9,6 @@ use rustc_middle::ty::layout::ValidityRequirement; use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt, layout}; use rustc_span::sym; use rustc_span::symbol::Symbol; -use rustc_target::spec::abi::Abi; use crate::simplify::simplify_duplicate_switch_targets; use crate::take_array; @@ -321,8 +321,8 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> { let body_ty = self.tcx.type_of(def_id).skip_binder(); let body_abi = match body_ty.kind() { ty::FnDef(..) => body_ty.fn_sig(self.tcx).abi(), - ty::Closure(..) => Abi::RustCall, - ty::Coroutine(..) => Abi::Rust, + ty::Closure(..) => ExternAbi::RustCall, + ty::Coroutine(..) => ExternAbi::Rust, _ => bug!("unexpected body ty: {:?}", body_ty), }; diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index 9b9b0b705bfec..3772589ac4ea0 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -35,6 +35,7 @@ //! Likewise, applying the optimisation can create a lot of new MIR, so we bound the instruction //! cost by `MAX_COST`. +use rustc_abi::{TagEncoding, Variants}; use rustc_arena::DroplessArena; use rustc_const_eval::const_eval::DummyMachine; use rustc_const_eval::interpret::{ImmTy, Immediate, InterpCx, OpTy, Projectable}; @@ -50,7 +51,6 @@ use rustc_middle::ty::{self, ScalarInt, TyCtxt}; use rustc_mir_dataflow::lattice::HasBottom; use rustc_mir_dataflow::value_analysis::{Map, PlaceIndex, State, TrackElem}; use rustc_span::DUMMY_SP; -use rustc_target::abi::{TagEncoding, Variants}; use tracing::{debug, instrument, trace}; use crate::cost_checker::CostChecker; diff --git a/compiler/rustc_mir_transform/src/large_enums.rs b/compiler/rustc_mir_transform/src/large_enums.rs index 3e263aa406774..fa659a56a274c 100644 --- a/compiler/rustc_mir_transform/src/large_enums.rs +++ b/compiler/rustc_mir_transform/src/large_enums.rs @@ -1,10 +1,10 @@ +use rustc_abi::{HasDataLayout, Size, TagEncoding, Variants}; use rustc_data_structures::fx::FxHashMap; use rustc_middle::mir::interpret::AllocId; use rustc_middle::mir::*; use rustc_middle::ty::util::IntTypeExt; use rustc_middle::ty::{self, AdtDef, ParamEnv, Ty, TyCtxt}; use rustc_session::Session; -use rustc_target::abi::{HasDataLayout, Size, TagEncoding, Variants}; /// A pass that seeks to optimize unnecessary moves of large enum types, if there is a large /// enough discrepancy between them. @@ -249,8 +249,8 @@ impl EnumSizeOpt { macro_rules! encode_store { ($curr_idx: expr, $endian: expr, $bytes: expr) => { let bytes = match $endian { - rustc_target::abi::Endian::Little => $bytes.to_le_bytes(), - rustc_target::abi::Endian::Big => $bytes.to_be_bytes(), + rustc_abi::Endian::Little => $bytes.to_le_bytes(), + rustc_abi::Endian::Big => $bytes.to_be_bytes(), }; for (i, b) in bytes.into_iter().enumerate() { data[$curr_idx + i] = b; @@ -263,10 +263,10 @@ impl EnumSizeOpt { target_bytes * adt_def.discriminant_for_variant(tcx, var_idx).val as usize; let sz = layout.size; match ptr_sized_int { - rustc_target::abi::Integer::I32 => { + rustc_abi::Integer::I32 => { encode_store!(curr_idx, data_layout.endian, sz.bytes() as u32); } - rustc_target::abi::Integer::I64 => { + rustc_abi::Integer::I64 => { encode_store!(curr_idx, data_layout.endian, sz.bytes()); } _ => unreachable!(), diff --git a/compiler/rustc_mir_transform/src/match_branches.rs b/compiler/rustc_mir_transform/src/match_branches.rs index ad3126f66a67e..237227f5294dc 100644 --- a/compiler/rustc_mir_transform/src/match_branches.rs +++ b/compiler/rustc_mir_transform/src/match_branches.rs @@ -1,11 +1,11 @@ use std::iter; +use rustc_abi::Integer; use rustc_index::IndexSlice; use rustc_middle::mir::patch::MirPatch; use rustc_middle::mir::*; use rustc_middle::ty::layout::{IntegerExt, TyAndLayout}; use rustc_middle::ty::{ParamEnv, ScalarInt, Ty, TyCtxt}; -use rustc_target::abi::Integer; use rustc_type_ir::TyKind::*; use super::simplify::simplify_cfg; diff --git a/compiler/rustc_mir_transform/src/remove_uninit_drops.rs b/compiler/rustc_mir_transform/src/remove_uninit_drops.rs index 55dd96100b0a6..20c34a7469e38 100644 --- a/compiler/rustc_mir_transform/src/remove_uninit_drops.rs +++ b/compiler/rustc_mir_transform/src/remove_uninit_drops.rs @@ -1,10 +1,10 @@ +use rustc_abi::FieldIdx; use rustc_index::bit_set::ChunkedBitSet; use rustc_middle::mir::{Body, TerminatorKind}; use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt, VariantDef}; use rustc_mir_dataflow::impls::MaybeInitializedPlaces; use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex}; use rustc_mir_dataflow::{Analysis, MaybeReachable, move_path_children_matching}; -use rustc_target::abi::FieldIdx; /// Removes `Drop` terminators whose target is known to be uninitialized at /// that point. diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index e872878a751ed..ffa11f5b21356 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -1,6 +1,7 @@ use std::assert_matches::assert_matches; use std::{fmt, iter}; +use rustc_abi::{ExternAbi, FIRST_VARIANT, FieldIdx, VariantIdx}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::lang_items::LangItem; @@ -15,8 +16,6 @@ use rustc_middle::{bug, span_bug}; use rustc_mir_dataflow::elaborate_drops::{self, DropElaborator, DropFlagMode, DropStyle}; use rustc_span::source_map::Spanned; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::abi::{FIRST_VARIANT, FieldIdx, VariantIdx}; -use rustc_target::spec::abi::Abi; use tracing::{debug, instrument}; use crate::{ @@ -905,7 +904,7 @@ fn build_call_shim<'tcx>( let mut body = new_body(MirSource::from_instance(instance), blocks, local_decls, sig.inputs().len(), span); - if let Abi::RustCall = sig.abi { + if let ExternAbi::RustCall = sig.abi { body.spread_arg = Some(Local::new(sig.inputs().len())); } diff --git a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs index 71723f040b3b6..f1672272862c0 100644 --- a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs +++ b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs @@ -1,6 +1,7 @@ use std::iter; use itertools::Itertools; +use rustc_abi::{FieldIdx, VariantIdx}; use rustc_ast::Mutability; use rustc_const_eval::interpret; use rustc_hir::def_id::DefId; @@ -18,7 +19,6 @@ use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::{bug, span_bug}; use rustc_span::source_map::respan; use rustc_span::{Span, Symbol}; -use rustc_target::abi::{FieldIdx, VariantIdx}; use rustc_target::spec::PanicStrategy; use tracing::debug; diff --git a/compiler/rustc_mir_transform/src/sroa.rs b/compiler/rustc_mir_transform/src/sroa.rs index 2de0059bc7fd7..53bbb1220967b 100644 --- a/compiler/rustc_mir_transform/src/sroa.rs +++ b/compiler/rustc_mir_transform/src/sroa.rs @@ -1,3 +1,4 @@ +use rustc_abi::{FIRST_VARIANT, FieldIdx}; use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_hir::LangItem; use rustc_index::IndexVec; @@ -8,7 +9,6 @@ use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_mir_dataflow::value_analysis::{excluded_locals, iter_fields}; -use rustc_target::abi::{FIRST_VARIANT, FieldIdx}; use tracing::{debug, instrument}; pub(super) struct ScalarReplacementOfAggregates; diff --git a/compiler/rustc_mir_transform/src/unreachable_prop.rs b/compiler/rustc_mir_transform/src/unreachable_prop.rs index f3dafd13824f3..9cd32459c7b48 100644 --- a/compiler/rustc_mir_transform/src/unreachable_prop.rs +++ b/compiler/rustc_mir_transform/src/unreachable_prop.rs @@ -2,13 +2,13 @@ //! when all of their successors are unreachable. This is achieved through a //! post-order traversal of the blocks. +use rustc_abi::Size; use rustc_data_structures::fx::FxHashSet; use rustc_middle::bug; use rustc_middle::mir::interpret::Scalar; use rustc_middle::mir::patch::MirPatch; use rustc_middle::mir::*; use rustc_middle::ty::{self, TyCtxt}; -use rustc_target::abi::Size; pub(super) struct UnreachablePropagation; diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index 8109a9b8ba0d1..ae4e6ea6a7497 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -1,5 +1,6 @@ //! Validates the MIR to ensure that invariants are upheld. +use rustc_abi::{ExternAbi, FIRST_VARIANT, Size}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::LangItem; use rustc_index::IndexVec; @@ -15,8 +16,6 @@ use rustc_middle::ty::{ Variance, }; use rustc_middle::{bug, span_bug}; -use rustc_target::abi::{FIRST_VARIANT, Size}; -use rustc_target::spec::abi::Abi; use rustc_trait_selection::traits::ObligationCtxt; use rustc_type_ir::Upcast; @@ -60,9 +59,9 @@ impl<'tcx> crate::MirPass<'tcx> for Validator { let body_ty = tcx.type_of(def_id).skip_binder(); let body_abi = match body_ty.kind() { ty::FnDef(..) => body_ty.fn_sig(tcx).abi(), - ty::Closure(..) => Abi::RustCall, - ty::CoroutineClosure(..) => Abi::RustCall, - ty::Coroutine(..) => Abi::Rust, + ty::Closure(..) => ExternAbi::RustCall, + ty::CoroutineClosure(..) => ExternAbi::RustCall, + ty::Coroutine(..) => ExternAbi::Rust, // No need to do MIR validation on error bodies ty::Error(_) => return, _ => { From 6c16a3123b2078d35dd726342d5df7e6763ffdbb Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 2 Nov 2024 19:33:04 -0700 Subject: [PATCH 06/11] compiler: Directly use rustc_abi in smir again --- .../rustc_smir/src/rustc_internal/internal.rs | 58 +++++++++---------- compiler/rustc_smir/src/rustc_smir/context.rs | 2 +- .../rustc_smir/src/rustc_smir/convert/mod.rs | 2 +- .../rustc_smir/src/rustc_smir/convert/ty.rs | 54 ++++++++--------- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_internal/internal.rs b/compiler/rustc_smir/src/rustc_internal/internal.rs index 7be7db1fd3d33..655553de864f1 100644 --- a/compiler/rustc_smir/src/rustc_internal/internal.rs +++ b/compiler/rustc_smir/src/rustc_internal/internal.rs @@ -237,10 +237,10 @@ impl RustcInternal for FnSig { } impl RustcInternal for VariantIdx { - type T<'tcx> = rustc_target::abi::VariantIdx; + type T<'tcx> = rustc_abi::VariantIdx; fn internal<'tcx>(&self, _tables: &mut Tables<'_>, _tcx: TyCtxt<'tcx>) -> Self::T<'tcx> { - rustc_target::abi::VariantIdx::from(self.to_index()) + rustc_abi::VariantIdx::from(self.to_index()) } } @@ -451,35 +451,35 @@ impl RustcInternal for AdtDef { } impl RustcInternal for Abi { - type T<'tcx> = rustc_target::spec::abi::Abi; + type T<'tcx> = rustc_abi::ExternAbi; fn internal<'tcx>(&self, _tables: &mut Tables<'_>, _tcx: TyCtxt<'tcx>) -> Self::T<'tcx> { match *self { - Abi::Rust => rustc_target::spec::abi::Abi::Rust, - Abi::C { unwind } => rustc_target::spec::abi::Abi::C { unwind }, - Abi::Cdecl { unwind } => rustc_target::spec::abi::Abi::Cdecl { unwind }, - Abi::Stdcall { unwind } => rustc_target::spec::abi::Abi::Stdcall { unwind }, - Abi::Fastcall { unwind } => rustc_target::spec::abi::Abi::Fastcall { unwind }, - Abi::Vectorcall { unwind } => rustc_target::spec::abi::Abi::Vectorcall { unwind }, - Abi::Thiscall { unwind } => rustc_target::spec::abi::Abi::Thiscall { unwind }, - Abi::Aapcs { unwind } => rustc_target::spec::abi::Abi::Aapcs { unwind }, - Abi::Win64 { unwind } => rustc_target::spec::abi::Abi::Win64 { unwind }, - Abi::SysV64 { unwind } => rustc_target::spec::abi::Abi::SysV64 { unwind }, - Abi::PtxKernel => rustc_target::spec::abi::Abi::PtxKernel, - Abi::Msp430Interrupt => rustc_target::spec::abi::Abi::Msp430Interrupt, - Abi::X86Interrupt => rustc_target::spec::abi::Abi::X86Interrupt, - Abi::EfiApi => rustc_target::spec::abi::Abi::EfiApi, - Abi::AvrInterrupt => rustc_target::spec::abi::Abi::AvrInterrupt, - Abi::AvrNonBlockingInterrupt => rustc_target::spec::abi::Abi::AvrNonBlockingInterrupt, - Abi::CCmseNonSecureCall => rustc_target::spec::abi::Abi::CCmseNonSecureCall, - Abi::CCmseNonSecureEntry => rustc_target::spec::abi::Abi::CCmseNonSecureEntry, - Abi::System { unwind } => rustc_target::spec::abi::Abi::System { unwind }, - Abi::RustIntrinsic => rustc_target::spec::abi::Abi::RustIntrinsic, - Abi::RustCall => rustc_target::spec::abi::Abi::RustCall, - Abi::Unadjusted => rustc_target::spec::abi::Abi::Unadjusted, - Abi::RustCold => rustc_target::spec::abi::Abi::RustCold, - Abi::RiscvInterruptM => rustc_target::spec::abi::Abi::RiscvInterruptM, - Abi::RiscvInterruptS => rustc_target::spec::abi::Abi::RiscvInterruptS, + Abi::Rust => rustc_abi::ExternAbi::Rust, + Abi::C { unwind } => rustc_abi::ExternAbi::C { unwind }, + Abi::Cdecl { unwind } => rustc_abi::ExternAbi::Cdecl { unwind }, + Abi::Stdcall { unwind } => rustc_abi::ExternAbi::Stdcall { unwind }, + Abi::Fastcall { unwind } => rustc_abi::ExternAbi::Fastcall { unwind }, + Abi::Vectorcall { unwind } => rustc_abi::ExternAbi::Vectorcall { unwind }, + Abi::Thiscall { unwind } => rustc_abi::ExternAbi::Thiscall { unwind }, + Abi::Aapcs { unwind } => rustc_abi::ExternAbi::Aapcs { unwind }, + Abi::Win64 { unwind } => rustc_abi::ExternAbi::Win64 { unwind }, + Abi::SysV64 { unwind } => rustc_abi::ExternAbi::SysV64 { unwind }, + Abi::PtxKernel => rustc_abi::ExternAbi::PtxKernel, + Abi::Msp430Interrupt => rustc_abi::ExternAbi::Msp430Interrupt, + Abi::X86Interrupt => rustc_abi::ExternAbi::X86Interrupt, + Abi::EfiApi => rustc_abi::ExternAbi::EfiApi, + Abi::AvrInterrupt => rustc_abi::ExternAbi::AvrInterrupt, + Abi::AvrNonBlockingInterrupt => rustc_abi::ExternAbi::AvrNonBlockingInterrupt, + Abi::CCmseNonSecureCall => rustc_abi::ExternAbi::CCmseNonSecureCall, + Abi::CCmseNonSecureEntry => rustc_abi::ExternAbi::CCmseNonSecureEntry, + Abi::System { unwind } => rustc_abi::ExternAbi::System { unwind }, + Abi::RustIntrinsic => rustc_abi::ExternAbi::RustIntrinsic, + Abi::RustCall => rustc_abi::ExternAbi::RustCall, + Abi::Unadjusted => rustc_abi::ExternAbi::Unadjusted, + Abi::RustCold => rustc_abi::ExternAbi::RustCold, + Abi::RiscvInterruptM => rustc_abi::ExternAbi::RiscvInterruptM, + Abi::RiscvInterruptS => rustc_abi::ExternAbi::RiscvInterruptS, } } } @@ -503,7 +503,7 @@ impl RustcInternal for Span { } impl RustcInternal for Layout { - type T<'tcx> = rustc_target::abi::Layout<'tcx>; + type T<'tcx> = rustc_abi::Layout<'tcx>; fn internal<'tcx>(&self, tables: &mut Tables<'_>, tcx: TyCtxt<'tcx>) -> Self::T<'tcx> { tcx.lift(tables.layouts[*self]).unwrap() diff --git a/compiler/rustc_smir/src/rustc_smir/context.rs b/compiler/rustc_smir/src/rustc_smir/context.rs index 9514ec883ae52..2d6ca3571fadf 100644 --- a/compiler/rustc_smir/src/rustc_smir/context.rs +++ b/compiler/rustc_smir/src/rustc_smir/context.rs @@ -786,7 +786,7 @@ pub(crate) struct TablesWrapper<'tcx>(pub RefCell>); /// Implement error handling for extracting function ABI information. impl<'tcx> FnAbiOfHelpers<'tcx> for Tables<'tcx> { - type FnAbiOfResult = Result<&'tcx rustc_target::abi::call::FnAbi<'tcx, ty::Ty<'tcx>>, Error>; + type FnAbiOfResult = Result<&'tcx rustc_target::callconv::FnAbi<'tcx, ty::Ty<'tcx>>, Error>; #[inline] fn handle_fn_abi_err( diff --git a/compiler/rustc_smir/src/rustc_smir/convert/mod.rs b/compiler/rustc_smir/src/rustc_smir/convert/mod.rs index c9795fca3993a..4f8da08eff916 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/mod.rs @@ -1,6 +1,6 @@ //! Conversion of internal Rust compiler items to stable ones. -use rustc_target::abi::FieldIdx; +use rustc_abi::FieldIdx; use crate::rustc_smir::{Stable, Tables}; diff --git a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs index 8f05f859c0776..8c5100967641c 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs @@ -891,38 +891,38 @@ impl<'tcx> Stable<'tcx> for ty::Movability { } } -impl<'tcx> Stable<'tcx> for rustc_target::spec::abi::Abi { +impl<'tcx> Stable<'tcx> for rustc_abi::ExternAbi { type T = stable_mir::ty::Abi; fn stable(&self, _: &mut Tables<'_>) -> Self::T { - use rustc_target::spec::abi; + use rustc_abi::ExternAbi; use stable_mir::ty::Abi; match *self { - abi::Abi::Rust => Abi::Rust, - abi::Abi::C { unwind } => Abi::C { unwind }, - abi::Abi::Cdecl { unwind } => Abi::Cdecl { unwind }, - abi::Abi::Stdcall { unwind } => Abi::Stdcall { unwind }, - abi::Abi::Fastcall { unwind } => Abi::Fastcall { unwind }, - abi::Abi::Vectorcall { unwind } => Abi::Vectorcall { unwind }, - abi::Abi::Thiscall { unwind } => Abi::Thiscall { unwind }, - abi::Abi::Aapcs { unwind } => Abi::Aapcs { unwind }, - abi::Abi::Win64 { unwind } => Abi::Win64 { unwind }, - abi::Abi::SysV64 { unwind } => Abi::SysV64 { unwind }, - abi::Abi::PtxKernel => Abi::PtxKernel, - abi::Abi::Msp430Interrupt => Abi::Msp430Interrupt, - abi::Abi::X86Interrupt => Abi::X86Interrupt, - abi::Abi::EfiApi => Abi::EfiApi, - abi::Abi::AvrInterrupt => Abi::AvrInterrupt, - abi::Abi::AvrNonBlockingInterrupt => Abi::AvrNonBlockingInterrupt, - abi::Abi::CCmseNonSecureCall => Abi::CCmseNonSecureCall, - abi::Abi::CCmseNonSecureEntry => Abi::CCmseNonSecureEntry, - abi::Abi::System { unwind } => Abi::System { unwind }, - abi::Abi::RustIntrinsic => Abi::RustIntrinsic, - abi::Abi::RustCall => Abi::RustCall, - abi::Abi::Unadjusted => Abi::Unadjusted, - abi::Abi::RustCold => Abi::RustCold, - abi::Abi::RiscvInterruptM => Abi::RiscvInterruptM, - abi::Abi::RiscvInterruptS => Abi::RiscvInterruptS, + ExternAbi::Rust => Abi::Rust, + ExternAbi::C { unwind } => Abi::C { unwind }, + ExternAbi::Cdecl { unwind } => Abi::Cdecl { unwind }, + ExternAbi::Stdcall { unwind } => Abi::Stdcall { unwind }, + ExternAbi::Fastcall { unwind } => Abi::Fastcall { unwind }, + ExternAbi::Vectorcall { unwind } => Abi::Vectorcall { unwind }, + ExternAbi::Thiscall { unwind } => Abi::Thiscall { unwind }, + ExternAbi::Aapcs { unwind } => Abi::Aapcs { unwind }, + ExternAbi::Win64 { unwind } => Abi::Win64 { unwind }, + ExternAbi::SysV64 { unwind } => Abi::SysV64 { unwind }, + ExternAbi::PtxKernel => Abi::PtxKernel, + ExternAbi::Msp430Interrupt => Abi::Msp430Interrupt, + ExternAbi::X86Interrupt => Abi::X86Interrupt, + ExternAbi::EfiApi => Abi::EfiApi, + ExternAbi::AvrInterrupt => Abi::AvrInterrupt, + ExternAbi::AvrNonBlockingInterrupt => Abi::AvrNonBlockingInterrupt, + ExternAbi::CCmseNonSecureCall => Abi::CCmseNonSecureCall, + ExternAbi::CCmseNonSecureEntry => Abi::CCmseNonSecureEntry, + ExternAbi::System { unwind } => Abi::System { unwind }, + ExternAbi::RustIntrinsic => Abi::RustIntrinsic, + ExternAbi::RustCall => Abi::RustCall, + ExternAbi::Unadjusted => Abi::Unadjusted, + ExternAbi::RustCold => Abi::RustCold, + ExternAbi::RiscvInterruptM => Abi::RiscvInterruptM, + ExternAbi::RiscvInterruptS => Abi::RiscvInterruptS, } } } From 092135b7b4564ca1156fd3d1af9db7a78a0c3d73 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 2 Nov 2024 19:33:06 -0700 Subject: [PATCH 07/11] compiler: Directly use rustc_abi in ty_utils --- compiler/rustc_ty_utils/src/abi.rs | 29 +++++++++---------- compiler/rustc_ty_utils/src/consts.rs | 2 +- compiler/rustc_ty_utils/src/layout.rs | 7 ++--- .../rustc_ty_utils/src/layout/invariant.rs | 2 +- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 722ef5f456982..42b710687cfdf 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -1,7 +1,7 @@ use std::iter; use rustc_abi::Primitive::Pointer; -use rustc_abi::{BackendRepr, PointerKind, Scalar, Size}; +use rustc_abi::{BackendRepr, ExternAbi, PointerKind, Scalar, Size}; use rustc_hir as hir; use rustc_hir::lang_items::LangItem; use rustc_middle::bug; @@ -12,10 +12,9 @@ use rustc_middle::ty::layout::{ use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt}; use rustc_session::config::OptLevel; use rustc_span::def_id::DefId; -use rustc_target::abi::call::{ +use rustc_target::callconv::{ ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, Conv, FnAbi, PassMode, RiscvInterruptKind, }; -use rustc_target::spec::abi::Abi as SpecAbi; use tracing::debug; pub(crate) fn provide(providers: &mut Providers) { @@ -39,7 +38,7 @@ fn fn_sig_for_fn_abi<'tcx>( tcx.thread_local_ptr_ty(instance.def_id()), false, hir::Safety::Safe, - rustc_target::spec::abi::Abi::Unadjusted, + rustc_abi::ExternAbi::Unadjusted, )); } @@ -270,7 +269,7 @@ fn fn_sig_for_fn_abi<'tcx>( ret_ty, false, hir::Safety::Safe, - rustc_target::spec::abi::Abi::Rust, + rustc_abi::ExternAbi::Rust, ) } else { // `Iterator::next` doesn't have a `resume` argument. @@ -279,7 +278,7 @@ fn fn_sig_for_fn_abi<'tcx>( ret_ty, false, hir::Safety::Safe, - rustc_target::spec::abi::Abi::Rust, + rustc_abi::ExternAbi::Rust, ) }; ty::Binder::bind_with_vars(fn_sig, bound_vars) @@ -289,8 +288,8 @@ fn fn_sig_for_fn_abi<'tcx>( } #[inline] -fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv { - use rustc_target::spec::abi::Abi::*; +fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: ExternAbi, c_variadic: bool) -> Conv { + use rustc_abi::ExternAbi::*; match tcx.sess.target.adjust_abi(abi, c_variadic) { RustIntrinsic | Rust | RustCall => Conv::Rust, @@ -453,12 +452,12 @@ fn adjust_for_rust_scalar<'tcx>( fn fn_abi_sanity_check<'tcx>( cx: &LayoutCx<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, - spec_abi: SpecAbi, + spec_abi: ExternAbi, ) { fn fn_arg_sanity_check<'tcx>( cx: &LayoutCx<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, - spec_abi: SpecAbi, + spec_abi: ExternAbi, arg: &ArgAbi<'tcx, Ty<'tcx>>, ) { let tcx = cx.tcx(); @@ -489,7 +488,7 @@ fn fn_abi_sanity_check<'tcx>( // (See issue: https://github.com/rust-lang/rust/issues/117271) assert!( matches!(&*tcx.sess.target.arch, "wasm32" | "wasm64") - || matches!(spec_abi, SpecAbi::PtxKernel | SpecAbi::Unadjusted), + || matches!(spec_abi, ExternAbi::PtxKernel | ExternAbi::Unadjusted), "`PassMode::Direct` for aggregates only allowed for \"unadjusted\" and \"ptx-kernel\" functions and on wasm\n\ Problematic type: {:#?}", arg.layout, @@ -556,7 +555,7 @@ fn fn_abi_new_uncached<'tcx>( let conv = conv_from_spec_abi(cx.tcx(), sig.abi, sig.c_variadic); let mut inputs = sig.inputs(); - let extra_args = if sig.abi == SpecAbi::RustCall { + let extra_args = if sig.abi == ExternAbi::RustCall { assert!(!sig.c_variadic && extra_args.is_empty()); if let Some(input) = sig.inputs().last() { @@ -649,10 +648,10 @@ fn fn_abi_new_uncached<'tcx>( fn fn_abi_adjust_for_abi<'tcx>( cx: &LayoutCx<'tcx>, fn_abi: &mut FnAbi<'tcx, Ty<'tcx>>, - abi: SpecAbi, + abi: ExternAbi, fn_def_id: Option, ) -> Result<(), &'tcx FnAbiError<'tcx>> { - if abi == SpecAbi::Unadjusted { + if abi == ExternAbi::Unadjusted { // The "unadjusted" ABI passes aggregates in "direct" mode. That's fragile but needed for // some LLVM intrinsics. fn unadjust<'tcx>(arg: &mut ArgAbi<'tcx, Ty<'tcx>>) { @@ -676,7 +675,7 @@ fn fn_abi_adjust_for_abi<'tcx>( let tcx = cx.tcx(); - if abi == SpecAbi::Rust || abi == SpecAbi::RustCall || abi == SpecAbi::RustIntrinsic { + if abi == ExternAbi::Rust || abi == ExternAbi::RustCall || abi == ExternAbi::RustIntrinsic { fn_abi.adjust_for_rust_abi(cx, abi); // Look up the deduced parameter attributes for this function, if we have its def ID and diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index 4b770d9938c2b..637e239a57010 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -1,5 +1,6 @@ use std::iter; +use rustc_abi::{FIRST_VARIANT, VariantIdx}; use rustc_errors::ErrorGuaranteed; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; @@ -11,7 +12,6 @@ use rustc_middle::ty::abstract_const::CastKind; use rustc_middle::ty::{self, Expr, TyCtxt, TypeVisitableExt}; use rustc_middle::{bug, mir, thir}; use rustc_span::Span; -use rustc_target::abi::{FIRST_VARIANT, VariantIdx}; use tracing::{debug, instrument}; use crate::errors::{GenericConstantTooComplex, GenericConstantTooComplexSub}; diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 5ca7afe245396..63421dfdce6cd 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -5,9 +5,9 @@ use hir::def_id::DefId; use rustc_abi::Integer::{I8, I32}; use rustc_abi::Primitive::{self, Float, Int, Pointer}; use rustc_abi::{ - AbiAndPrefAlign, AddressSpace, Align, BackendRepr, FieldsShape, HasDataLayout, - LayoutCalculatorError, LayoutData, Niche, ReprOptions, Scalar, Size, StructKind, TagEncoding, - Variants, WrappingRange, + AbiAndPrefAlign, AddressSpace, Align, BackendRepr, FIRST_VARIANT, FieldIdx, FieldsShape, + HasDataLayout, Layout, LayoutCalculatorError, LayoutData, Niche, ReprOptions, Scalar, Size, + StructKind, TagEncoding, VariantIdx, Variants, WrappingRange, }; use rustc_index::bit_set::BitSet; use rustc_index::{IndexSlice, IndexVec}; @@ -24,7 +24,6 @@ use rustc_middle::ty::{ use rustc_session::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo}; use rustc_span::sym; use rustc_span::symbol::Symbol; -use rustc_target::abi::{FIRST_VARIANT, FieldIdx, Layout, VariantIdx}; use tracing::{debug, instrument, trace}; use {rustc_abi as abi, rustc_hir as hir}; diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index f43feb552b289..fc05dd8256b61 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -1,8 +1,8 @@ use std::assert_matches::assert_matches; +use rustc_abi::{BackendRepr, FieldsShape, Scalar, Size, Variants}; use rustc_middle::bug; use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, TyAndLayout}; -use rustc_target::abi::*; /// Enforce some basic invariants on layouts. pub(super) fn partially_check_layout<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayout<'tcx>) { From 586e141be7b0b66412c386f74a8fe3c79cd7943d Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 2 Nov 2024 19:33:36 -0700 Subject: [PATCH 08/11] compiler: Directly use rustc_abi in lints --- compiler/rustc_lint/src/nonstandard_style.rs | 6 +++--- compiler/rustc_lint/src/types.rs | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index 1c27e1daa9066..c5f0b94327f5b 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -1,3 +1,4 @@ +use rustc_abi::ExternAbi; use rustc_hir::def::{DefKind, Res}; use rustc_hir::intravisit::FnKind; use rustc_hir::{GenericParamKind, PatKind}; @@ -7,7 +8,6 @@ use rustc_session::{declare_lint, declare_lint_pass}; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::{Ident, sym}; use rustc_span::{BytePos, Span}; -use rustc_target::spec::abi::Abi; use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; use crate::lints::{ @@ -397,7 +397,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase { match &fk { FnKind::Method(ident, sig, ..) => match method_context(cx, id) { MethodLateContext::PlainImpl => { - if sig.header.abi != Abi::Rust && cx.tcx.has_attr(id, sym::no_mangle) { + if sig.header.abi != ExternAbi::Rust && cx.tcx.has_attr(id, sym::no_mangle) { return; } self.check_snake_case(cx, "method", ident); @@ -409,7 +409,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase { }, FnKind::ItemFn(ident, _, header) => { // Skip foreign-ABI #[no_mangle] functions (Issue #31924) - if header.abi != Abi::Rust && cx.tcx.has_attr(id, sym::no_mangle) { + if header.abi != ExternAbi::Rust && cx.tcx.has_attr(id, sym::no_mangle) { return; } self.check_snake_case(cx, "function", ident); diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 48dd8e38a036a..be70149b664db 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1,7 +1,7 @@ use std::iter; use std::ops::ControlFlow; -use rustc_abi::{BackendRepr, TagEncoding, Variants, WrappingRange}; +use rustc_abi::{BackendRepr, ExternAbi, TagEncoding, Variants, WrappingRange}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::DiagMessage; use rustc_hir::{Expr, ExprKind}; @@ -14,7 +14,6 @@ use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass}; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::sym; use rustc_span::{Span, Symbol, source_map}; -use rustc_target::spec::abi::Abi as SpecAbi; use tracing::debug; use {rustc_ast as ast, rustc_hir as hir}; @@ -1294,10 +1293,10 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { self.check_type_for_ffi_and_report_errors(span, ty, true, false); } - fn is_internal_abi(&self, abi: SpecAbi) -> bool { + fn is_internal_abi(&self, abi: ExternAbi) -> bool { matches!( abi, - SpecAbi::Rust | SpecAbi::RustCall | SpecAbi::RustCold | SpecAbi::RustIntrinsic + ExternAbi::Rust | ExternAbi::RustCall | ExternAbi::RustCold | ExternAbi::RustIntrinsic ) } From 7639773e702787332595061c910f1d30f217261a Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 2 Nov 2024 19:33:41 -0700 Subject: [PATCH 09/11] compiler: Directly use rustc_abi in session --- compiler/rustc_session/src/cstore.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_session/src/cstore.rs b/compiler/rustc_session/src/cstore.rs index 041a10475eaad..29d3d608388b9 100644 --- a/compiler/rustc_session/src/cstore.rs +++ b/compiler/rustc_session/src/cstore.rs @@ -5,6 +5,7 @@ use std::any::Any; use std::path::PathBuf; +use rustc_abi::ExternAbi; use rustc_ast as ast; use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock}; use rustc_hir::def_id::{ @@ -14,7 +15,6 @@ use rustc_hir::definitions::{DefKey, DefPath, DefPathHash, Definitions}; use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_span::Span; use rustc_span::symbol::Symbol; -use rustc_target::spec::abi::Abi; use crate::search_paths::PathKind; use crate::utils::NativeLibKind; @@ -148,7 +148,7 @@ pub enum DllCallingConvention { pub struct ForeignModule { pub foreign_items: Vec, pub def_id: DefId, - pub abi: Abi, + pub abi: ExternAbi, } #[derive(Copy, Clone, Debug, HashStable_Generic)] From 5c953ee91098b9f0c828ba1cb0085af12f1fcde8 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 2 Nov 2024 19:33:42 -0700 Subject: [PATCH 10/11] compiler: Replace rustc_target with abi in symbol_mangling --- Cargo.lock | 1 - compiler/rustc_symbol_mangling/Cargo.toml | 1 - compiler/rustc_symbol_mangling/src/v0.rs | 7 +++---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 500992ff8c127..a24d6480260ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4437,7 +4437,6 @@ dependencies = [ "rustc_middle", "rustc_session", "rustc_span", - "rustc_target", "tracing", ] diff --git a/compiler/rustc_symbol_mangling/Cargo.toml b/compiler/rustc_symbol_mangling/Cargo.toml index 644e710d1db84..1fb647cab5b57 100644 --- a/compiler/rustc_symbol_mangling/Cargo.toml +++ b/compiler/rustc_symbol_mangling/Cargo.toml @@ -15,6 +15,5 @@ rustc_hir = { path = "../rustc_hir" } rustc_middle = { path = "../rustc_middle" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } -rustc_target = { path = "../rustc_target" } tracing = "0.1" # tidy-alphabetical-end diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 868345c75945f..334061bfdc1f7 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -2,7 +2,7 @@ use std::fmt::Write; use std::iter; use std::ops::Range; -use rustc_abi::Integer; +use rustc_abi::{ExternAbi, Integer}; use rustc_data_structures::base_n::ToBaseN; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::intern::Interned; @@ -18,7 +18,6 @@ use rustc_middle::ty::{ TyCtxt, TypeVisitable, TypeVisitableExt, UintTy, }; use rustc_span::symbol::kw; -use rustc_target::spec::abi::Abi; pub(super) fn mangle<'tcx>( tcx: TyCtxt<'tcx>, @@ -444,8 +443,8 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> { cx.push("U"); } match sig.abi { - Abi::Rust => {} - Abi::C { unwind: false } => cx.push("KC"), + ExternAbi::Rust => {} + ExternAbi::C { unwind: false } => cx.push("KC"), abi => { cx.push("K"); let name = abi.name(); From fa2047370b4ed15d7ab3cbb54ad1c16f595322df Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sun, 3 Nov 2024 11:30:50 -0800 Subject: [PATCH 11/11] compiler: Remove unused rustc_target from Cargo.tomls --- Cargo.lock | 2 -- compiler/rustc_mir_dataflow/Cargo.toml | 1 - compiler/rustc_pattern_analysis/Cargo.toml | 2 -- 3 files changed, 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a24d6480260ad..cc36dd82f971d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4093,7 +4093,6 @@ dependencies = [ "rustc_macros", "rustc_middle", "rustc_span", - "rustc_target", "smallvec", "tracing", ] @@ -4237,7 +4236,6 @@ dependencies = [ "rustc_middle", "rustc_session", "rustc_span", - "rustc_target", "smallvec", "tracing", "tracing-subscriber", diff --git a/compiler/rustc_mir_dataflow/Cargo.toml b/compiler/rustc_mir_dataflow/Cargo.toml index 62a69b3464f0d..f84a06638976e 100644 --- a/compiler/rustc_mir_dataflow/Cargo.toml +++ b/compiler/rustc_mir_dataflow/Cargo.toml @@ -18,7 +18,6 @@ rustc_index = { path = "../rustc_index" } rustc_macros = { path = "../rustc_macros" } rustc_middle = { path = "../rustc_middle" } rustc_span = { path = "../rustc_span" } -rustc_target = { path = "../rustc_target" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } tracing = "0.1" # tidy-alphabetical-end diff --git a/compiler/rustc_pattern_analysis/Cargo.toml b/compiler/rustc_pattern_analysis/Cargo.toml index f98e4243375f2..16eea9e4ff90a 100644 --- a/compiler/rustc_pattern_analysis/Cargo.toml +++ b/compiler/rustc_pattern_analysis/Cargo.toml @@ -19,7 +19,6 @@ rustc_macros = { path = "../rustc_macros", optional = true } rustc_middle = { path = "../rustc_middle", optional = true } rustc_session = { path = "../rustc_session", optional = true } rustc_span = { path = "../rustc_span", optional = true } -rustc_target = { path = "../rustc_target", optional = true } smallvec = { version = "1.8.1", features = ["union"] } tracing = "0.1" # tidy-alphabetical-end @@ -41,7 +40,6 @@ rustc = [ "dep:rustc_middle", "dep:rustc_session", "dep:rustc_span", - "dep:rustc_target", "smallvec/may_dangle", "rustc_index/nightly", ]