Skip to content

Commit 236fe33

Browse files
compiler: Directly use rustc_abi in metadata and middle
Stop reexporting ReprOptions from middle::ty
1 parent 89ec8c2 commit 236fe33

35 files changed

+93
-102
lines changed

compiler/rustc_metadata/src/native_libs.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::ops::ControlFlow;
22
use std::path::{Path, PathBuf};
33

4+
use rustc_abi::ExternAbi;
45
use rustc_ast::CRATE_NODE_ID;
56
use rustc_attr as attr;
67
use rustc_data_structures::fx::FxHashSet;
@@ -17,7 +18,6 @@ use rustc_session::utils::NativeLibKind;
1718
use rustc_span::def_id::{DefId, LOCAL_CRATE};
1819
use rustc_span::symbol::{Symbol, sym};
1920
use rustc_target::spec::LinkSelfContainedComponents;
20-
use rustc_target::spec::abi::Abi;
2121

2222
use crate::{errors, fluent_generated};
2323

@@ -203,7 +203,7 @@ impl<'tcx> Collector<'tcx> {
203203

204204
let sess = self.tcx.sess;
205205

206-
if matches!(abi, Abi::Rust | Abi::RustIntrinsic) {
206+
if matches!(abi, ExternAbi::Rust | ExternAbi::RustIntrinsic) {
207207
return;
208208
}
209209

@@ -625,7 +625,7 @@ impl<'tcx> Collector<'tcx> {
625625

626626
fn build_dll_import(
627627
&self,
628-
abi: Abi,
628+
abi: ExternAbi,
629629
import_name_type: Option<PeImportNameType>,
630630
item: DefId,
631631
) -> DllImport {
@@ -634,12 +634,14 @@ impl<'tcx> Collector<'tcx> {
634634
// this logic is similar to `Target::adjust_abi` (in rustc_target/src/spec/mod.rs) but errors on unsupported inputs
635635
let calling_convention = if self.tcx.sess.target.arch == "x86" {
636636
match abi {
637-
Abi::C { .. } | Abi::Cdecl { .. } => DllCallingConvention::C,
638-
Abi::Stdcall { .. } => DllCallingConvention::Stdcall(self.i686_arg_list_size(item)),
637+
ExternAbi::C { .. } | ExternAbi::Cdecl { .. } => DllCallingConvention::C,
638+
ExternAbi::Stdcall { .. } => {
639+
DllCallingConvention::Stdcall(self.i686_arg_list_size(item))
640+
}
639641
// On Windows, `extern "system"` behaves like msvc's `__stdcall`.
640642
// `__stdcall` only applies on x86 and on non-variadic functions:
641643
// https://learn.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-170
642-
Abi::System { .. } => {
644+
ExternAbi::System { .. } => {
643645
let c_variadic =
644646
self.tcx.type_of(item).instantiate_identity().fn_sig(self.tcx).c_variadic();
645647

@@ -649,10 +651,10 @@ impl<'tcx> Collector<'tcx> {
649651
DllCallingConvention::Stdcall(self.i686_arg_list_size(item))
650652
}
651653
}
652-
Abi::Fastcall { .. } => {
654+
ExternAbi::Fastcall { .. } => {
653655
DllCallingConvention::Fastcall(self.i686_arg_list_size(item))
654656
}
655-
Abi::Vectorcall { .. } => {
657+
ExternAbi::Vectorcall { .. } => {
656658
DllCallingConvention::Vectorcall(self.i686_arg_list_size(item))
657659
}
658660
_ => {
@@ -661,7 +663,9 @@ impl<'tcx> Collector<'tcx> {
661663
}
662664
} else {
663665
match abi {
664-
Abi::C { .. } | Abi::Win64 { .. } | Abi::System { .. } => DllCallingConvention::C,
666+
ExternAbi::C { .. } | ExternAbi::Win64 { .. } | ExternAbi::System { .. } => {
667+
DllCallingConvention::C
668+
}
665669
_ => {
666670
self.tcx.dcx().emit_fatal(errors::UnsupportedAbi { span });
667671
}

compiler/rustc_metadata/src/rmeta/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use decoder::{DecodeContext, Metadata};
66
use def_path_hash_map::DefPathHashMapRef;
77
use encoder::EncodeContext;
88
pub use encoder::{EncodedMetadata, encode_metadata, rendered_const};
9-
use rustc_abi::{FieldIdx, VariantIdx};
9+
use rustc_abi::{FieldIdx, ReprOptions, VariantIdx};
1010
use rustc_ast::expand::StrippedCfgItem;
1111
use rustc_data_structures::fx::FxHashMap;
1212
use rustc_data_structures::svh::Svh;
@@ -27,7 +27,7 @@ use rustc_middle::middle::lib_features::FeatureStability;
2727
use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault;
2828
use rustc_middle::ty::fast_reject::SimplifiedType;
2929
use rustc_middle::ty::{
30-
self, DeducedParamAttrs, ParameterizedOverTcx, ReprOptions, Ty, TyCtxt, UnusedGenericParams,
30+
self, DeducedParamAttrs, ParameterizedOverTcx, Ty, TyCtxt, UnusedGenericParams,
3131
};
3232
use rustc_middle::util::Providers;
3333
use rustc_middle::{mir, trivially_parameterized_over_tcx};

compiler/rustc_middle/src/arena.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ macro_rules! arena_types {
99
($macro:path) => (
1010
$macro!([
1111
[] layout: rustc_abi::LayoutData<rustc_abi::FieldIdx, rustc_abi::VariantIdx>,
12-
[] fn_abi: rustc_target::abi::call::FnAbi<'tcx, rustc_middle::ty::Ty<'tcx>>,
12+
[] fn_abi: rustc_target::callconv::FnAbi<'tcx, rustc_middle::ty::Ty<'tcx>>,
1313
// AdtDef are interned and compared by address
1414
[decode] adt_def: rustc_middle::ty::AdtDefData,
1515
[] steal_thir: rustc_data_structures::steal::Steal<rustc_middle::thir::Thir<'tcx>>,

compiler/rustc_middle/src/hir/map/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_abi::ExternAbi;
12
use rustc_ast::visit::{VisitorResult, walk_list};
23
use rustc_data_structures::fingerprint::Fingerprint;
34
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -12,7 +13,6 @@ use rustc_middle::hir::nested_filter;
1213
use rustc_span::def_id::StableCrateId;
1314
use rustc_span::symbol::{Ident, Symbol, kw, sym};
1415
use rustc_span::{ErrorGuaranteed, Span};
15-
use rustc_target::spec::abi::Abi;
1616
use {rustc_ast as ast, rustc_hir_pretty as pprust_hir};
1717

1818
use crate::hir::ModuleItems;
@@ -668,7 +668,7 @@ impl<'hir> Map<'hir> {
668668
}
669669
}
670670

671-
pub fn get_foreign_abi(self, hir_id: HirId) -> Abi {
671+
pub fn get_foreign_abi(self, hir_id: HirId) -> ExternAbi {
672672
let parent = self.get_parent_item(hir_id);
673673
if let OwnerNode::Item(Item { kind: ItemKind::ForeignMod { abi, .. }, .. }) =
674674
self.tcx.hir_owner_node(parent)

compiler/rustc_middle/src/hir/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use rustc_abi::{FieldIdx, VariantIdx};
12
use rustc_hir::HirId;
23
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
3-
use rustc_target::abi::{FieldIdx, VariantIdx};
44

55
use crate::ty;
66
use crate::ty::Ty;

compiler/rustc_middle/src/middle/codegen_fn_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
use rustc_abi::Align;
12
use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr};
23
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
34
use rustc_span::symbol::Symbol;
4-
use rustc_target::abi::Align;
55
use rustc_target::spec::SanitizerSet;
66

77
use crate::mir::mono::Linkage;

compiler/rustc_middle/src/mir/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::fmt::{self, Debug, Display, Formatter};
22

33
use either::Either;
4+
use rustc_abi::{HasDataLayout, Size};
45
use rustc_hir::def_id::DefId;
56
use rustc_macros::{HashStable, Lift, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
67
use rustc_session::RemapFileNameExt;
78
use rustc_session::config::RemapPathScopeComponents;
89
use rustc_span::{DUMMY_SP, Span};
9-
use rustc_target::abi::{HasDataLayout, Size};
1010

1111
use crate::mir::interpret::{AllocId, ConstAllocation, ErrorHandled, Scalar, alloc_range};
1212
use crate::mir::{Promoted, pretty_print_const_value};

compiler/rustc_middle/src/mir/interpret/allocation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use either::{Left, Right};
1212
use init_mask::*;
1313
pub use init_mask::{InitChunk, InitChunkIter};
1414
use provenance_map::*;
15+
use rustc_abi::{Align, HasDataLayout, Size};
1516
use rustc_ast::Mutability;
1617
use rustc_data_structures::intern::Interned;
1718
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
18-
use rustc_target::abi::{Align, HasDataLayout, Size};
1919

2020
use super::{
2121
AllocId, BadBytesAccess, CtfeProvenance, InterpErrorKind, InterpResult, Pointer,

compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ mod tests;
44
use std::ops::Range;
55
use std::{hash, iter};
66

7+
use rustc_abi::Size;
78
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
89
use rustc_serialize::{Decodable, Encodable};
9-
use rustc_target::abi::Size;
1010
use rustc_type_ir::{TyDecoder, TyEncoder};
1111

1212
use super::AllocRange;

compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
44
use std::cmp;
55

6+
use rustc_abi::{HasDataLayout, Size};
67
use rustc_data_structures::sorted_map::SortedMap;
78
use rustc_macros::HashStable;
89
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
9-
use rustc_target::abi::{HasDataLayout, Size};
1010
use tracing::trace;
1111

1212
use super::{AllocError, AllocRange, AllocResult, CtfeProvenance, Provenance, alloc_range};

compiler/rustc_middle/src/mir/interpret/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use std::borrow::Cow;
44
use std::{convert, fmt, mem, ops};
55

66
use either::Either;
7+
use rustc_abi::{Align, Size, VariantIdx, WrappingRange};
78
use rustc_ast_ir::Mutability;
89
use rustc_data_structures::sync::Lock;
910
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg};
1011
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
1112
use rustc_session::CtfeBacktrace;
1213
use rustc_span::def_id::DefId;
1314
use rustc_span::{DUMMY_SP, Span, Symbol};
14-
use rustc_target::abi::{Align, Size, VariantIdx, WrappingRange, call};
1515

1616
use super::{AllocId, AllocRange, ConstAllocation, Pointer, Scalar};
1717
use crate::error;
@@ -217,7 +217,7 @@ pub enum InvalidProgramInfo<'tcx> {
217217
/// An error occurred during FnAbi computation: the passed --target lacks FFI support
218218
/// (which unfortunately typeck does not reject).
219219
/// Not using `FnAbiError` as that contains a nested `LayoutError`.
220-
FnAbiAdjustForForeignAbi(call::AdjustForForeignAbiError),
220+
FnAbiAdjustForForeignAbi(rustc_target::callconv::AdjustForForeignAbiError),
221221
}
222222

223223
/// Details of why a pointer had to be in-bounds.

compiler/rustc_middle/src/mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::io::{Read, Write};
1212
use std::num::NonZero;
1313
use std::{fmt, io};
1414

15+
use rustc_abi::{AddressSpace, Endian, HasDataLayout};
1516
use rustc_ast::LitKind;
1617
use rustc_data_structures::fx::FxHashMap;
1718
use rustc_data_structures::sync::Lock;
@@ -20,7 +21,6 @@ use rustc_hir::def_id::{DefId, LocalDefId};
2021
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
2122
use rustc_middle::ty::print::with_no_trimmed_paths;
2223
use rustc_serialize::{Decodable, Encodable};
23-
use rustc_target::abi::{AddressSpace, Endian, HasDataLayout};
2424
use tracing::{debug, trace};
2525
// Also make the error macros available from this module.
2626
pub use {

compiler/rustc_middle/src/mir/interpret/pointer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::fmt;
22
use std::num::NonZero;
33

4+
use rustc_abi::{HasDataLayout, Size};
45
use rustc_data_structures::static_assert_size;
56
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
6-
use rustc_target::abi::{HasDataLayout, Size};
77

88
use super::AllocId;
99

compiler/rustc_middle/src/mir/interpret/value.rs

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

33
use either::{Either, Left, Right};
4+
use rustc_abi::{HasDataLayout, Size};
45
use rustc_apfloat::Float;
56
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
67
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
7-
use rustc_target::abi::{HasDataLayout, Size};
88

99
use super::{
1010
AllocId, CtfeProvenance, InterpResult, Pointer, PointerArithmetic, Provenance,

compiler/rustc_middle/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::{iter, mem};
1010
pub use basic_blocks::BasicBlocks;
1111
use either::Either;
1212
use polonius_engine::Atom;
13+
use rustc_abi::{FieldIdx, VariantIdx};
1314
pub use rustc_ast::Mutability;
1415
use rustc_data_structures::captures::Captures;
1516
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@@ -27,7 +28,6 @@ use rustc_serialize::{Decodable, Encodable};
2728
use rustc_span::source_map::Spanned;
2829
use rustc_span::symbol::Symbol;
2930
use rustc_span::{DUMMY_SP, Span};
30-
use rustc_target::abi::{FieldIdx, VariantIdx};
3131
use tracing::trace;
3232

3333
pub use self::query::*;

compiler/rustc_middle/src/mir/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use std::fs;
44
use std::io::{self, Write as _};
55
use std::path::{Path, PathBuf};
66

7+
use rustc_abi::Size;
78
use rustc_ast::InlineAsmTemplatePiece;
89
use rustc_middle::mir::interpret::{
910
AllocBytes, AllocId, Allocation, GlobalAlloc, Pointer, Provenance, alloc_range,
1011
read_target_uint,
1112
};
1213
use rustc_middle::mir::visit::Visitor;
1314
use rustc_middle::mir::*;
14-
use rustc_target::abi::Size;
1515
use tracing::trace;
1616

1717
use super::graphviz::write_mir_fn_graphviz;

compiler/rustc_middle/src/mir/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::cell::Cell;
44
use std::fmt::{self, Debug};
55

66
use derive_where::derive_where;
7+
use rustc_abi::{FieldIdx, VariantIdx};
78
use rustc_data_structures::fx::FxIndexMap;
89
use rustc_errors::ErrorGuaranteed;
910
use rustc_hir::def_id::LocalDefId;
@@ -12,7 +13,6 @@ use rustc_index::{Idx, IndexVec};
1213
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
1314
use rustc_span::Span;
1415
use rustc_span::symbol::Symbol;
15-
use rustc_target::abi::{FieldIdx, VariantIdx};
1616
use smallvec::SmallVec;
1717

1818
use super::{ConstValue, SourceInfo};

compiler/rustc_middle/src/mir/syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! This is in a dedicated file so that changes to this file can be reviewed more carefully.
44
//! The intention is that this file only contains datatype declarations, no code.
55
6+
use rustc_abi::{FieldIdx, VariantIdx};
67
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece, Mutability};
78
use rustc_data_structures::packed::Pu128;
89
use rustc_hir::CoroutineKind;
@@ -13,7 +14,6 @@ use rustc_span::Span;
1314
use rustc_span::def_id::LocalDefId;
1415
use rustc_span::source_map::Spanned;
1516
use rustc_span::symbol::Symbol;
16-
use rustc_target::abi::{FieldIdx, VariantIdx};
1717
use rustc_target::asm::InlineAsmRegOrRegClass;
1818
use smallvec::SmallVec;
1919

compiler/rustc_middle/src/query/erase.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,10 @@ impl EraseType for Result<bool, &ty::layout::LayoutError<'_>> {
132132
type Result = [u8; size_of::<Result<bool, &'static ty::layout::LayoutError<'static>>>()];
133133
}
134134

135-
impl EraseType
136-
for Result<rustc_target::abi::TyAndLayout<'_, Ty<'_>>, &ty::layout::LayoutError<'_>>
137-
{
135+
impl EraseType for Result<rustc_abi::TyAndLayout<'_, Ty<'_>>, &ty::layout::LayoutError<'_>> {
138136
type Result = [u8; size_of::<
139137
Result<
140-
rustc_target::abi::TyAndLayout<'static, Ty<'static>>,
138+
rustc_abi::TyAndLayout<'static, Ty<'static>>,
141139
&'static ty::layout::LayoutError<'static>,
142140
>,
143141
>()];
@@ -253,13 +251,14 @@ trivial! {
253251
Option<rustc_span::def_id::DefId>,
254252
Option<rustc_span::def_id::LocalDefId>,
255253
Option<rustc_span::Span>,
256-
Option<rustc_target::abi::FieldIdx>,
254+
Option<rustc_abi::FieldIdx>,
257255
Option<rustc_target::spec::PanicStrategy>,
258256
Option<usize>,
259257
Option<rustc_middle::ty::IntrinsicDef>,
260258
Result<(), rustc_errors::ErrorGuaranteed>,
261259
Result<(), rustc_middle::traits::query::NoSolution>,
262260
Result<rustc_middle::traits::EvaluationResult, rustc_middle::traits::OverflowError>,
261+
rustc_abi::ReprOptions,
263262
rustc_ast::expand::allocator::AllocatorKind,
264263
rustc_attr::ConstStability,
265264
rustc_attr::DefaultBodyStability,
@@ -311,7 +310,6 @@ trivial! {
311310
rustc_middle::ty::fast_reject::SimplifiedType,
312311
rustc_middle::ty::ImplPolarity,
313312
rustc_middle::ty::Representability,
314-
rustc_middle::ty::ReprOptions,
315313
rustc_middle::ty::UnusedGenericParams,
316314
rustc_middle::ty::util::AlwaysRequiresDrop,
317315
rustc_middle::ty::Visibility<rustc_span::def_id::DefId>,

compiler/rustc_middle/src/query/keys.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc_hir::hir_id::{HirId, OwnerId};
55
use rustc_query_system::query::{DefIdCache, DefaultCache, SingleCache, VecCache};
66
use rustc_span::symbol::{Ident, Symbol};
77
use rustc_span::{DUMMY_SP, Span};
8-
use rustc_target::abi;
98

109
use crate::infer::canonical::CanonicalQueryInput;
1110
use crate::ty::fast_reject::SimplifiedType;
@@ -509,7 +508,7 @@ impl<'tcx> Key for (DefId, Ty<'tcx>, GenericArgsRef<'tcx>, ty::ParamEnv<'tcx>) {
509508
}
510509
}
511510

512-
impl<'tcx> Key for (Ty<'tcx>, abi::VariantIdx) {
511+
impl<'tcx> Key for (Ty<'tcx>, rustc_abi::VariantIdx) {
513512
type Cache<V> = DefaultCache<Self, V>;
514513

515514
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {

0 commit comments

Comments
 (0)