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

Lines changed: 13 additions & 9 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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};

0 commit comments

Comments
 (0)