diff --git a/src/librustc_codegen_llvm/abi.rs b/src/librustc_codegen_llvm/abi.rs index 064ca53bd1bd1..8e9c5f25ccb71 100644 --- a/src/librustc_codegen_llvm/abi.rs +++ b/src/librustc_codegen_llvm/abi.rs @@ -10,17 +10,15 @@ use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::MemFlags; use rustc_middle::bug; -use rustc_middle::ty::layout::{self}; +pub use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA}; use rustc_middle::ty::Ty; use rustc_target::abi::call::ArgAbi; -use rustc_target::abi::{HasDataLayout, LayoutOf}; - -use libc::c_uint; - -pub use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA}; pub use rustc_target::abi::call::*; +use rustc_target::abi::{self, HasDataLayout, Int, LayoutOf}; pub use rustc_target::spec::abi::Abi; +use libc::c_uint; + macro_rules! for_each_kind { ($flags: ident, $f: ident, $($kind: ident),+) => ({ $(if $flags.contains(ArgAttribute::$kind) { $f(llvm::Attribute::$kind) })+ @@ -450,11 +448,11 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> { PassMode::Indirect(ref attrs, _) => apply(attrs, Some(self.ret.layout.llvm_type(bx))), _ => {} } - if let layout::Abi::Scalar(ref scalar) = self.ret.layout.abi { + if let abi::Abi::Scalar(ref scalar) = self.ret.layout.abi { // If the value is a boolean, the range is 0..2 and that ultimately // become 0..0 when the type becomes i1, which would be rejected // by the LLVM verifier. - if let layout::Int(..) = scalar.value { + if let Int(..) = scalar.value { if !scalar.is_bool() { let range = scalar.valid_range_exclusive(bx); if range.start != range.end { diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 35946fb71c3e0..da9060f043f81 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -16,9 +16,10 @@ use rustc_codegen_ssa::MemFlags; use rustc_data_structures::const_cstr; use rustc_data_structures::small_c_str::SmallCStr; use rustc_hir::def_id::DefId; -use rustc_middle::ty::layout::{self, Align, Size, TyAndLayout}; +use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::config::{self, Sanitizer}; +use rustc_target::abi::{self, Align, Size}; use rustc_target::spec::{HasTargetSpec, Target}; use std::borrow::Cow; use std::ffi::CStr; @@ -60,8 +61,8 @@ impl BackendTypes for Builder<'_, 'll, 'tcx> { type DIVariable = as BackendTypes>::DIVariable; } -impl ty::layout::HasDataLayout for Builder<'_, '_, '_> { - fn data_layout(&self) -> &ty::layout::TargetDataLayout { +impl abi::HasDataLayout for Builder<'_, '_, '_> { + fn data_layout(&self) -> &abi::TargetDataLayout { self.cx.data_layout() } } @@ -84,7 +85,7 @@ impl HasTargetSpec for Builder<'_, '_, 'tcx> { } } -impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> { +impl abi::LayoutOf for Builder<'_, '_, 'tcx> { type Ty = Ty<'tcx>; type TyAndLayout = TyAndLayout<'tcx>; @@ -435,17 +436,17 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn scalar_load_metadata<'a, 'll, 'tcx>( bx: &mut Builder<'a, 'll, 'tcx>, load: &'ll Value, - scalar: &layout::Scalar, + scalar: &abi::Scalar, ) { let vr = scalar.valid_range.clone(); match scalar.value { - layout::Int(..) => { + abi::Int(..) => { let range = scalar.valid_range_exclusive(bx); if range.start != range.end { bx.range_metadata(load, range); } } - layout::Pointer if vr.start() < vr.end() && !vr.contains(&0) => { + abi::Pointer if vr.start() < vr.end() && !vr.contains(&0) => { bx.nonnull_metadata(load); } _ => {} @@ -465,16 +466,16 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } let llval = const_llval.unwrap_or_else(|| { let load = self.load(place.llval, place.align); - if let layout::Abi::Scalar(ref scalar) = place.layout.abi { + if let abi::Abi::Scalar(ref scalar) = place.layout.abi { scalar_load_metadata(self, load, scalar); } load }); OperandValue::Immediate(to_immediate(self, llval, place.layout)) - } else if let layout::Abi::ScalarPair(ref a, ref b) = place.layout.abi { + } else if let abi::Abi::ScalarPair(ref a, ref b) = place.layout.abi { let b_offset = a.value.size(self).align_to(b.value.align(self).abi); - let mut load = |i, scalar: &layout::Scalar, align| { + let mut load = |i, scalar: &abi::Scalar, align| { let llptr = self.struct_gep(place.llval, i as u64); let load = self.load(llptr, align); scalar_load_metadata(self, load, scalar); diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs index 01c8e02fdc2ba..1415fedf11a27 100644 --- a/src/librustc_codegen_llvm/common.rs +++ b/src/librustc_codegen_llvm/common.rs @@ -2,26 +2,24 @@ //! Code that is useful in various codegen modules. -use crate::consts; +use crate::consts::{self, const_alloc_to_llvm}; +pub use crate::context::CodegenCx; use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, OperandBundleDef, True}; use crate::type_::Type; use crate::type_of::LayoutLlvmExt; use crate::value::Value; -use log::debug; -use rustc_codegen_ssa::traits::*; -use rustc_middle::bug; -use crate::consts::const_alloc_to_llvm; +use rustc_ast::ast::Mutability; use rustc_codegen_ssa::mir::place::PlaceRef; +use rustc_codegen_ssa::traits::*; +use rustc_middle::bug; use rustc_middle::mir::interpret::{Allocation, GlobalAlloc, Scalar}; -use rustc_middle::ty::layout::{self, HasDataLayout, LayoutOf, Size, TyAndLayout}; - -use libc::{c_char, c_uint}; - -use rustc_ast::ast::Mutability; +use rustc_middle::ty::layout::TyAndLayout; use rustc_span::symbol::Symbol; +use rustc_target::abi::{self, HasDataLayout, LayoutOf, Pointer, Size}; -pub use crate::context::CodegenCx; +use libc::{c_char, c_uint}; +use log::debug; /* * A note on nomenclature of linking: "extern", "foreign", and "upcall". @@ -229,12 +227,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { }) } - fn scalar_to_backend( - &self, - cv: Scalar, - layout: &layout::Scalar, - llty: &'ll Type, - ) -> &'ll Value { + fn scalar_to_backend(&self, cv: Scalar, layout: &abi::Scalar, llty: &'ll Type) -> &'ll Value { let bitsize = if layout.is_bool() { 1 } else { layout.value.size(self).bits() }; match cv { Scalar::Raw { size: 0, .. } => { @@ -244,7 +237,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { Scalar::Raw { data, size } => { assert_eq!(size as u64, layout.value.size(self).bytes()); let llval = self.const_uint_big(self.type_ix(bitsize), data); - if layout.value == layout::Pointer { + if layout.value == Pointer { unsafe { llvm::LLVMConstIntToPtr(llval, llty) } } else { self.const_bitcast(llval, llty) @@ -278,7 +271,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { 1, ) }; - if layout.value != layout::Pointer { + if layout.value != Pointer { unsafe { llvm::LLVMConstPtrToInt(llval, llty) } } else { self.const_bitcast(llval, llty) diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index db92f3d382f6e..2d5564abfb2c8 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -16,12 +16,11 @@ use rustc_middle::mir::interpret::{ read_target_uint, Allocation, ConstValue, ErrorHandled, Pointer, }; use rustc_middle::mir::mono::MonoItem; -use rustc_middle::ty::layout::{self, Align, LayoutOf, Size}; use rustc_middle::ty::{self, Instance, Ty}; use rustc_middle::{bug, span_bug}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; -use rustc_target::abi::HasDataLayout; +use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Primitive, Scalar, Size}; use std::ffi::CStr; @@ -56,7 +55,7 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll as u64; llvals.push(cx.scalar_to_backend( Pointer::new(alloc_id, Size::from_bytes(ptr_offset)).into(), - &layout::Scalar { value: layout::Primitive::Pointer, valid_range: 0..=!0 }, + &Scalar { value: Primitive::Pointer, valid_range: 0..=!0 }, cx.type_i8p(), )); next_offset = offset + pointer_size; diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index add1f46a56d37..99a825823c3cd 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -14,14 +14,13 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::small_c_str::SmallCStr; use rustc_middle::bug; use rustc_middle::mir::mono::CodegenUnit; -use rustc_middle::ty::layout::{ - HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyAndLayout, VariantIdx, -}; +use rustc_middle::ty::layout::{HasParamEnv, LayoutError, TyAndLayout}; use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; use rustc_session::config::{self, CFGuard, DebugInfo}; use rustc_session::Session; use rustc_span::source_map::{Span, DUMMY_SP}; use rustc_span::symbol::Symbol; +use rustc_target::abi::{HasDataLayout, LayoutOf, PointeeInfo, Size, TargetDataLayout, VariantIdx}; use rustc_target::spec::{HasTargetSpec, Target}; use std::cell::{Cell, RefCell}; @@ -817,8 +816,8 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> { } } -impl ty::layout::HasDataLayout for CodegenCx<'ll, 'tcx> { - fn data_layout(&self) -> &ty::layout::TargetDataLayout { +impl HasDataLayout for CodegenCx<'ll, 'tcx> { + fn data_layout(&self) -> &TargetDataLayout { &self.tcx.data_layout } } diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index b90c7e51ccd69..a9e21c056a3eb 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -34,9 +34,7 @@ use rustc_middle::ich::NodeIdHashingMode; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::interpret::truncate; use rustc_middle::mir::{self, Field, GeneratorLayout}; -use rustc_middle::ty::layout::{ - self, Align, Integer, IntegerExt, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx, -}; +use rustc_middle::ty::layout::{self, IntegerExt, PrimitiveExt, TyAndLayout}; use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::Instance; use rustc_middle::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt}; @@ -44,7 +42,9 @@ use rustc_middle::{bug, span_bug}; use rustc_session::config::{self, DebugInfo}; use rustc_span::symbol::{Interner, Symbol}; use rustc_span::{self, FileName, Span}; -use rustc_target::abi::HasDataLayout; +use rustc_target::abi::{Abi, Align, DiscriminantKind, HasDataLayout, Integer, LayoutOf}; +use rustc_target::abi::{Int, Pointer, F32, F64}; +use rustc_target::abi::{Primitive, Size, VariantIdx, Variants}; use libc::{c_longlong, c_uint}; use std::collections::hash_map::Entry; @@ -1364,7 +1364,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { }; match self.layout.variants { - layout::Variants::Single { index } => { + Variants::Single { index } => { if let ty::Adt(adt, _) = &self.enum_type.kind { if adt.variants.is_empty() { return vec![]; @@ -1399,8 +1399,8 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { discriminant: None, }] } - layout::Variants::Multiple { - discr_kind: layout::DiscriminantKind::Tag, + Variants::Multiple { + discr_kind: DiscriminantKind::Tag, discr_index, ref variants, .. @@ -1457,9 +1457,9 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { }) .collect() } - layout::Variants::Multiple { + Variants::Multiple { discr_kind: - layout::DiscriminantKind::Niche { ref niche_variants, niche_start, dataful_variant }, + DiscriminantKind::Niche { ref niche_variants, niche_start, dataful_variant }, ref discr, ref variants, discr_index, @@ -1592,7 +1592,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { // Creates `MemberDescription`s for the fields of a single enum variant. struct VariantMemberDescriptionFactory<'ll, 'tcx> { /// Cloned from the `layout::Struct` describing the variant. - offsets: Vec, + offsets: Vec, args: Vec<(String, Ty<'tcx>)>, discriminant_type_metadata: Option<&'ll DIType>, span: Span, @@ -1777,7 +1777,7 @@ fn prepare_enum_metadata( // let file_metadata = unknown_file_metadata(cx); - let discriminant_type_metadata = |discr: layout::Primitive| { + let discriminant_type_metadata = |discr: Primitive| { let enumerators_metadata: Vec<_> = match enum_type.kind { ty::Adt(def, _) => def .discriminants(cx.tcx) @@ -1870,10 +1870,8 @@ fn prepare_enum_metadata( let layout = cx.layout_of(enum_type); if let ( - &layout::Abi::Scalar(_), - &layout::Variants::Multiple { - discr_kind: layout::DiscriminantKind::Tag, ref discr, .. - }, + &Abi::Scalar(_), + &Variants::Multiple { discr_kind: DiscriminantKind::Tag, ref discr, .. }, ) = (&layout.abi, &layout.variants) { return FinalMetadata(discriminant_type_metadata(discr.value)); @@ -1881,16 +1879,11 @@ fn prepare_enum_metadata( if use_enum_fallback(cx) { let discriminant_type_metadata = match layout.variants { - layout::Variants::Single { .. } - | layout::Variants::Multiple { - discr_kind: layout::DiscriminantKind::Niche { .. }, - .. - } => None, - layout::Variants::Multiple { - discr_kind: layout::DiscriminantKind::Tag, - ref discr, - .. - } => Some(discriminant_type_metadata(discr.value)), + Variants::Single { .. } + | Variants::Multiple { discr_kind: DiscriminantKind::Niche { .. }, .. } => None, + Variants::Multiple { discr_kind: DiscriminantKind::Tag, ref discr, .. } => { + Some(discriminant_type_metadata(discr.value)) + } }; let enum_metadata = { @@ -1938,10 +1931,10 @@ fn prepare_enum_metadata( }; let discriminator_metadata = match layout.variants { // A single-variant enum has no discriminant. - layout::Variants::Single { .. } => None, + Variants::Single { .. } => None, - layout::Variants::Multiple { - discr_kind: layout::DiscriminantKind::Niche { .. }, + Variants::Multiple { + discr_kind: DiscriminantKind::Niche { .. }, ref discr, discr_index, .. @@ -1951,10 +1944,10 @@ fn prepare_enum_metadata( let align = discr.value.align(cx); let discr_type = match discr.value { - layout::Int(t, _) => t, - layout::F32 => Integer::I32, - layout::F64 => Integer::I64, - layout::Pointer => cx.data_layout().ptr_sized_integer(), + Int(t, _) => t, + F32 => Integer::I32, + F64 => Integer::I64, + Pointer => cx.data_layout().ptr_sized_integer(), } .to_ty(cx.tcx, false); @@ -1976,11 +1969,8 @@ fn prepare_enum_metadata( } } - layout::Variants::Multiple { - discr_kind: layout::DiscriminantKind::Tag, - ref discr, - discr_index, - .. + Variants::Multiple { + discr_kind: DiscriminantKind::Tag, ref discr, discr_index, .. } => { let discr_type = discr.value.to_ty(cx.tcx); let (size, align) = cx.size_and_align_of(discr_type); @@ -2005,8 +1995,8 @@ fn prepare_enum_metadata( }; let mut outer_fields = match layout.variants { - layout::Variants::Single { .. } => vec![], - layout::Variants::Multiple { .. } => { + Variants::Single { .. } => vec![], + Variants::Multiple { .. } => { let tuple_mdf = TupleMemberDescriptionFactory { ty: enum_type, component_types: outer_field_tys, diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 848c973c15b51..f04ac58650411 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -8,35 +8,35 @@ use self::namespace::mangled_name_of_instance; use self::type_names::compute_debuginfo_type_name; use self::utils::{create_DIArray, is_node_local_to_unit, DIB}; +use crate::abi::FnAbi; +use crate::builder::Builder; +use crate::common::CodegenCx; use crate::llvm; use crate::llvm::debuginfo::{ DIArray, DIBuilder, DIFile, DIFlags, DILexicalBlock, DISPFlags, DIScope, DIType, DIVariable, }; -use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE}; -use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; - -use crate::abi::FnAbi; -use crate::builder::Builder; -use crate::common::CodegenCx; use crate::value::Value; + +use rustc_ast::ast; use rustc_codegen_ssa::debuginfo::type_names; use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind}; +use rustc_codegen_ssa::traits::*; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE}; use rustc_index::vec::IndexVec; use rustc_middle::mir; +use rustc_middle::ty::layout::HasTyCtxt; +use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::{self, Instance, ParamEnv, Ty}; use rustc_session::config::{self, DebugInfo}; +use rustc_span::symbol::Symbol; +use rustc_span::{self, BytePos, Span}; +use rustc_target::abi::{LayoutOf, Primitive, Size}; use libc::c_uint; use log::debug; -use std::cell::RefCell; - -use rustc_ast::ast; -use rustc_codegen_ssa::traits::*; -use rustc_middle::ty::layout::{self, HasTyCtxt, LayoutOf, Size}; -use rustc_span::symbol::Symbol; -use rustc_span::{self, BytePos, Span}; use smallvec::SmallVec; +use std::cell::RefCell; mod create_scope_map; pub mod gdb; @@ -60,7 +60,7 @@ pub struct CrateDebugContext<'a, 'tcx> { llmod: &'a llvm::Module, builder: &'a mut DIBuilder<'a>, created_files: RefCell, Option), &'a DIFile>>, - created_enum_disr_types: RefCell>, + created_enum_disr_types: RefCell>, type_map: RefCell>, namespace_map: RefCell>, diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 23f6c0a942036..bc7a9c566b476 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -7,23 +7,22 @@ use crate::type_::Type; use crate::type_of::LayoutLlvmExt; use crate::va_arg::emit_va_arg; use crate::value::Value; + use rustc_ast::ast; use rustc_codegen_ssa::base::{compare_simd_types, to_immediate, wants_msvc_seh}; +use rustc_codegen_ssa::common::span_invalid_monomorphization_error; use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; use rustc_codegen_ssa::glue; use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; use rustc_codegen_ssa::mir::place::PlaceRef; +use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::MemFlags; use rustc_hir as hir; -use rustc_middle::ty::layout::{self, FnAbiExt, HasTyCtxt, LayoutOf, Primitive}; +use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt}; use rustc_middle::ty::{self, Ty}; use rustc_middle::{bug, span_bug}; -use rustc_target::abi::HasDataLayout; - -use rustc_codegen_ssa::common::span_invalid_monomorphization_error; -use rustc_codegen_ssa::traits::*; - use rustc_span::Span; +use rustc_target::abi::{self, HasDataLayout, LayoutOf, Primitive}; use std::cmp::Ordering; use std::{i128, iter, u128}; @@ -145,7 +144,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> { } "va_arg" => { match fn_abi.ret.layout.abi { - layout::Abi::Scalar(ref scalar) => { + abi::Abi::Scalar(ref scalar) => { match scalar.value { Primitive::Int(..) => { if self.cx().size_of(ret_ty).bytes() < 4 { diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index 8a16d098a8bef..939f9e9c2a0c7 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -23,11 +23,10 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, ModuleConfig}; use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::ModuleCodegen; use rustc_codegen_ssa::{CodegenResults, CompiledModule}; -use rustc_errors::{FatalError, Handler}; +use rustc_errors::{ErrorReported, FatalError, Handler}; use rustc_middle::dep_graph::{DepGraph, WorkProduct}; use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoaderDyn}; use rustc_middle::ty::{self, TyCtxt}; -use rustc_middle::util::common::ErrorReported; use rustc_serialize::json; use rustc_session::config::{self, OptLevel, OutputFilenames, PrintRequest}; use rustc_session::Session; diff --git a/src/librustc_codegen_llvm/mono_item.rs b/src/librustc_codegen_llvm/mono_item.rs index a7a9d0c8a0759..29389b44adc27 100644 --- a/src/librustc_codegen_llvm/mono_item.rs +++ b/src/librustc_codegen_llvm/mono_item.rs @@ -7,11 +7,11 @@ use crate::type_of::LayoutLlvmExt; use log::debug; use rustc_codegen_ssa::traits::*; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; +pub use rustc_middle::mir::mono::MonoItem; use rustc_middle::mir::mono::{Linkage, Visibility}; -use rustc_middle::ty::layout::{FnAbiExt, LayoutOf}; +use rustc_middle::ty::layout::FnAbiExt; use rustc_middle::ty::{Instance, TypeFoldable}; - -pub use rustc_middle::mir::mono::MonoItem; +use rustc_target::abi::LayoutOf; impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> { fn predefine_static( diff --git a/src/librustc_codegen_llvm/type_.rs b/src/librustc_codegen_llvm/type_.rs index c06d2e6a01ac2..854eff3173380 100644 --- a/src/librustc_codegen_llvm/type_.rs +++ b/src/librustc_codegen_llvm/type_.rs @@ -12,9 +12,10 @@ 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::{self, Align, Size, TyAndLayout}; +use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::Ty; use rustc_target::abi::call::{CastTarget, FnAbi, Reg}; +use rustc_target::abi::{Align, Integer, Size}; use std::fmt; use std::ptr; @@ -114,14 +115,14 @@ impl CodegenCx<'ll, 'tcx> { crate fn type_pointee_for_align(&self, align: Align) -> &'ll Type { // FIXME(eddyb) We could find a better approximation if ity.align < align. - let ity = layout::Integer::approximate_align(self, align); + let ity = Integer::approximate_align(self, align); self.type_from_integer(ity) } /// Return a LLVM type that has at most the required alignment, /// and exactly the required size, as a best-effort padding array. crate fn type_padding_filler(&self, size: Size, align: Align) -> &'ll Type { - let unit = layout::Integer::approximate_align(self, align); + let unit = Integer::approximate_align(self, align); let size = size.bytes(); let unit_size = unit.size().bytes(); assert_eq!(size % unit_size, 0); diff --git a/src/librustc_codegen_llvm/type_of.rs b/src/librustc_codegen_llvm/type_of.rs index 6501ba031e445..f475ea741c893 100644 --- a/src/librustc_codegen_llvm/type_of.rs +++ b/src/librustc_codegen_llvm/type_of.rs @@ -4,10 +4,12 @@ use crate::type_::Type; use log::debug; use rustc_codegen_ssa::traits::*; use rustc_middle::bug; -use rustc_middle::ty::layout::{self, Align, FnAbiExt, LayoutOf, PointeeInfo, Size, TyAndLayout}; +use rustc_middle::ty::layout::{FnAbiExt, TyAndLayout}; use rustc_middle::ty::print::obsolete::DefPathBasedNames; use rustc_middle::ty::{self, Ty, TypeFoldable}; -use rustc_target::abi::TyAndLayoutMethods; +use rustc_target::abi::{Abi, Align, FieldsShape}; +use rustc_target::abi::{Int, Pointer, F32, F64}; +use rustc_target::abi::{LayoutOf, PointeeInfo, Scalar, Size, TyAndLayoutMethods, Variants}; use std::fmt::Write; @@ -17,8 +19,8 @@ fn uncached_llvm_type<'a, 'tcx>( defer: &mut Option<(&'a Type, TyAndLayout<'tcx>)>, ) -> &'a Type { match layout.abi { - layout::Abi::Scalar(_) => bug!("handled elsewhere"), - layout::Abi::Vector { ref element, count } => { + Abi::Scalar(_) => bug!("handled elsewhere"), + Abi::Vector { ref element, count } => { // LLVM has a separate type for 64-bit SIMD vectors on X86 called // `x86_mmx` which is needed for some SIMD operations. As a bit of a // hack (all SIMD definitions are super unstable anyway) we @@ -37,7 +39,7 @@ fn uncached_llvm_type<'a, 'tcx>( return cx.type_vector(element, count); } } - layout::Abi::ScalarPair(..) => { + Abi::ScalarPair(..) => { return cx.type_struct( &[ layout.scalar_pair_element_llvm_type(cx, 0, false), @@ -46,7 +48,7 @@ fn uncached_llvm_type<'a, 'tcx>( false, ); } - layout::Abi::Uninhabited | layout::Abi::Aggregate { .. } => {} + Abi::Uninhabited | Abi::Aggregate { .. } => {} } let name = match layout.ty.kind { @@ -61,14 +63,14 @@ fn uncached_llvm_type<'a, 'tcx>( let mut name = String::with_capacity(32); let printer = DefPathBasedNames::new(cx.tcx, true, true); printer.push_type_name(layout.ty, &mut name, false); - if let (&ty::Adt(def, _), &layout::Variants::Single { index }) + if let (&ty::Adt(def, _), &Variants::Single { index }) = (&layout.ty.kind, &layout.variants) { if def.is_enum() && !def.variants.is_empty() { write!(&mut name, "::{}", def.variants[index].ident).unwrap(); } } - if let (&ty::Generator(_, substs, _), &layout::Variants::Single { index }) + if let (&ty::Generator(_, substs, _), &Variants::Single { index }) = (&layout.ty.kind, &layout.variants) { write!(&mut name, "::{}", substs.as_generator().variant_name(index)).unwrap(); @@ -79,7 +81,7 @@ fn uncached_llvm_type<'a, 'tcx>( }; match layout.fields { - layout::FieldsShape::Union(_) => { + FieldsShape::Union(_) => { let fill = cx.type_padding_filler(layout.size, layout.align.abi); let packed = false; match name { @@ -91,10 +93,8 @@ fn uncached_llvm_type<'a, 'tcx>( } } } - layout::FieldsShape::Array { count, .. } => { - cx.type_array(layout.field(cx, 0).llvm_type(cx), count) - } - layout::FieldsShape::Arbitrary { .. } => match name { + FieldsShape::Array { count, .. } => cx.type_array(layout.field(cx, 0).llvm_type(cx), count), + FieldsShape::Arbitrary { .. } => match name { None => { let (llfields, packed) = struct_llfields(cx, layout); cx.type_struct(&llfields, packed) @@ -189,7 +189,7 @@ pub trait LayoutLlvmExt<'tcx> { fn scalar_llvm_type_at<'a>( &self, cx: &CodegenCx<'a, 'tcx>, - scalar: &layout::Scalar, + scalar: &Scalar, offset: Size, ) -> &'a Type; fn scalar_pair_element_llvm_type<'a>( @@ -205,19 +205,16 @@ pub trait LayoutLlvmExt<'tcx> { impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { fn is_llvm_immediate(&self) -> bool { match self.abi { - layout::Abi::Scalar(_) | layout::Abi::Vector { .. } => true, - layout::Abi::ScalarPair(..) => false, - layout::Abi::Uninhabited | layout::Abi::Aggregate { .. } => self.is_zst(), + Abi::Scalar(_) | Abi::Vector { .. } => true, + Abi::ScalarPair(..) => false, + Abi::Uninhabited | Abi::Aggregate { .. } => self.is_zst(), } } fn is_llvm_scalar_pair(&self) -> bool { match self.abi { - layout::Abi::ScalarPair(..) => true, - layout::Abi::Uninhabited - | layout::Abi::Scalar(_) - | layout::Abi::Vector { .. } - | layout::Abi::Aggregate { .. } => false, + Abi::ScalarPair(..) => true, + Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } | Abi::Aggregate { .. } => false, } } @@ -233,7 +230,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { /// of that field's type - this is useful for taking the address of /// that field and ensuring the struct has the right alignment. fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type { - if let layout::Abi::Scalar(ref scalar) = self.abi { + if let Abi::Scalar(ref scalar) = self.abi { // Use a different cache for scalars because pointers to DSTs // can be either fat or thin (data pointers of fat pointers). if let Some(&llty) = cx.scalar_lltypes.borrow().get(&self.ty) { @@ -255,7 +252,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { // Check the cache. let variant_index = match self.variants { - layout::Variants::Single { index } => Some(index), + Variants::Single { index } => Some(index), _ => None, }; if let Some(&llty) = cx.lltypes.borrow().get(&(self.ty, variant_index)) { @@ -293,7 +290,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { } fn immediate_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type { - if let layout::Abi::Scalar(ref scalar) = self.abi { + if let Abi::Scalar(ref scalar) = self.abi { if scalar.is_bool() { return cx.type_i1(); } @@ -304,14 +301,14 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { fn scalar_llvm_type_at<'a>( &self, cx: &CodegenCx<'a, 'tcx>, - scalar: &layout::Scalar, + scalar: &Scalar, offset: Size, ) -> &'a Type { match scalar.value { - layout::Int(i, _) => cx.type_from_integer(i), - layout::F32 => cx.type_f32(), - layout::F64 => cx.type_f64(), - layout::Pointer => { + Int(i, _) => cx.type_from_integer(i), + F32 => cx.type_f32(), + F64 => cx.type_f64(), + Pointer => { // If we know the alignment, pick something better than i8. let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) { cx.type_pointee_for_align(pointee.align) @@ -343,7 +340,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { } let (a, b) = match self.abi { - layout::Abi::ScalarPair(ref a, ref b) => (a, b), + Abi::ScalarPair(ref a, ref b) => (a, b), _ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self), }; let scalar = [a, b][index]; @@ -365,21 +362,19 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { fn llvm_field_index(&self, index: usize) -> u64 { match self.abi { - layout::Abi::Scalar(_) | layout::Abi::ScalarPair(..) => { + Abi::Scalar(_) | Abi::ScalarPair(..) => { bug!("TyAndLayout::llvm_field_index({:?}): not applicable", self) } _ => {} } match self.fields { - layout::FieldsShape::Union(_) => { + FieldsShape::Union(_) => { bug!("TyAndLayout::llvm_field_index({:?}): not applicable", self) } - layout::FieldsShape::Array { .. } => index as u64, + FieldsShape::Array { .. } => index as u64, - layout::FieldsShape::Arbitrary { .. } => { - 1 + (self.fields.memory_index(index) as u64) * 2 - } + FieldsShape::Arbitrary { .. } => 1 + (self.fields.memory_index(index) as u64) * 2, } } diff --git a/src/librustc_codegen_llvm/va_arg.rs b/src/librustc_codegen_llvm/va_arg.rs index 42e9f60e95cb5..8bc3579800ea8 100644 --- a/src/librustc_codegen_llvm/va_arg.rs +++ b/src/librustc_codegen_llvm/va_arg.rs @@ -6,8 +6,9 @@ use rustc_codegen_ssa::mir::operand::OperandRef; use rustc_codegen_ssa::traits::{ BaseTypeMethods, BuilderMethods, ConstMethods, DerivedTypeMethods, }; -use rustc_middle::ty::layout::{Align, HasDataLayout, HasTyCtxt, LayoutOf, Size}; +use rustc_middle::ty::layout::HasTyCtxt; use rustc_middle::ty::Ty; +use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Size}; #[allow(dead_code)] fn round_pointer_up_to_alignment( diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 9e6a3b23323d8..0297415155553 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -31,14 +31,14 @@ use rustc_data_structures::profiling::print_time_passes_entry; use rustc_data_structures::sync::{par_iter, Lock, ParallelIterator}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; +use rustc_hir::lang_items::StartFnLangItem; use rustc_index::vec::Idx; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::middle::cstore::EncodedMetadata; use rustc_middle::middle::cstore::{self, LinkagePreference}; use rustc_middle::middle::lang_items; -use rustc_middle::middle::lang_items::StartFnLangItem; use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem}; -use rustc_middle::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyAndLayout, VariantIdx}; +use rustc_middle::ty::layout::{self, HasTyCtxt, TyAndLayout}; use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA}; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; @@ -47,6 +47,7 @@ use rustc_session::config::{self, EntryFnType, Lto}; use rustc_session::Session; use rustc_span::Span; use rustc_symbol_mangling::test as symbol_names_test; +use rustc_target::abi::{Abi, Align, LayoutOf, Scalar, VariantIdx}; use std::cmp; use std::ops::{Deref, DerefMut}; @@ -343,7 +344,7 @@ pub fn to_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( val: Bx::Value, layout: layout::TyAndLayout<'_>, ) -> Bx::Value { - if let layout::Abi::Scalar(ref scalar) = layout.abi { + if let Abi::Scalar(ref scalar) = layout.abi { return to_immediate_scalar(bx, val, scalar); } val @@ -352,7 +353,7 @@ pub fn to_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( pub fn to_immediate_scalar<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, val: Bx::Value, - scalar: &layout::Scalar, + scalar: &Scalar, ) -> Bx::Value { if scalar.is_bool() { return bx.trunc(val, bx.cx().type_i1()); diff --git a/src/librustc_codegen_ssa/common.rs b/src/librustc_codegen_ssa/common.rs index 8de04b730e170..0d0321ec4ae5e 100644 --- a/src/librustc_codegen_ssa/common.rs +++ b/src/librustc_codegen_ssa/common.rs @@ -1,17 +1,16 @@ #![allow(non_camel_case_types, non_snake_case)] use rustc_errors::struct_span_err; +use rustc_hir as hir; +use rustc_hir::def_id::DefId; +use rustc_hir::LangItem; use rustc_middle::ty::{Ty, TyCtxt}; use rustc_session::Session; use rustc_span::Span; use crate::base; -use crate::traits::*; -use rustc_hir::def_id::DefId; -use rustc_middle::middle::lang_items::LangItem; - use crate::traits::BuilderMethods; -use rustc_hir as hir; +use crate::traits::*; pub enum IntPredicate { IntEQ, diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs index bf2f92a473fe8..bf8441562c55b 100644 --- a/src/librustc_codegen_ssa/lib.rs +++ b/src/librustc_codegen_ssa/lib.rs @@ -21,10 +21,10 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::Lrc; use rustc_hir::def_id::CrateNum; +use rustc_hir::LangItem; use rustc_middle::dep_graph::WorkProduct; use rustc_middle::middle::cstore::{CrateSource, LibSource, NativeLibrary}; use rustc_middle::middle::dependency_format::Dependencies; -use rustc_middle::middle::lang_items::LangItem; use rustc_middle::ty::query::Providers; use rustc_session::config::{OutputFilenames, OutputType, RUST_CGU_EXT}; use rustc_span::symbol::Symbol; diff --git a/src/librustc_codegen_ssa/mir/analyze.rs b/src/librustc_codegen_ssa/mir/analyze.rs index ec3de274b8a83..221f36fed362d 100644 --- a/src/librustc_codegen_ssa/mir/analyze.rs +++ b/src/librustc_codegen_ssa/mir/analyze.rs @@ -12,7 +12,8 @@ use rustc_middle::mir::visit::{ }; use rustc_middle::mir::{self, Location, TerminatorKind}; use rustc_middle::ty; -use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf}; +use rustc_middle::ty::layout::HasTyCtxt; +use rustc_target::abi::LayoutOf; pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( fx: &FunctionCx<'a, 'tcx, Bx>, diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 931fab6ae01da..219d5aa77ea0d 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -9,14 +9,15 @@ use crate::meth; use crate::traits::*; use crate::MemFlags; +use rustc_hir::lang_items; use rustc_index::vec::Idx; -use rustc_middle::middle::lang_items; use rustc_middle::mir; use rustc_middle::mir::AssertKind; -use rustc_middle::ty::layout::{self, FnAbiExt, HasTyCtxt, LayoutOf}; +use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt}; use rustc_middle::ty::{self, Instance, Ty, TypeFoldable}; use rustc_span::{source_map::Span, symbol::Symbol}; use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode}; +use rustc_target::abi::{self, LayoutOf}; use rustc_target::spec::abi::Abi; use std::borrow::Cow; @@ -591,7 +592,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // we can do what we like. Here, we declare that transmuting // into an uninhabited type is impossible, so anything following // it must be unreachable. - assert_eq!(fn_abi.ret.layout.abi, layout::Abi::Uninhabited); + assert_eq!(fn_abi.ret.layout.abi, abi::Abi::Uninhabited); bx.unreachable(); } return; @@ -994,7 +995,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // the load would just produce `OperandValue::Ref` instead // of the `OperandValue::Immediate` we need for the call. llval = bx.load(llval, align); - if let layout::Abi::Scalar(ref scalar) = arg.layout.abi { + if let abi::Abi::Scalar(ref scalar) = arg.layout.abi { if scalar.is_bool() { bx.range_metadata(llval, 0..2); } diff --git a/src/librustc_codegen_ssa/mir/constant.rs b/src/librustc_codegen_ssa/mir/constant.rs index 9770d04aa99dd..298aa25f0321f 100644 --- a/src/librustc_codegen_ssa/mir/constant.rs +++ b/src/librustc_codegen_ssa/mir/constant.rs @@ -3,9 +3,10 @@ use crate::traits::*; use rustc_index::vec::Idx; use rustc_middle::mir; use rustc_middle::mir::interpret::{ConstValue, ErrorHandled}; -use rustc_middle::ty::layout::{self, HasTyCtxt}; +use rustc_middle::ty::layout::HasTyCtxt; use rustc_middle::ty::{self, Ty}; use rustc_span::source_map::Span; +use rustc_target::abi::Abi; use super::FunctionCx; @@ -87,7 +88,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if let Some(prim) = field.try_to_scalar() { let layout = bx.layout_of(field_ty); let scalar = match layout.abi { - layout::Abi::Scalar(ref x) => x, + Abi::Scalar(ref x) => x, _ => bug!("from_const: invalid ByVal layout: {:#?}", layout), }; bx.scalar_to_backend(prim, scalar, bx.immediate_backend_type(layout)) diff --git a/src/librustc_codegen_ssa/mir/debuginfo.rs b/src/librustc_codegen_ssa/mir/debuginfo.rs index 4eefb37ba0d42..5501ed5128d4d 100644 --- a/src/librustc_codegen_ssa/mir/debuginfo.rs +++ b/src/librustc_codegen_ssa/mir/debuginfo.rs @@ -3,11 +3,10 @@ use rustc_hir::def_id::CrateNum; use rustc_index::vec::IndexVec; use rustc_middle::mir; use rustc_middle::ty; -use rustc_middle::ty::layout::{LayoutOf, Size}; use rustc_session::config::DebugInfo; - use rustc_span::symbol::{kw, Symbol}; use rustc_span::{BytePos, Span}; +use rustc_target::abi::{LayoutOf, Size}; use super::operand::OperandValue; use super::place::PlaceRef; diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index 7545882a0eacb..69f11ed57ac5d 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -8,8 +8,9 @@ use crate::MemFlags; use rustc_middle::mir; use rustc_middle::mir::interpret::{ConstValue, ErrorHandled, Pointer, Scalar}; -use rustc_middle::ty::layout::{self, Align, LayoutOf, Size, TyAndLayout}; +use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::Ty; +use rustc_target::abi::{Abi, Align, LayoutOf, Size}; use std::fmt; @@ -78,7 +79,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { let val = match val { ConstValue::Scalar(x) => { let scalar = match layout.abi { - layout::Abi::Scalar(ref x) => x, + Abi::Scalar(ref x) => x, _ => bug!("from_const: invalid ByVal layout: {:#?}", layout), }; let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout)); @@ -86,7 +87,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { } ConstValue::Slice { data, start, end } => { let a_scalar = match layout.abi { - layout::Abi::ScalarPair(ref a, _) => a, + Abi::ScalarPair(ref a, _) => a, _ => bug!("from_const: invalid ScalarPair layout: {:#?}", layout), }; let a = Scalar::from(Pointer::new( @@ -161,7 +162,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { llval: V, layout: TyAndLayout<'tcx>, ) -> Self { - let val = if let layout::Abi::ScalarPair(ref a, ref b) = layout.abi { + let val = if let Abi::ScalarPair(ref a, ref b) = layout.abi { debug!("Operand::from_immediate_or_packed_pair: unpacking {:?} @ {:?}", llval, layout); // Deconstruct the immediate aggregate. @@ -199,7 +200,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { } // Extract a scalar component from a pair. - (OperandValue::Pair(a_llval, b_llval), &layout::Abi::ScalarPair(ref a, ref b)) => { + (OperandValue::Pair(a_llval, b_llval), &Abi::ScalarPair(ref a, ref b)) => { if offset.bytes() == 0 { assert_eq!(field.size, a.value.size(bx.cx())); OperandValue::Immediate(a_llval) @@ -211,7 +212,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { } // `#[repr(simd)]` types are also immediate. - (OperandValue::Immediate(llval), &layout::Abi::Vector { .. }) => { + (OperandValue::Immediate(llval), &Abi::Vector { .. }) => { OperandValue::Immediate(bx.extract_element(llval, bx.cx().const_usize(i as u64))) } @@ -305,7 +306,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandValue { } OperandValue::Pair(a, b) => { let (a_scalar, b_scalar) = match dest.layout.abi { - layout::Abi::ScalarPair(ref a, ref b) => (a, b), + Abi::ScalarPair(ref a, ref b) => (a, b), _ => bug!("store_with_flags: invalid ScalarPair layout: {:#?}", dest.layout), }; let b_offset = a_scalar.value.size(bx).align_to(b_scalar.value.align(bx).abi); diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index eca66a5704db9..461695129c2f3 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -8,8 +8,10 @@ use crate::MemFlags; use rustc_middle::mir; use rustc_middle::mir::tcx::PlaceTy; -use rustc_middle::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyAndLayout, VariantIdx}; +use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout}; use rustc_middle::ty::{self, Ty}; +use rustc_target::abi::{Abi, Align, DiscriminantKind, FieldsShape, Int}; +use rustc_target::abi::{LayoutOf, VariantIdx, Variants}; #[derive(Copy, Clone, Debug)] pub struct PlaceRef<'tcx, V> { @@ -66,7 +68,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { } pub fn len>(&self, cx: &Cx) -> V { - if let layout::FieldsShape::Array { count, .. } = self.layout.fields { + if let FieldsShape::Array { count, .. } = self.layout.fields { if self.layout.is_unsized() { assert_eq!(count, 0); self.llextra.unwrap() @@ -94,7 +96,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { // Unions and newtypes only use an offset of 0. let llval = if offset.bytes() == 0 { self.llval - } else if let layout::Abi::ScalarPair(ref a, ref b) = self.layout.abi { + } else if let Abi::ScalarPair(ref a, ref b) = self.layout.abi { // Offsets have to match either first or second field. assert_eq!(offset, a.value.size(bx.cx()).align_to(b.value.align(bx.cx()).abi)); bx.struct_gep(self.llval, 1) @@ -198,7 +200,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { return bx.cx().const_undef(cast_to); } let (discr_scalar, discr_kind, discr_index) = match self.layout.variants { - layout::Variants::Single { index } => { + Variants::Single { index } => { let discr_val = self .layout .ty @@ -206,7 +208,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { .map_or(index.as_u32() as u128, |discr| discr.val); return bx.cx().const_uint_big(cast_to, discr_val); } - layout::Variants::Multiple { ref discr, ref discr_kind, discr_index, .. } => { + Variants::Multiple { ref discr, ref discr_kind, discr_index, .. } => { (discr, discr_kind, discr_index) } }; @@ -217,22 +219,18 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { // Decode the discriminant (specifically if it's niche-encoded). match *discr_kind { - layout::DiscriminantKind::Tag => { + DiscriminantKind::Tag => { let signed = match discr_scalar.value { // We use `i1` for bytes that are always `0` or `1`, // e.g., `#[repr(i8)] enum E { A, B }`, but we can't // let LLVM interpret the `i1` as signed, because // then `i1 1` (i.e., `E::B`) is effectively `i8 -1`. - layout::Int(_, signed) => !discr_scalar.is_bool() && signed, + Int(_, signed) => !discr_scalar.is_bool() && signed, _ => false, }; bx.intcast(encoded_discr.immediate(), cast_to, signed) } - layout::DiscriminantKind::Niche { - dataful_variant, - ref niche_variants, - niche_start, - } => { + DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start } => { // Rebase from niche values to discriminants, and check // whether the result is in range for the niche variants. let niche_llty = bx.cx().immediate_backend_type(encoded_discr.layout); @@ -311,14 +309,10 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { return; } match self.layout.variants { - layout::Variants::Single { index } => { + Variants::Single { index } => { assert_eq!(index, variant_index); } - layout::Variants::Multiple { - discr_kind: layout::DiscriminantKind::Tag, - discr_index, - .. - } => { + Variants::Multiple { discr_kind: DiscriminantKind::Tag, discr_index, .. } => { let ptr = self.project_field(bx, discr_index); let to = self.layout.ty.discriminant_for_variant(bx.tcx(), variant_index).unwrap().val; @@ -328,9 +322,9 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { ptr.align, ); } - layout::Variants::Multiple { + Variants::Multiple { discr_kind: - layout::DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start }, + DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start }, discr_index, .. } => { diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index ce681c729b2b5..33f449ed270be 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -8,13 +8,14 @@ use crate::traits::*; use crate::MemFlags; use rustc_apfloat::{ieee, Float, Round, Status}; -use rustc_middle::middle::lang_items::ExchangeMallocFnLangItem; +use rustc_hir::lang_items::ExchangeMallocFnLangItem; use rustc_middle::mir; use rustc_middle::ty::cast::{CastTy, IntTy}; -use rustc_middle::ty::layout::{self, HasTyCtxt, LayoutOf}; +use rustc_middle::ty::layout::HasTyCtxt; use rustc_middle::ty::{self, adjustment::PointerCast, Instance, Ty, TyCtxt}; use rustc_span::source_map::{Span, DUMMY_SP}; use rustc_span::symbol::sym; +use rustc_target::abi::{Abi, Int, LayoutOf, Variants}; use std::{i128, u128}; @@ -292,7 +293,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let r_t_out = CastTy::from_ty(cast.ty).expect("bad output type for cast"); let ll_t_in = bx.cx().immediate_backend_type(operand.layout); match operand.layout.variants { - layout::Variants::Single { index } => { + Variants::Single { index } => { if let Some(discr) = operand.layout.ty.discriminant_for_variant(bx.tcx(), index) { @@ -311,13 +312,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ); } } - layout::Variants::Multiple { .. } => {} + Variants::Multiple { .. } => {} } let llval = operand.immediate(); let mut signed = false; - if let layout::Abi::Scalar(ref scalar) = operand.layout.abi { - if let layout::Int(_, s) = scalar.value { + if let Abi::Scalar(ref scalar) = operand.layout.abi { + if let Int(_, s) = scalar.value { // We use `i1` for bytes that are always `0` or `1`, // e.g., `#[repr(i8)] enum E { A, B }`, but we can't // let LLVM interpret the `i1` as signed, because diff --git a/src/librustc_codegen_ssa/traits/backend.rs b/src/librustc_codegen_ssa/traits/backend.rs index 1474edd8aa09a..91be123beb0bc 100644 --- a/src/librustc_codegen_ssa/traits/backend.rs +++ b/src/librustc_codegen_ssa/traits/backend.rs @@ -3,17 +3,18 @@ use super::CodegenObject; use crate::ModuleCodegen; use rustc_ast::expand::allocator::AllocatorKind; +use rustc_errors::ErrorReported; use rustc_middle::dep_graph::DepGraph; use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoaderDyn}; -use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout}; +use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout}; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{Ty, TyCtxt}; -use rustc_middle::util::common::ErrorReported; use rustc_session::{ config::{self, OutputFilenames, PrintRequest}, Session, }; use rustc_span::symbol::Symbol; +use rustc_target::abi::LayoutOf; pub use rustc_data_structures::sync::MetadataRef; diff --git a/src/librustc_codegen_ssa/traits/builder.rs b/src/librustc_codegen_ssa/traits/builder.rs index d59ea387b86ba..caba7ebef593b 100644 --- a/src/librustc_codegen_ssa/traits/builder.rs +++ b/src/librustc_codegen_ssa/traits/builder.rs @@ -12,8 +12,9 @@ use crate::mir::operand::OperandRef; use crate::mir::place::PlaceRef; use crate::MemFlags; -use rustc_middle::ty::layout::{Align, HasParamEnv, Size}; +use rustc_middle::ty::layout::HasParamEnv; use rustc_middle::ty::Ty; +use rustc_target::abi::{Align, Size}; use rustc_target::spec::HasTargetSpec; use std::iter::TrustedLen; diff --git a/src/librustc_codegen_ssa/traits/consts.rs b/src/librustc_codegen_ssa/traits/consts.rs index e5e1aa658e62e..6b58dea794bcb 100644 --- a/src/librustc_codegen_ssa/traits/consts.rs +++ b/src/librustc_codegen_ssa/traits/consts.rs @@ -1,9 +1,9 @@ use super::BackendTypes; use crate::mir::place::PlaceRef; -use rustc_middle::mir::interpret::Allocation; -use rustc_middle::mir::interpret::Scalar; -use rustc_middle::ty::layout; +use rustc_middle::mir::interpret::{Allocation, Scalar}; +use rustc_middle::ty::layout::TyAndLayout; use rustc_span::Symbol; +use rustc_target::abi::{self, Size}; pub trait ConstMethods<'tcx>: BackendTypes { // Constant constructors @@ -26,17 +26,12 @@ pub trait ConstMethods<'tcx>: BackendTypes { fn const_to_opt_uint(&self, v: Self::Value) -> Option; fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option; - fn scalar_to_backend( - &self, - cv: Scalar, - layout: &layout::Scalar, - llty: Self::Type, - ) -> Self::Value; + fn scalar_to_backend(&self, cv: Scalar, layout: &abi::Scalar, llty: Self::Type) -> Self::Value; fn from_const_alloc( &self, - layout: layout::TyAndLayout<'tcx>, + layout: TyAndLayout<'tcx>, alloc: &Allocation, - offset: layout::Size, + offset: Size, ) -> PlaceRef<'tcx, Self::Value>; fn const_ptrcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value; diff --git a/src/librustc_codegen_ssa/traits/debuginfo.rs b/src/librustc_codegen_ssa/traits/debuginfo.rs index 4e84c096822ef..34be1cfdd8844 100644 --- a/src/librustc_codegen_ssa/traits/debuginfo.rs +++ b/src/librustc_codegen_ssa/traits/debuginfo.rs @@ -3,10 +3,10 @@ use crate::mir::debuginfo::{FunctionDebugContext, VariableKind}; use rustc_ast::ast::Name; use rustc_hir::def_id::CrateNum; use rustc_middle::mir; -use rustc_middle::ty::layout::Size; use rustc_middle::ty::{Instance, Ty}; use rustc_span::{SourceFile, Span}; use rustc_target::abi::call::FnAbi; +use rustc_target::abi::Size; pub trait DebugInfoMethods<'tcx>: BackendTypes { fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value); diff --git a/src/librustc_codegen_ssa/traits/statics.rs b/src/librustc_codegen_ssa/traits/statics.rs index 50df08614345f..a6462b358347b 100644 --- a/src/librustc_codegen_ssa/traits/statics.rs +++ b/src/librustc_codegen_ssa/traits/statics.rs @@ -1,6 +1,6 @@ use super::BackendTypes; use rustc_hir::def_id::DefId; -use rustc_middle::ty::layout::Align; +use rustc_target::abi::Align; pub trait StaticMethods: BackendTypes { fn static_addr_of(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value; diff --git a/src/librustc_codegen_ssa/traits/type_.rs b/src/librustc_codegen_ssa/traits/type_.rs index 383be6dfcb5ea..703479b74bef8 100644 --- a/src/librustc_codegen_ssa/traits/type_.rs +++ b/src/librustc_codegen_ssa/traits/type_.rs @@ -3,10 +3,11 @@ use super::Backend; use super::HasCodegen; use crate::common::TypeKind; use crate::mir::place::PlaceRef; -use rustc_middle::ty::layout::{self, TyAndLayout}; +use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{self, Ty}; use rustc_span::DUMMY_SP; use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg}; +use rustc_target::abi::Integer; // This depends on `Backend` and not `BackendTypes`, because consumers will probably want to use // `LayoutOf` or `HasTyCtxt`. This way, they don't have to add a constraint on it themselves. @@ -53,8 +54,8 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> { } } - fn type_from_integer(&self, i: layout::Integer) -> Self::Type { - use rustc_middle::ty::layout::Integer::*; + fn type_from_integer(&self, i: Integer) -> Self::Type { + use Integer::*; match i { I8 => self.type_i8(), I16 => self.type_i16(), diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 8f8c2eae6e27d..ccbce01d6c12e 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -22,10 +22,8 @@ use rustc_ast::ast; use rustc_codegen_ssa::{traits::CodegenBackend, CodegenResults}; use rustc_data_structures::profiling::print_time_passes_entry; use rustc_data_structures::sync::SeqCst; -use rustc_errors::{ - registry::{InvalidErrorCode, Registry}, - PResult, -}; +use rustc_errors::registry::{InvalidErrorCode, Registry}; +use rustc_errors::{ErrorReported, PResult}; use rustc_feature::{find_gated_cfg, UnstableFeatures}; use rustc_hir::def_id::LOCAL_CRATE; use rustc_interface::util::{collect_crate_types, get_builtin_codegen_backend}; @@ -34,7 +32,6 @@ use rustc_lint::LintStore; use rustc_metadata::locator; use rustc_middle::middle::cstore::MetadataLoader; use rustc_middle::ty::TyCtxt; -use rustc_middle::util::common::ErrorReported; use rustc_save_analysis as save; use rustc_save_analysis::DumpHandler; use rustc_serialize::json::{self, ToJson}; diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 87777bd674bf2..78a271810b288 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -2,12 +2,12 @@ use rustc_ast::ast; use rustc_ast_pretty::pprust; +use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir_pretty as pprust_hir; use rustc_middle::hir::map as hir_map; use rustc_middle::ty::{self, TyCtxt}; -use rustc_middle::util::common::ErrorReported; use rustc_mir::util::{write_mir_graphviz, write_mir_pretty}; use rustc_session::config::{Input, PpMode, PpSourceMode}; use rustc_session::Session; diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/different_lifetimes.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/different_lifetimes.rs index 3836bd9afa8b6..d206a30d526cb 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/different_lifetimes.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/different_lifetimes.rs @@ -5,9 +5,8 @@ use crate::infer::error_reporting::nice_region_error::util::AnonymousParamInfo; use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::infer::lexical_region_resolve::RegionResolutionError; use crate::infer::SubregionOrigin; -use rustc_middle::util::common::ErrorReported; -use rustc_errors::struct_span_err; +use rustc_errors::{struct_span_err, ErrorReported}; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// Print the error message for lifetime errors when both the concerned regions are anonymous. diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/mod.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/mod.rs index 4613c43ba07af..2aed3d9a469fb 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/mod.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/mod.rs @@ -1,9 +1,8 @@ use crate::infer::lexical_region_resolve::RegionResolutionError; use crate::infer::lexical_region_resolve::RegionResolutionError::*; use crate::infer::InferCtxt; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::{DiagnosticBuilder, ErrorReported}; use rustc_middle::ty::{self, TyCtxt}; -use rustc_middle::util::common::ErrorReported; use rustc_span::source_map::Span; mod different_lifetimes; diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/outlives_closure.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/outlives_closure.rs index 028148b17db18..70c302710430b 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/outlives_closure.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/outlives_closure.rs @@ -4,9 +4,9 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::infer::lexical_region_resolve::RegionResolutionError::SubSupConflict; use crate::infer::SubregionOrigin; +use rustc_errors::ErrorReported; use rustc_hir::{Expr, ExprKind::Closure, Node}; use rustc_middle::ty::RegionKind; -use rustc_middle::util::common::ErrorReported; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// Print the error message for lifetime errors when binding escapes a closure. diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs index 34653f2dc0db8..7f3ec852e41de 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -3,9 +3,8 @@ use crate::infer::error_reporting::msg_span_from_free_region; use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::infer::lexical_region_resolve::RegionResolutionError; -use rustc_errors::Applicability; +use rustc_errors::{Applicability, ErrorReported}; use rustc_middle::ty::{BoundRegion, FreeRegion, RegionKind}; -use rustc_middle::util::common::ErrorReported; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// Print the error message for lifetime errors when the return type is a static impl Trait. diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/trait_impl_difference.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/trait_impl_difference.rs index a2cd54b48d520..695f3e47fb5d7 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/trait_impl_difference.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/trait_impl_difference.rs @@ -4,8 +4,8 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::infer::lexical_region_resolve::RegionResolutionError; use crate::infer::{Subtype, ValuePairs}; use crate::traits::ObligationCauseCode::CompareImplMethodObligation; +use rustc_errors::ErrorReported; use rustc_middle::ty::Ty; -use rustc_middle::util::common::ErrorReported; use rustc_span::Span; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs index a50e802ac2ec6..8e929b7daa850 100644 --- a/src/librustc_interface/interface.rs +++ b/src/librustc_interface/interface.rs @@ -8,9 +8,9 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::OnDrop; use rustc_errors::registry::Registry; +use rustc_errors::ErrorReported; use rustc_lint::LintStore; use rustc_middle::ty; -use rustc_middle::util::common::ErrorReported; use rustc_parse::new_parser_from_source_str; use rustc_session::config::{self, ErrorOutputType, Input, OutputFilenames}; use rustc_session::early_error; diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index e3fc4fa52fb61..609c80a2b7905 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -9,7 +9,7 @@ use rustc_codegen_ssa::back::link::emit_metadata; use rustc_codegen_ssa::traits::CodegenBackend; use rustc_data_structures::sync::{par_iter, Lrc, Once, ParallelIterator, WorkerLocal}; use rustc_data_structures::{box_region_allow_access, declare_box_region_type, parallel}; -use rustc_errors::PResult; +use rustc_errors::{ErrorReported, PResult}; use rustc_expand::base::ExtCtxt; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; use rustc_hir::definitions::Definitions; @@ -21,7 +21,6 @@ use rustc_middle::middle; use rustc_middle::middle::cstore::{CrateStore, MetadataLoader, MetadataLoaderDyn}; use rustc_middle::ty::steal::Steal; use rustc_middle::ty::{self, GlobalCtxt, ResolverOutputs, TyCtxt}; -use rustc_middle::util::common::ErrorReported; use rustc_mir as mir; use rustc_mir_build as mir_build; use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str}; diff --git a/src/librustc_interface/queries.rs b/src/librustc_interface/queries.rs index 995776552dd18..6a62d754f2891 100644 --- a/src/librustc_interface/queries.rs +++ b/src/librustc_interface/queries.rs @@ -4,6 +4,7 @@ use crate::passes::{self, BoxedResolver, QueryContext}; use rustc_ast::{self, ast}; use rustc_codegen_ssa::traits::CodegenBackend; use rustc_data_structures::sync::{Lrc, Once, WorkerLocal}; +use rustc_errors::ErrorReported; use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::Crate; use rustc_incremental::DepGraphFuture; @@ -12,7 +13,6 @@ use rustc_middle::arena::Arena; use rustc_middle::dep_graph::DepGraph; use rustc_middle::ty::steal::Steal; use rustc_middle::ty::{GlobalCtxt, ResolverOutputs, TyCtxt}; -use rustc_middle::util::common::ErrorReported; use rustc_session::config::{OutputFilenames, OutputType}; use rustc_session::{output::find_crate_name, Session}; use rustc_span::symbol::sym; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 646febec72334..cff86e8f21837 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -36,12 +36,13 @@ use rustc_hir::def_id::DefId; use rustc_hir::{GenericParamKind, PatKind}; use rustc_hir::{HirIdSet, Node}; use rustc_middle::lint::LintDiagnosticBuilder; -use rustc_middle::ty::{self, layout::VariantIdx, Ty, TyCtxt}; +use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::lint::FutureIncompatibleInfo; use rustc_span::edition::Edition; use rustc_span::source_map::Spanned; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::{BytePos, Span}; +use rustc_target::abi::VariantIdx; use rustc_trait_selection::traits::misc::can_type_implement_copy; use crate::nonstandard_style::{method_context, MethodLateContext}; diff --git a/src/librustc_lint/context.rs b/src/librustc_lint/context.rs index 12543cf83ddb2..1747a78d36a4c 100644 --- a/src/librustc_lint/context.rs +++ b/src/librustc_lint/context.rs @@ -29,12 +29,13 @@ use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; use rustc_middle::lint::LintDiagnosticBuilder; use rustc_middle::middle::privacy::AccessLevels; use rustc_middle::middle::stability; -use rustc_middle::ty::layout::{LayoutError, LayoutOf, TyAndLayout}; +use rustc_middle::ty::layout::{LayoutError, TyAndLayout}; use rustc_middle::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt}; use rustc_session::lint::{add_elided_lifetime_in_path_suggestion, BuiltinLintDiagnostics}; use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId}; use rustc_session::Session; use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP}; +use rustc_target::abi::LayoutOf; use std::slice; diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 52ec8cd938156..a6e1ed84c8708 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -10,12 +10,13 @@ use rustc_hir::def_id::DefId; use rustc_hir::{is_range_literal, ExprKind, Node}; use rustc_index::vec::Idx; use rustc_middle::mir::interpret::{sign_extend, truncate}; -use rustc_middle::ty::layout::{self, IntegerExt, LayoutOf, SizeSkeleton, VariantIdx}; +use rustc_middle::ty::layout::{IntegerExt, SizeSkeleton}; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt}; use rustc_span::source_map; use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_target::abi::{DiscriminantKind, Integer, LayoutOf, VariantIdx, Variants}; use rustc_target::spec::abi::Abi; use log::debug; @@ -150,7 +151,7 @@ fn report_bin_hex_error( val: u128, negative: bool, ) { - let size = layout::Integer::from_attr(&cx.tcx, ty).size(); + let size = Integer::from_attr(&cx.tcx, ty).size(); cx.struct_span_lint(OVERFLOWING_LITERALS, expr.span, |lint| { let (t, actually) = match ty { attr::IntType::SignedInt(t) => { @@ -1034,8 +1035,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences { | Err(ty::layout::LayoutError::SizeOverflow(_)) => return, }; let (variants, tag) = match layout.variants { - layout::Variants::Multiple { - discr_kind: layout::DiscriminantKind::Tag, + Variants::Multiple { + discr_kind: DiscriminantKind::Tag, ref discr, ref variants, .. diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs index 004c5f2ebb7f4..1cb5dcb465c72 100644 --- a/src/librustc_metadata/rmeta/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -18,13 +18,13 @@ use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::definitions::DefPathTable; use rustc_hir::definitions::{DefKey, DefPath, DefPathData, DefPathHash}; +use rustc_hir::lang_items; use rustc_index::vec::{Idx, IndexVec}; use rustc_middle::dep_graph::{self, DepNode, DepNodeExt, DepNodeIndex}; use rustc_middle::hir::exports::Export; use rustc_middle::middle::cstore::{CrateSource, ExternCrate}; use rustc_middle::middle::cstore::{ForeignModule, LinkagePreference, NativeLibrary}; use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel}; -use rustc_middle::middle::lang_items; use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState}; use rustc_middle::mir::{self, interpret, BodyAndCache, Promoted}; use rustc_middle::ty::codec::TyDecoder; diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index f6e2730cb5761..417c548690779 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -15,6 +15,7 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, use rustc_hir::definitions::DefPathTable; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::itemlikevisit::{ItemLikeVisitor, ParItemLikeVisitor}; +use rustc_hir::lang_items; use rustc_hir::{AnonConst, GenericParamKind}; use rustc_index::vec::Idx; use rustc_middle::hir::map::Map; @@ -25,17 +26,16 @@ use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::exported_symbols::{ metadata_symbol_name, ExportedSymbol, SymbolExportLevel, }; -use rustc_middle::middle::lang_items; use rustc_middle::mir::{self, interpret}; use rustc_middle::traits::specialization_graph; use rustc_middle::ty::codec::{self as ty_codec, TyEncoder}; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::{self, SymbolName, Ty, TyCtxt}; use rustc_serialize::{opaque, Encodable, Encoder, SpecializedEncoder}; use rustc_session::config::{self, CrateType}; use rustc_span::source_map::Spanned; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::{self, ExternalSource, FileName, SourceFile, Span}; +use rustc_target::abi::VariantIdx; use std::hash::Hash; use std::num::NonZeroUsize; use std::path::Path; diff --git a/src/librustc_metadata/rmeta/mod.rs b/src/librustc_metadata/rmeta/mod.rs index d0ad76b0fc7ea..d6260c536aa18 100644 --- a/src/librustc_metadata/rmeta/mod.rs +++ b/src/librustc_metadata/rmeta/mod.rs @@ -8,11 +8,11 @@ use rustc_data_structures::sync::MetadataRef; use rustc_hir as hir; use rustc_hir::def::CtorKind; use rustc_hir::def_id::{DefId, DefIndex}; +use rustc_hir::lang_items; use rustc_index::vec::IndexVec; use rustc_middle::hir::exports::Export; use rustc_middle::middle::cstore::{DepKind, ForeignModule, LinkagePreference, NativeLibrary}; use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel}; -use rustc_middle::middle::lang_items; use rustc_middle::mir; use rustc_middle::ty::{self, ReprOptions, Ty}; use rustc_serialize::opaque::Encoder; diff --git a/src/librustc_middle/arena.rs b/src/librustc_middle/arena.rs index fcf6989043a54..e3dec59478c1f 100644 --- a/src/librustc_middle/arena.rs +++ b/src/librustc_middle/arena.rs @@ -11,7 +11,7 @@ macro_rules! arena_types { ($macro:path, $args:tt, $tcx:lifetime) => ( $macro!($args, [ - [] layouts: rustc_middle::ty::layout::Layout, + [] layouts: rustc_target::abi::Layout, [] generics: rustc_middle::ty::Generics, [] trait_def: rustc_middle::ty::TraitDef, [] adt_def: rustc_middle::ty::AdtDef, @@ -106,7 +106,7 @@ macro_rules! arena_types { String >, [few] get_lib_features: rustc_middle::middle::lib_features::LibFeatures, - [few] defined_lib_features: rustc_middle::middle::lang_items::LanguageItems, + [few] defined_lib_features: rustc_hir::lang_items::LanguageItems, [few] visible_parent_map: rustc_hir::def_id::DefIdMap, [few] foreign_module: rustc_middle::middle::cstore::ForeignModule, [few] foreign_modules: Vec, diff --git a/src/librustc_middle/ich/mod.rs b/src/librustc_middle/ich/mod.rs index 516e3ed979c7c..c8fb2bf39cc80 100644 --- a/src/librustc_middle/ich/mod.rs +++ b/src/librustc_middle/ich/mod.rs @@ -4,7 +4,6 @@ pub use self::hcx::{ hash_stable_trait_impls, NodeIdHashingMode, StableHashingContext, StableHashingContextProvider, }; use rustc_span::symbol::{sym, Symbol}; -pub use rustc_span::CachingSourceMapView; mod hcx; diff --git a/src/librustc_middle/middle/lang_items.rs b/src/librustc_middle/middle/lang_items.rs index 36560371587a5..0f98c338c16b1 100644 --- a/src/librustc_middle/middle/lang_items.rs +++ b/src/librustc_middle/middle/lang_items.rs @@ -7,17 +7,13 @@ //! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`. //! * Functions called by the compiler itself. -pub use self::LangItem::*; - use crate::ty::{self, TyCtxt}; use rustc_hir::def_id::DefId; +use rustc_hir::LangItem; use rustc_span::Span; use rustc_target::spec::PanicStrategy; -pub use rustc_hir::weak_lang_items::link_name; -pub use rustc_hir::{LangItem, LanguageItems}; - impl<'tcx> TyCtxt<'tcx> { /// Returns the `DefId` for a given `LangItem`. /// If not found, fatally aborts compilation. diff --git a/src/librustc_middle/mir/interpret/allocation.rs b/src/librustc_middle/mir/interpret/allocation.rs index 0e75f34629e0e..8b9f09774853a 100644 --- a/src/librustc_middle/mir/interpret/allocation.rs +++ b/src/librustc_middle/mir/interpret/allocation.rs @@ -7,14 +7,12 @@ use std::ops::{Deref, DerefMut, Range}; use rustc_ast::ast::Mutability; use rustc_data_structures::sorted_map::SortedMap; -use rustc_target::abi::HasDataLayout; +use rustc_target::abi::{Align, HasDataLayout, Size}; use super::{ read_target_uint, write_target_uint, AllocId, InterpResult, Pointer, Scalar, ScalarMaybeUndef, }; -use crate::ty::layout::{Align, Size}; - // NOTE: When adding new fields, make sure to adjust the `Snapshot` impl in // `src/librustc_mir/interpret/snapshot.rs`. #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] diff --git a/src/librustc_middle/mir/interpret/error.rs b/src/librustc_middle/mir/interpret/error.rs index d46f1bc4cc4d8..7844fb108406d 100644 --- a/src/librustc_middle/mir/interpret/error.rs +++ b/src/librustc_middle/mir/interpret/error.rs @@ -1,7 +1,7 @@ use super::{AllocId, CheckInAllocMsg, Pointer, RawConst, ScalarMaybeUndef}; use crate::mir::interpret::ConstValue; -use crate::ty::layout::{Align, LayoutError, Size}; +use crate::ty::layout::LayoutError; use crate::ty::query::TyCtxtAt; use crate::ty::tls; use crate::ty::{self, layout, Ty}; @@ -14,6 +14,7 @@ use rustc_hir::definitions::DefPathData; use rustc_macros::HashStable; use rustc_session::CtfeBacktrace; use rustc_span::{def_id::DefId, Pos, Span}; +use rustc_target::abi::{Align, Size}; use std::{any::Any, fmt, mem}; #[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable)] diff --git a/src/librustc_middle/mir/interpret/mod.rs b/src/librustc_middle/mir/interpret/mod.rs index 10c3a06da0810..96bf694d8fa67 100644 --- a/src/librustc_middle/mir/interpret/mod.rs +++ b/src/librustc_middle/mir/interpret/mod.rs @@ -109,10 +109,10 @@ use rustc_data_structures::tiny_list::TinyList; use rustc_hir::def_id::DefId; use rustc_macros::HashStable; use rustc_serialize::{Decodable, Encodable, Encoder}; +use rustc_target::abi::{Endian, Size}; use crate::mir; use crate::ty::codec::TyDecoder; -use crate::ty::layout::{self, Size}; use crate::ty::subst::GenericArgKind; use crate::ty::{self, Instance, Ty, TyCtxt}; @@ -521,22 +521,22 @@ impl<'tcx> AllocMap<'tcx> { #[inline] pub fn write_target_uint( - endianness: layout::Endian, + endianness: Endian, mut target: &mut [u8], data: u128, ) -> Result<(), io::Error> { let len = target.len(); match endianness { - layout::Endian::Little => target.write_uint128::(data, len), - layout::Endian::Big => target.write_uint128::(data, len), + Endian::Little => target.write_uint128::(data, len), + Endian::Big => target.write_uint128::(data, len), } } #[inline] -pub fn read_target_uint(endianness: layout::Endian, mut source: &[u8]) -> Result { +pub fn read_target_uint(endianness: Endian, mut source: &[u8]) -> Result { match endianness { - layout::Endian::Little => source.read_uint128::(source.len()), - layout::Endian::Big => source.read_uint128::(source.len()), + Endian::Little => source.read_uint128::(source.len()), + Endian::Big => source.read_uint128::(source.len()), } } diff --git a/src/librustc_middle/mir/interpret/pointer.rs b/src/librustc_middle/mir/interpret/pointer.rs index d22207bd81651..7549d902dfbfe 100644 --- a/src/librustc_middle/mir/interpret/pointer.rs +++ b/src/librustc_middle/mir/interpret/pointer.rs @@ -1,8 +1,7 @@ use super::{AllocId, InterpResult}; -use crate::ty::layout::{self, HasDataLayout, Size}; - use rustc_macros::HashStable; +use rustc_target::abi::{HasDataLayout, Size}; use std::convert::TryFrom; use std::fmt::{self, Display}; @@ -37,7 +36,7 @@ impl Display for CheckInAllocMsg { // Pointer arithmetic //////////////////////////////////////////////////////////////////////////////// -pub trait PointerArithmetic: layout::HasDataLayout { +pub trait PointerArithmetic: HasDataLayout { // These are not supposed to be overridden. #[inline(always)] @@ -100,7 +99,7 @@ pub trait PointerArithmetic: layout::HasDataLayout { } } -impl PointerArithmetic for T {} +impl PointerArithmetic for T {} /// `Pointer` is generic over the type that represents a reference to `Allocation`s, /// thus making it possible for the most convenient representation to be used in diff --git a/src/librustc_middle/mir/interpret/value.rs b/src/librustc_middle/mir/interpret/value.rs index bf4ee8488238f..f3c1c87dad484 100644 --- a/src/librustc_middle/mir/interpret/value.rs +++ b/src/librustc_middle/mir/interpret/value.rs @@ -6,12 +6,9 @@ use rustc_apfloat::{ Float, }; use rustc_macros::HashStable; -use rustc_target::abi::TargetDataLayout; +use rustc_target::abi::{HasDataLayout, Size, TargetDataLayout}; -use crate::ty::{ - layout::{HasDataLayout, Size}, - ParamEnv, Ty, TyCtxt, -}; +use crate::ty::{ParamEnv, Ty, TyCtxt}; use super::{sign_extend, truncate, AllocId, Allocation, InterpResult, Pointer, PointerArithmetic}; diff --git a/src/librustc_middle/mir/mod.rs b/src/librustc_middle/mir/mod.rs index 216fe43e81997..36e10f8759d17 100644 --- a/src/librustc_middle/mir/mod.rs +++ b/src/librustc_middle/mir/mod.rs @@ -6,7 +6,6 @@ use crate::mir::interpret::{GlobalAlloc, Scalar}; use crate::mir::visit::MirVisitable; use crate::ty::adjustment::PointerCast; use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; -use crate::ty::layout::VariantIdx; use crate::ty::print::{FmtPrinter, Printer}; use crate::ty::subst::{Subst, SubstsRef}; use crate::ty::{ @@ -16,6 +15,7 @@ use rustc_hir as hir; use rustc_hir::def::{CtorKind, Namespace}; use rustc_hir::def_id::DefId; use rustc_hir::{self, GeneratorKind}; +use rustc_target::abi::VariantIdx; use polonius_engine::Atom; pub use rustc_ast::ast::Mutability; diff --git a/src/librustc_middle/mir/tcx.rs b/src/librustc_middle/mir/tcx.rs index feb6631926712..06b27c5e8b329 100644 --- a/src/librustc_middle/mir/tcx.rs +++ b/src/librustc_middle/mir/tcx.rs @@ -4,11 +4,11 @@ */ use crate::mir::*; -use crate::ty::layout::VariantIdx; use crate::ty::subst::Subst; use crate::ty::util::IntTypeExt; use crate::ty::{self, Ty, TyCtxt}; use rustc_hir as hir; +use rustc_target::abi::VariantIdx; #[derive(Copy, Clone, Debug, TypeFoldable)] pub struct PlaceTy<'tcx> { diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs index c1ece6275092d..2ffbbfb1762d3 100644 --- a/src/librustc_middle/query/mod.rs +++ b/src/librustc_middle/query/mod.rs @@ -738,7 +738,7 @@ rustc_queries! { query layout_raw( env: ty::ParamEnvAnd<'tcx, Ty<'tcx>> - ) -> Result<&'tcx ty::layout::Layout, ty::layout::LayoutError<'tcx>> { + ) -> Result<&'tcx rustc_target::abi::Layout, ty::layout::LayoutError<'tcx>> { desc { "computing layout of `{}`", env.value } } } diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index be889f66228d5..95d0c758d08de 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -11,8 +11,6 @@ use crate::lint::{struct_lint_level, LintSource}; use crate::middle; use crate::middle::cstore::CrateStoreDyn; use crate::middle::cstore::EncodedMetadata; -use crate::middle::lang_items; -use crate::middle::lang_items::PanicLocationLangItem; use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault}; use crate::middle::stability; use crate::mir::interpret::{Allocation, ConstValue, Scalar}; @@ -21,7 +19,6 @@ use crate::mir::{ }; use crate::traits; use crate::traits::{Clause, Clauses, Goal, GoalKind, Goals}; -use crate::ty::layout::{Layout, TargetDataLayout, VariantIdx}; use crate::ty::query; use crate::ty::steal::Steal; use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef}; @@ -38,7 +35,6 @@ use crate::ty::{ConstVid, FloatVar, FloatVid, IntVar, IntVid, TyVar, TyVid}; use crate::ty::{ExistentialPredicate, InferTy, ParamTy, PolyFnSig, Predicate, ProjectionTy}; use crate::ty::{InferConst, ParamConst}; use crate::ty::{List, TyKind, TyS}; -use crate::util::common::ErrorReported; use rustc_ast::ast; use rustc_ast::expand::allocator::AllocatorKind; use rustc_ast::node_id::NodeMap; @@ -50,10 +46,13 @@ use rustc_data_structures::stable_hasher::{ hash_stable_hashmap, HashStable, StableHasher, StableVec, }; use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal}; +use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE}; use rustc_hir::definitions::{DefPathData, DefPathHash, Definitions}; +use rustc_hir::lang_items; +use rustc_hir::lang_items::PanicLocationLangItem; use rustc_hir::{HirId, Node, TraitCandidate}; use rustc_hir::{ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet}; use rustc_index::vec::{Idx, IndexVec}; @@ -65,6 +64,7 @@ use rustc_session::Session; use rustc_span::source_map::MultiSpan; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::Span; +use rustc_target::abi::{Layout, TargetDataLayout, VariantIdx}; use rustc_target::spec::abi; use smallvec::SmallVec; @@ -1203,7 +1203,7 @@ impl<'tcx> TyCtxt<'tcx> { } /// Obtain all lang items of this crate and all dependencies (recursively) - pub fn lang_items(self) -> &'tcx middle::lang_items::LanguageItems { + pub fn lang_items(self) -> &'tcx rustc_hir::lang_items::LanguageItems { self.get_lang_items(LOCAL_CRATE) } diff --git a/src/librustc_middle/ty/instance.rs b/src/librustc_middle/ty/instance.rs index fcfee0fea85af..5d47a6e13f488 100644 --- a/src/librustc_middle/ty/instance.rs +++ b/src/librustc_middle/ty/instance.rs @@ -1,10 +1,10 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; -use crate::middle::lang_items::DropInPlaceFnLangItem; use crate::ty::print::{FmtPrinter, Printer}; use crate::ty::{self, SubstsRef, Ty, TyCtxt, TypeFoldable}; use rustc_data_structures::AtomicRef; use rustc_hir::def::Namespace; use rustc_hir::def_id::{CrateNum, DefId}; +use rustc_hir::lang_items::DropInPlaceFnLangItem; use rustc_macros::HashStable; use std::fmt; diff --git a/src/librustc_middle/ty/layout.rs b/src/librustc_middle/ty/layout.rs index 727d302d53f08..520793c69fdd2 100644 --- a/src/librustc_middle/ty/layout.rs +++ b/src/librustc_middle/ty/layout.rs @@ -15,7 +15,7 @@ use rustc_span::DUMMY_SP; use rustc_target::abi::call::{ ArgAbi, ArgAttribute, ArgAttributes, Conv, FnAbi, PassMode, Reg, RegKind, }; -pub use rustc_target::abi::*; +use rustc_target::abi::*; use rustc_target::spec::{abi::Abi as SpecAbi, HasTargetSpec, PanicStrategy}; use std::cmp; diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 43982439d47c8..3d1893d3bd07b 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -11,14 +11,12 @@ use crate::hir::exports::ExportMap; use crate::ich::StableHashingContext; use crate::infer::canonical::Canonical; use crate::middle::cstore::CrateStoreDyn; -use crate::middle::lang_items::{FnMutTraitLangItem, FnOnceTraitLangItem, FnTraitLangItem}; use crate::middle::resolve_lifetime::ObjectLifetimeDefault; use crate::mir::interpret::ErrorHandled; use crate::mir::GeneratorLayout; use crate::mir::ReadOnlyBodyAndCache; use crate::traits::{self, Reveal}; use crate::ty; -use crate::ty::layout::VariantIdx; use crate::ty::subst::{InternalSubsts, Subst, SubstsRef}; use crate::ty::util::{Discr, IntTypeExt}; use crate::ty::walk::TypeWalker; @@ -35,6 +33,7 @@ use rustc_data_structures::sync::{self, par_iter, Lrc, ParallelIterator}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Namespace, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX}; +use rustc_hir::lang_items::{FnMutTraitLangItem, FnOnceTraitLangItem, FnTraitLangItem}; use rustc_hir::{Constness, GlobMap, Node, TraitMap}; use rustc_index::vec::{Idx, IndexVec}; use rustc_macros::HashStable; @@ -43,7 +42,7 @@ use rustc_session::DataTypeKind; use rustc_span::hygiene::ExpnId; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::Span; -use rustc_target::abi::Align; +use rustc_target::abi::{Align, VariantIdx}; use std::cell::RefCell; use std::cmp::{self, Ordering}; @@ -2078,7 +2077,7 @@ pub struct AdtDef { /// The `DefId` of the struct, enum or union item. pub did: DefId, /// Variants of the ADT. If this is a struct or union, then there will be a single variant. - pub variants: IndexVec, + pub variants: IndexVec, /// Flags of the ADT (e.g., is this a struct? is this non-exhaustive?). flags: AdtFlags, /// Repr options provided by the user. diff --git a/src/librustc_middle/ty/print/pretty.rs b/src/librustc_middle/ty/print/pretty.rs index 5c365a57cd12d..a8b7b6a4b97a4 100644 --- a/src/librustc_middle/ty/print/pretty.rs +++ b/src/librustc_middle/ty/print/pretty.rs @@ -1,7 +1,7 @@ use crate::middle::cstore::{ExternCrate, ExternCrateSource}; use crate::middle::region; use crate::mir::interpret::{sign_extend, truncate, AllocId, ConstValue, Pointer, Scalar}; -use crate::ty::layout::{Integer, IntegerExt, Size}; +use crate::ty::layout::IntegerExt; use crate::ty::subst::{GenericArg, GenericArgKind, Subst}; use crate::ty::{self, DefIdTree, ParamConst, Ty, TyCtxt, TypeFoldable}; use rustc_apfloat::ieee::{Double, Single}; @@ -13,6 +13,7 @@ use rustc_hir::def::{DefKind, Namespace}; use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; use rustc_span::symbol::{kw, Symbol}; +use rustc_target::abi::{Integer, Size}; use rustc_target::spec::abi::Abi; use std::cell::Cell; diff --git a/src/librustc_middle/ty/query/mod.rs b/src/librustc_middle/ty/query/mod.rs index 744237520fbfd..9986eb88dc326 100644 --- a/src/librustc_middle/ty/query/mod.rs +++ b/src/librustc_middle/ty/query/mod.rs @@ -7,7 +7,6 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrs; use crate::middle::cstore::{CrateSource, DepKind, NativeLibraryKind}; use crate::middle::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLibrary}; use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel}; -use crate::middle::lang_items::{LangItem, LanguageItems}; use crate::middle::lib_features::LibFeatures; use crate::middle::privacy::AccessLevels; use crate::middle::region; @@ -34,16 +33,17 @@ use crate::ty::steal::Steal; use crate::ty::subst::{GenericArg, SubstsRef}; use crate::ty::util::AlwaysRequiresDrop; use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt}; -use crate::util::common::ErrorReported; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_data_structures::profiling::ProfileCategory::*; use rustc_data_structures::stable_hasher::StableVec; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::Lrc; +use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId}; +use rustc_hir::lang_items::{LangItem, LanguageItems}; use rustc_hir::{Crate, HirIdSet, ItemLocalId, TraitCandidate}; use rustc_index::vec::IndexVec; use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion}; diff --git a/src/librustc_middle/ty/structural_impls.rs b/src/librustc_middle/ty/structural_impls.rs index 429791d09a49c..0ac4466d34f5c 100644 --- a/src/librustc_middle/ty/structural_impls.rs +++ b/src/librustc_middle/ty/structural_impls.rs @@ -254,7 +254,7 @@ CloneTypeFoldableAndLiftImpls! { (), bool, usize, - crate::ty::layout::VariantIdx, + ::rustc_target::abi::VariantIdx, u64, String, crate::middle::region::Scope, diff --git a/src/librustc_middle/ty/sty.rs b/src/librustc_middle/ty/sty.rs index 57df50dc1a05d..99e3b88f5052c 100644 --- a/src/librustc_middle/ty/sty.rs +++ b/src/librustc_middle/ty/sty.rs @@ -10,7 +10,6 @@ use crate::middle::region; use crate::mir::interpret::ConstValue; use crate::mir::interpret::{LitToConstInput, Scalar}; use crate::mir::Promoted; -use crate::ty::layout::VariantIdx; use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef}; use crate::ty::{ self, AdtDef, DefIdTree, Discr, Ty, TyCtxt, TypeFlags, TypeFoldable, WithConstness, @@ -24,6 +23,7 @@ use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_index::vec::Idx; use rustc_macros::HashStable; use rustc_span::symbol::{kw, Symbol}; +use rustc_target::abi::{Size, VariantIdx}; use rustc_target::spec::abi; use smallvec::SmallVec; use std::borrow::Cow; @@ -2501,7 +2501,7 @@ impl<'tcx> ConstKind<'tcx> { } #[inline] - pub fn try_to_bits(&self, size: ty::layout::Size) -> Option { + pub fn try_to_bits(&self, size: Size) -> Option { if let ConstKind::Value(val) = self { val.try_to_bits(size) } else { None } } } diff --git a/src/librustc_middle/ty/util.rs b/src/librustc_middle/ty/util.rs index dab367a6639ed..86575b013335c 100644 --- a/src/librustc_middle/ty/util.rs +++ b/src/librustc_middle/ty/util.rs @@ -2,24 +2,24 @@ use crate::ich::NodeIdHashingMode; use crate::mir::interpret::{sign_extend, truncate}; -use crate::ty::layout::{Integer, IntegerExt, Size}; +use crate::ty::layout::IntegerExt; use crate::ty::query::TyCtxtAt; use crate::ty::subst::{GenericArgKind, InternalSubsts, Subst, SubstsRef}; use crate::ty::TyKind::*; use crate::ty::{self, DefIdTree, GenericParamDefKind, Ty, TyCtxt, TypeFoldable}; -use crate::util::common::ErrorReported; use rustc_apfloat::Float as _; use rustc_ast::ast; use rustc_attr::{self as attr, SignedInt, UnsignedInt}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; use rustc_hir::definitions::DefPathData; use rustc_macros::HashStable; use rustc_span::Span; -use rustc_target::abi::TargetDataLayout; +use rustc_target::abi::{Integer, Size, TargetDataLayout}; use smallvec::SmallVec; use std::{cmp, fmt}; diff --git a/src/librustc_middle/util/common.rs b/src/librustc_middle/util/common.rs index 19b43bfd16241..1e09702bf27ca 100644 --- a/src/librustc_middle/util/common.rs +++ b/src/librustc_middle/util/common.rs @@ -8,8 +8,6 @@ use std::time::{Duration, Instant}; #[cfg(test)] mod tests; -pub use rustc_errors::ErrorReported; - pub fn to_readable_str(mut val: usize) -> String { let mut groups = vec![]; loop { diff --git a/src/librustc_mir/borrow_check/diagnostics/mod.rs b/src/librustc_mir/borrow_check/diagnostics/mod.rs index 2991f29949aa0..619ae0ff8faa1 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mod.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mod.rs @@ -9,10 +9,10 @@ use rustc_middle::mir::{ AggregateKind, Constant, Field, Local, LocalInfo, LocalKind, Location, Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, }; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::print::Print; use rustc_middle::ty::{self, DefIdTree, Ty, TyCtxt}; use rustc_span::Span; +use rustc_target::abi::VariantIdx; use super::borrow_set::BorrowData; use super::MirBorrowckCtxt; diff --git a/src/librustc_mir/borrow_check/type_check/mod.rs b/src/librustc_mir/borrow_check/type_check/mod.rs index 1d66bd13c6fe6..cedae94ab89fe 100644 --- a/src/librustc_mir/borrow_check/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/type_check/mod.rs @@ -24,13 +24,13 @@ use rustc_middle::mir::*; use rustc_middle::ty::adjustment::PointerCast; use rustc_middle::ty::cast::CastTy; use rustc_middle::ty::fold::TypeFoldable; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::subst::{GenericArgKind, Subst, SubstsRef, UserSubsts}; use rustc_middle::ty::{ self, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, RegionVid, ToPolyTraitRef, Ty, TyCtxt, UserType, UserTypeAnnotationIndex, }; use rustc_span::{Span, DUMMY_SP}; +use rustc_target::abi::VariantIdx; use rustc_trait_selection::infer::InferCtxtExt as _; use rustc_trait_selection::opaque_types::{GenerateMemberConstraints, InferCtxtExt}; use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _; diff --git a/src/librustc_mir/borrow_check/universal_regions.rs b/src/librustc_mir/borrow_check/universal_regions.rs index c31f5a57ebc22..4d67d7204ca6e 100644 --- a/src/librustc_mir/borrow_check/universal_regions.rs +++ b/src/librustc_mir/borrow_check/universal_regions.rs @@ -17,10 +17,10 @@ use rustc_data_structures::fx::FxHashMap; use rustc_errors::DiagnosticBuilder; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::lang_items; use rustc_hir::{BodyOwnerKind, HirId}; use rustc_index::vec::{Idx, IndexVec}; use rustc_infer::infer::{InferCtxt, NLLRegionVariableOrigin}; -use rustc_middle::middle::lang_items; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef}; use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt}; diff --git a/src/librustc_mir/const_eval/eval_queries.rs b/src/librustc_mir/const_eval/eval_queries.rs index af79198ef6415..97cdb32e2cdf7 100644 --- a/src/librustc_mir/const_eval/eval_queries.rs +++ b/src/librustc_mir/const_eval/eval_queries.rs @@ -9,8 +9,9 @@ use rustc_hir::def::DefKind; use rustc_middle::mir; use rustc_middle::mir::interpret::{ConstEvalErr, ErrorHandled}; use rustc_middle::traits::Reveal; -use rustc_middle::ty::{self, layout, layout::LayoutOf, subst::Subst, TyCtxt}; +use rustc_middle::ty::{self, subst::Subst, TyCtxt}; use rustc_span::source_map::Span; +use rustc_target::abi::{Abi, LayoutOf}; use std::convert::TryInto; pub fn note_on_undefined_behavior_error() -> &'static str { @@ -105,8 +106,8 @@ pub(super) fn op_to_const<'tcx>( // the usual cases of extracting e.g. a `usize`, without there being a real use case for the // `Undef` situation. let try_as_immediate = match op.layout.abi { - layout::Abi::Scalar(..) => true, - layout::Abi::ScalarPair(..) => match op.layout.ty.kind { + Abi::Scalar(..) => true, + Abi::ScalarPair(..) => match op.layout.ty.kind { ty::Ref(_, inner, _) => match inner.kind { ty::Slice(elem) => elem == ecx.tcx.types.u8, ty::Str => true, diff --git a/src/librustc_mir/const_eval/mod.rs b/src/librustc_mir/const_eval/mod.rs index 78d1e8989a2f5..e1146ef30d131 100644 --- a/src/librustc_mir/const_eval/mod.rs +++ b/src/librustc_mir/const_eval/mod.rs @@ -3,9 +3,9 @@ use std::convert::TryFrom; use rustc_middle::mir; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::{source_map::DUMMY_SP, symbol::Symbol}; +use rustc_target::abi::VariantIdx; use crate::interpret::{intern_const_alloc_recursive, ConstValue, InternKind, InterpCx}; diff --git a/src/librustc_mir/dataflow/framework/mod.rs b/src/librustc_mir/dataflow/framework/mod.rs index fd2a3d5ea28f2..06da8799dd468 100644 --- a/src/librustc_mir/dataflow/framework/mod.rs +++ b/src/librustc_mir/dataflow/framework/mod.rs @@ -36,8 +36,8 @@ use rustc_hir::def_id::DefId; use rustc_index::bit_set::{BitSet, HybridBitSet}; use rustc_index::vec::{Idx, IndexVec}; use rustc_middle::mir::{self, BasicBlock, Location}; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::{self, TyCtxt}; +use rustc_target::abi::VariantIdx; mod cursor; mod engine; diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index 1c85226b1221f..b5f1a2d4eb94b 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -5,8 +5,8 @@ use rustc_index::bit_set::BitSet; use rustc_index::vec::Idx; use rustc_middle::mir::{self, Body, Location}; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::{self, TyCtxt}; +use rustc_target::abi::VariantIdx; use super::MoveDataParamEnv; diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index 215c7bb747593..67696aa2da8b0 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -7,10 +7,10 @@ use rustc_ast::ast::FloatTy; use rustc_middle::mir::interpret::{InterpResult, PointerArithmetic, Scalar}; use rustc_middle::mir::CastKind; use rustc_middle::ty::adjustment::PointerCast; -use rustc_middle::ty::layout::{self, Size, TyAndLayout}; +use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{self, Ty, TypeAndMut, TypeFoldable}; use rustc_span::symbol::sym; -use rustc_target::abi::LayoutOf; +use rustc_target::abi::{LayoutOf, Size, Variants}; impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { pub fn cast( @@ -132,7 +132,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // Handle cast from a univariant (ZST) enum. match src.layout.variants { - layout::Variants::Single { index } => { + Variants::Single { index } => { if let Some(discr) = src.layout.ty.discriminant_for_variant(*self.tcx, index) { assert!(src.layout.is_zst()); let discr_layout = self.layout_of(discr.ty)?; @@ -141,7 +141,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { .into()); } } - layout::Variants::Multiple { .. } => {} + Variants::Multiple { .. } => {} } // Handle casting the metadata away from a fat pointer. diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 8f24fc451bc3f..9aa42e107dc84 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -13,11 +13,12 @@ use rustc_middle::mir; use rustc_middle::mir::interpret::{ sign_extend, truncate, AllocId, FrameInfo, GlobalId, InterpResult, Pointer, Scalar, }; -use rustc_middle::ty::layout::{self, Align, HasDataLayout, LayoutOf, Size, TyAndLayout}; +use rustc_middle::ty::layout::{self, TyAndLayout}; use rustc_middle::ty::query::TyCtxtAt; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc_span::source_map::DUMMY_SP; +use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Size, TargetDataLayout}; use super::{ Immediate, MPlaceTy, Machine, MemPlace, MemPlaceMeta, Memory, OpTy, Operand, Place, PlaceTy, @@ -173,7 +174,7 @@ impl<'mir, 'tcx, Tag, Extra> Frame<'mir, 'tcx, Tag, Extra> { impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout for InterpCx<'mir, 'tcx, M> { #[inline] - fn data_layout(&self) -> &layout::TargetDataLayout { + fn data_layout(&self) -> &TargetDataLayout { &self.tcx.data_layout } } diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index b60377fbcd69a..d976df82577ea 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -11,10 +11,10 @@ use rustc_middle::mir::{ BinOp, }; use rustc_middle::ty; -use rustc_middle::ty::layout::{LayoutOf, Primitive, Size}; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::TyCtxt; use rustc_span::symbol::{sym, Symbol}; +use rustc_target::abi::{Abi, LayoutOf as _, Primitive, Size}; use super::{ImmTy, InterpCx, Machine, OpTy, PlaceTy}; @@ -134,7 +134,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let val = self.read_scalar(args[0])?.not_undef()?; let bits = self.force_bits(val, layout_of.size)?; let kind = match layout_of.abi { - ty::layout::Abi::Scalar(ref scalar) => scalar.value, + Abi::Scalar(ref scalar) => scalar.value, _ => bug!("{} called on invalid type {:?}", intrinsic_name, ty), }; let (nonzero, intrinsic_name) = match intrinsic_name { diff --git a/src/librustc_mir/interpret/intrinsics/caller_location.rs b/src/librustc_mir/interpret/intrinsics/caller_location.rs index f7e264b01d16d..754f45d9ec05b 100644 --- a/src/librustc_mir/interpret/intrinsics/caller_location.rs +++ b/src/librustc_mir/interpret/intrinsics/caller_location.rs @@ -1,6 +1,6 @@ use std::convert::TryFrom; -use rustc_middle::middle::lang_items::PanicLocationLangItem; +use rustc_hir::lang_items::PanicLocationLangItem; use rustc_middle::ty::subst::Subst; use rustc_span::{Span, Symbol}; use rustc_target::abi::LayoutOf; diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 9443ae116fcfd..04a927c69a687 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -11,11 +11,10 @@ use std::collections::VecDeque; use std::convert::TryFrom; use std::ptr; +use rustc_ast::ast::Mutability; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_middle::ty::layout::{Align, HasDataLayout, Size, TargetDataLayout}; use rustc_middle::ty::{self, query::TyCtxtAt, Instance, ParamEnv}; - -use rustc_ast::ast::Mutability; +use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout}; use super::{ AllocId, AllocMap, Allocation, AllocationExtra, CheckInAllocMsg, ErrorHandled, GlobalAlloc, diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 7191198b6c0ee..999d0d26ab34a 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -10,12 +10,12 @@ pub use rustc_middle::mir::interpret::ScalarMaybeUndef; use rustc_middle::mir::interpret::{ sign_extend, truncate, AllocId, ConstValue, GlobalId, InterpResult, Pointer, Scalar, }; -use rustc_middle::ty::layout::{ - self, HasDataLayout, IntegerExt, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx, -}; +use rustc_middle::ty::layout::{IntegerExt, PrimitiveExt, TyAndLayout}; use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter, Printer}; use rustc_middle::ty::Ty; use rustc_middle::{mir, ty}; +use rustc_target::abi::{Abi, DiscriminantKind, HasDataLayout, Integer, LayoutOf, Size}; +use rustc_target::abi::{VariantIdx, Variants}; use std::fmt::Write; /// An `Immediate` represents a single immediate self-contained Rust value. @@ -266,7 +266,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { }; match mplace.layout.abi { - layout::Abi::Scalar(..) => { + Abi::Scalar(..) => { let scalar = self.memory.get_raw(ptr.alloc_id)?.read_scalar( self, ptr, @@ -274,7 +274,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { )?; Ok(Some(ImmTy { imm: scalar.into(), layout: mplace.layout })) } - layout::Abi::ScalarPair(ref a, ref b) => { + Abi::ScalarPair(ref a, ref b) => { // We checked `ptr_align` above, so all fields will have the alignment they need. // We would anyway check against `ptr_align.restrict_for_offset(b_offset)`, // which `ptr.offset(b_offset)` cannot possibly fail to satisfy. @@ -587,7 +587,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { trace!("read_discriminant_value {:#?}", rval.layout); let (discr_layout, discr_kind, discr_index) = match rval.layout.variants { - layout::Variants::Single { index } => { + Variants::Single { index } => { let discr_val = rval .layout .ty @@ -595,12 +595,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { .map_or(u128::from(index.as_u32()), |discr| discr.val); return Ok((discr_val, index)); } - layout::Variants::Multiple { - discr: ref discr_layout, - ref discr_kind, - discr_index, - .. - } => (discr_layout, discr_kind, discr_index), + Variants::Multiple { discr: ref discr_layout, ref discr_kind, discr_index, .. } => { + (discr_layout, discr_kind, discr_index) + } }; // read raw discriminant value @@ -610,7 +607,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { trace!("discr value: {:?}", raw_discr); // post-process Ok(match *discr_kind { - layout::DiscriminantKind::Tag => { + DiscriminantKind::Tag => { let bits_discr = raw_discr .not_undef() .and_then(|raw_discr| self.force_bits(raw_discr, discr_val.layout.size)) @@ -627,7 +624,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { .expect("tagged layout corresponds to adt") .repr .discr_type(); - let size = layout::Integer::from_attr(self, discr_ty).size(); + let size = Integer::from_attr(self, discr_ty).size(); truncate(sexted, size) } else { bits_discr @@ -648,11 +645,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { .ok_or_else(|| err_ub!(InvalidDiscriminant(raw_discr.erase_tag())))?; (real_discr, index.0) } - layout::DiscriminantKind::Niche { - dataful_variant, - ref niche_variants, - niche_start, - } => { + DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start } => { let variants_start = niche_variants.start().as_u32(); let variants_end = niche_variants.end().as_u32(); let raw_discr = raw_discr diff --git a/src/librustc_mir/interpret/operator.rs b/src/librustc_mir/interpret/operator.rs index e81cd8b3d00d7..0aa7e98f3edfa 100644 --- a/src/librustc_mir/interpret/operator.rs +++ b/src/librustc_mir/interpret/operator.rs @@ -4,11 +4,8 @@ use rustc_apfloat::Float; use rustc_ast::ast::FloatTy; use rustc_middle::mir; use rustc_middle::mir::interpret::{InterpResult, Scalar}; -use rustc_middle::ty::{ - self, - layout::{LayoutOf, TyAndLayout}, - Ty, -}; +use rustc_middle::ty::{self, layout::TyAndLayout, Ty}; +use rustc_target::abi::LayoutOf; use super::{ImmTy, Immediate, InterpCx, Machine, PlaceTy}; diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index a8e65a7e7f5a9..ece54daf4c61d 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -8,10 +8,10 @@ use std::hash::Hash; use rustc_macros::HashStable; use rustc_middle::mir; use rustc_middle::mir::interpret::truncate; -use rustc_middle::ty::layout::{ - self, Align, HasDataLayout, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx, -}; +use rustc_middle::ty::layout::{PrimitiveExt, TyAndLayout}; use rustc_middle::ty::{self, Ty}; +use rustc_target::abi::{Abi, Align, DiscriminantKind, FieldsShape}; +use rustc_target::abi::{HasDataLayout, LayoutOf, Size, VariantIdx, Variants}; use super::{ AllocId, AllocMap, Allocation, AllocationExtra, ImmTy, Immediate, InterpCx, InterpResult, @@ -219,7 +219,7 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> { // Go through the layout. There are lots of types that support a length, // e.g., SIMD types. match self.layout.fields { - layout::FieldsShape::Array { count, .. } => Ok(count), + FieldsShape::Array { count, .. } => Ok(count), _ => bug!("len not supported on sized type {:?}", self.layout.ty), } } @@ -437,7 +437,7 @@ where ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { // Not using the layout method because we want to compute on u64 match base.layout.fields { - layout::FieldsShape::Array { stride, .. } => { + FieldsShape::Array { stride, .. } => { let len = base.len(self)?; if index >= len { // This can only be reached in ConstProp and non-rustc-MIR. @@ -463,7 +463,7 @@ where { let len = base.len(self)?; // also asserts that we have a type where this makes sense let stride = match base.layout.fields { - layout::FieldsShape::Array { stride, .. } => stride, + FieldsShape::Array { stride, .. } => stride, _ => bug!("mplace_array_fields: expected an array layout"), }; let layout = base.layout.field(self, 0)?; @@ -493,7 +493,7 @@ where // Not using layout method because that works with usize, and does not work with slices // (that have count 0 in their layout). let from_offset = match base.layout.fields { - layout::FieldsShape::Array { stride, .. } => stride * from, // `Size` multiplication is checked + FieldsShape::Array { stride, .. } => stride * from, // `Size` multiplication is checked _ => bug!("Unexpected layout of index access: {:#?}", base.layout), }; @@ -802,7 +802,7 @@ where match value { Immediate::Scalar(scalar) => { match dest.layout.abi { - layout::Abi::Scalar(_) => {} // fine + Abi::Scalar(_) => {} // fine _ => { bug!("write_immediate_to_mplace: invalid Scalar layout: {:#?}", dest.layout) } @@ -819,7 +819,7 @@ where // We would anyway check against `ptr_align.restrict_for_offset(b_offset)`, // which `ptr.offset(b_offset)` cannot possibly fail to satisfy. let (a, b) = match dest.layout.abi { - layout::Abi::ScalarPair(ref a, ref b) => (&a.value, &b.value), + Abi::ScalarPair(ref a, ref b) => (&a.value, &b.value), _ => bug!( "write_immediate_to_mplace: invalid ScalarPair layout: {:#?}", dest.layout @@ -1067,11 +1067,11 @@ where } match dest.layout.variants { - layout::Variants::Single { index } => { + Variants::Single { index } => { assert_eq!(index, variant_index); } - layout::Variants::Multiple { - discr_kind: layout::DiscriminantKind::Tag, + Variants::Multiple { + discr_kind: DiscriminantKind::Tag, discr: ref discr_layout, discr_index, .. @@ -1091,9 +1091,9 @@ where let discr_dest = self.place_field(dest, discr_index)?; self.write_scalar(Scalar::from_uint(discr_val, size), discr_dest)?; } - layout::Variants::Multiple { + Variants::Multiple { discr_kind: - layout::DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start }, + DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start }, discr: ref discr_layout, discr_index, .. diff --git a/src/librustc_mir/interpret/step.rs b/src/librustc_mir/interpret/step.rs index 961b0f4d189f8..407849c2ce27c 100644 --- a/src/librustc_mir/interpret/step.rs +++ b/src/librustc_mir/interpret/step.rs @@ -4,7 +4,7 @@ use rustc_middle::mir; use rustc_middle::mir::interpret::{InterpResult, Scalar}; -use rustc_middle::ty::layout::LayoutOf; +use rustc_target::abi::LayoutOf; use super::{InterpCx, Machine}; diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index 6ca6f50b0ee7c..8ad743d2b8b1d 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -1,9 +1,10 @@ use std::borrow::Cow; use std::convert::TryFrom; -use rustc_middle::ty::layout::{self, LayoutOf, TyAndLayout}; +use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::Instance; use rustc_middle::{mir, ty}; +use rustc_target::abi::{self, LayoutOf as _}; use rustc_target::spec::abi::Abi; use super::{ @@ -142,12 +143,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // Different valid ranges are okay (once we enforce validity, // that will take care to make it UB to leave the range, just // like for transmute). - (layout::Abi::Scalar(ref caller), layout::Abi::Scalar(ref callee)) => { + (abi::Abi::Scalar(ref caller), abi::Abi::Scalar(ref callee)) => { caller.value == callee.value } ( - layout::Abi::ScalarPair(ref caller1, ref caller2), - layout::Abi::ScalarPair(ref callee1, ref callee2), + abi::Abi::ScalarPair(ref caller1, ref caller2), + abi::Abi::ScalarPair(ref callee1, ref callee2), ) => caller1.value == callee1.value && caller2.value == callee2.value, // Be conservative _ => false, diff --git a/src/librustc_mir/interpret/traits.rs b/src/librustc_mir/interpret/traits.rs index ed882e107411d..fb9401c7d8f28 100644 --- a/src/librustc_mir/interpret/traits.rs +++ b/src/librustc_mir/interpret/traits.rs @@ -1,8 +1,8 @@ use std::convert::TryFrom; use rustc_middle::mir::interpret::{InterpResult, Pointer, PointerArithmetic, Scalar}; -use rustc_middle::ty::layout::{Align, HasDataLayout, LayoutOf, Size}; use rustc_middle::ty::{self, Instance, Ty, TypeFoldable}; +use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Size}; use super::{FnVal, InterpCx, Machine, MemoryKind}; diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 0ca565d86787a..701e394415bbd 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -11,8 +11,9 @@ use std::ops::RangeInclusive; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_middle::ty; -use rustc_middle::ty::layout::{self, LayoutOf, TyAndLayout, VariantIdx}; +use rustc_middle::ty::layout::TyAndLayout; use rustc_span::symbol::{sym, Symbol}; +use rustc_target::abi::{Abi, LayoutOf, Scalar, VariantIdx, Variants}; use std::hash::Hash; @@ -180,7 +181,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M fn aggregate_field_path_elem(&mut self, layout: TyAndLayout<'tcx>, field: usize) -> PathElem { // First, check if we are projecting to a variant. match layout.variants { - layout::Variants::Multiple { discr_index, .. } => { + Variants::Multiple { discr_index, .. } => { if discr_index == field { return match layout.ty.kind { ty::Adt(def, ..) if def.is_enum() => PathElem::EnumTag, @@ -189,7 +190,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M }; } } - layout::Variants::Single { .. } => {} + Variants::Single { .. } => {} } // Now we know we are projecting to a field, so figure out which one. @@ -226,11 +227,11 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M ty::Adt(def, ..) if def.is_enum() => { // we might be projecting *to* a variant, or to a field *in* a variant. match layout.variants { - layout::Variants::Single { index } => { + Variants::Single { index } => { // Inside a variant PathElem::Field(def.variants[index].fields[field].ident.name) } - layout::Variants::Multiple { .. } => bug!("we handled variants above"), + Variants::Multiple { .. } => bug!("we handled variants above"), } } @@ -539,7 +540,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M fn visit_scalar( &mut self, op: OpTy<'tcx, M::PointerTag>, - scalar_layout: &layout::Scalar, + scalar_layout: &Scalar, ) -> InterpResult<'tcx> { let value = self.ecx.read_scalar(op)?; let valid_range = &scalar_layout.valid_range; @@ -685,22 +686,22 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M> // scalars, we do the same check on every "level" (e.g., first we check // MyNewtype and then the scalar in there). match op.layout.abi { - layout::Abi::Uninhabited => { + Abi::Uninhabited => { throw_validation_failure!( format_args!("a value of uninhabited type {:?}", op.layout.ty), self.path ); } - layout::Abi::Scalar(ref scalar_layout) => { + Abi::Scalar(ref scalar_layout) => { self.visit_scalar(op, scalar_layout)?; } - layout::Abi::ScalarPair { .. } | layout::Abi::Vector { .. } => { + Abi::ScalarPair { .. } | Abi::Vector { .. } => { // These have fields that we already visited above, so we already checked // all their scalar-level restrictions. // There is also no equivalent to `rustc_layout_scalar_valid_range_start` // that would make skipping them here an issue. } - layout::Abi::Aggregate { .. } => { + Abi::Aggregate { .. } => { // Nothing to do. } } diff --git a/src/librustc_mir/interpret/visitor.rs b/src/librustc_mir/interpret/visitor.rs index 66a46c12c062f..e03984f4d0be5 100644 --- a/src/librustc_mir/interpret/visitor.rs +++ b/src/librustc_mir/interpret/visitor.rs @@ -3,7 +3,8 @@ use rustc_middle::mir::interpret::InterpResult; use rustc_middle::ty; -use rustc_middle::ty::layout::{self, TyAndLayout, VariantIdx}; +use rustc_middle::ty::layout::TyAndLayout; +use rustc_target::abi::{FieldsShape, VariantIdx, Variants}; use super::{InterpCx, MPlaceTy, Machine, OpTy}; @@ -207,10 +208,10 @@ macro_rules! make_value_visitor { // Visit the fields of this value. match v.layout().fields { - layout::FieldsShape::Union(fields) => { + FieldsShape::Union(fields) => { self.visit_union(v, fields)?; }, - layout::FieldsShape::Arbitrary { ref offsets, .. } => { + FieldsShape::Arbitrary { ref offsets, .. } => { // FIXME: We collect in a vec because otherwise there are lifetime // errors: Projecting to a field needs access to `ecx`. let fields: Vec> = @@ -220,7 +221,7 @@ macro_rules! make_value_visitor { .collect(); self.visit_aggregate(v, fields.into_iter())?; }, - layout::FieldsShape::Array { .. } => { + FieldsShape::Array { .. } => { // Let's get an mplace first. let mplace = v.to_op(self.ecx())?.assert_mem_place(self.ecx()); // Now we can go over all the fields. @@ -237,7 +238,7 @@ macro_rules! make_value_visitor { match v.layout().variants { // If this is a multi-variant layout, find the right variant and proceed // with *its* fields. - layout::Variants::Multiple { .. } => { + Variants::Multiple { .. } => { let op = v.to_op(self.ecx())?; let idx = self.ecx().read_discriminant(op)?.1; let inner = v.project_downcast(self.ecx(), idx)?; @@ -246,7 +247,7 @@ macro_rules! make_value_visitor { self.visit_variant(v, idx, inner) } // For single-variant layouts, we already did anything there is to do. - layout::Variants::Single { .. } => Ok(()) + Variants::Single { .. } => Ok(()) } } } diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 1106eba104682..1032ff413af41 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -181,9 +181,9 @@ use rustc_data_structures::sync::{par_iter, MTLock, MTRef, ParallelIterator}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, DefIdMap, LOCAL_CRATE}; use rustc_hir::itemlikevisit::ItemLikeVisitor; +use rustc_hir::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem}; use rustc_index::bit_set::GrowableBitSet; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; -use rustc_middle::middle::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem}; use rustc_middle::mir::interpret::{AllocId, ConstValue}; use rustc_middle::mir::interpret::{ErrorHandled, GlobalAlloc, Scalar}; use rustc_middle::mir::mono::{InstantiationMode, MonoItem}; diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 0a998bbfe7068..67de81ed77baa 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -1,10 +1,10 @@ use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_middle::mir::*; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::query::Providers; use rustc_middle::ty::subst::{InternalSubsts, Subst}; use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; +use rustc_target::abi::VariantIdx; use rustc_index::vec::{Idx, IndexVec}; diff --git a/src/librustc_mir/transform/check_consts/validation.rs b/src/librustc_mir/transform/check_consts/validation.rs index 649cc0a79d636..e4a0b9cdb48b1 100644 --- a/src/librustc_mir/transform/check_consts/validation.rs +++ b/src/librustc_mir/transform/check_consts/validation.rs @@ -1,10 +1,10 @@ //! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations. use rustc_errors::struct_span_err; +use rustc_hir::lang_items; use rustc_hir::{def_id::DefId, HirId}; use rustc_index::bit_set::BitSet; use rustc_infer::infer::TyCtxtInferExt; -use rustc_middle::middle::lang_items; use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor}; use rustc_middle::mir::*; use rustc_middle::ty::cast::CastTy; diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index f4cba875620eb..c7f63d24c28ab 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -19,13 +19,12 @@ use rustc_middle::mir::{ SourceInfo, SourceScope, SourceScopeData, Statement, StatementKind, Terminator, TerminatorKind, UnOp, RETURN_PLACE, }; -use rustc_middle::ty::layout::{ - HasDataLayout, HasTyCtxt, LayoutError, LayoutOf, Size, TargetDataLayout, TyAndLayout, -}; +use rustc_middle::ty::layout::{HasTyCtxt, LayoutError, TyAndLayout}; use rustc_middle::ty::subst::{InternalSubsts, Subst}; use rustc_middle::ty::{self, ConstKind, Instance, ParamEnv, Ty, TyCtxt, TypeFoldable}; use rustc_session::lint; use rustc_span::{def_id::DefId, Span}; +use rustc_target::abi::{HasDataLayout, LayoutOf, Size, TargetDataLayout}; use rustc_trait_selection::traits; use crate::const_eval::error_to_const_error; diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index d3971c9a45cae..a7c6b5a98bbc1 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -13,9 +13,9 @@ use rustc_data_structures::fx::FxHashMap; use rustc_hir as hir; use rustc_index::bit_set::BitSet; use rustc_middle::mir::*; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::Span; +use rustc_target::abi::VariantIdx; use std::fmt; pub struct ElaborateDrops; diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 390d927a85471..53eec1f6dc3de 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -63,10 +63,10 @@ use rustc_index::bit_set::{BitMatrix, BitSet}; use rustc_index::vec::{Idx, IndexVec}; use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor}; use rustc_middle::mir::*; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::GeneratorSubsts; use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt}; +use rustc_target::abi::VariantIdx; use std::borrow::Cow; use std::iter; diff --git a/src/librustc_mir/transform/uninhabited_enum_branching.rs b/src/librustc_mir/transform/uninhabited_enum_branching.rs index 38a9194e5c55d..0a08c13b479aa 100644 --- a/src/librustc_mir/transform/uninhabited_enum_branching.rs +++ b/src/librustc_mir/transform/uninhabited_enum_branching.rs @@ -5,8 +5,9 @@ use rustc_middle::mir::{ BasicBlock, BasicBlockData, Body, BodyAndCache, Local, Operand, Rvalue, StatementKind, TerminatorKind, }; -use rustc_middle::ty::layout::{Abi, TyAndLayout, Variants}; +use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{Ty, TyCtxt}; +use rustc_target::abi::{Abi, Variants}; pub struct UninhabitedEnumBranching; diff --git a/src/librustc_mir/util/aggregate.rs b/src/librustc_mir/util/aggregate.rs index b22dbf40b5019..e77d264b7ce5c 100644 --- a/src/librustc_mir/util/aggregate.rs +++ b/src/librustc_mir/util/aggregate.rs @@ -1,7 +1,7 @@ use rustc_index::vec::Idx; use rustc_middle::mir::*; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::{Ty, TyCtxt}; +use rustc_target::abi::VariantIdx; use std::iter::TrustedLen; diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index f6d67abcef041..e3a96ca78967e 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -1,13 +1,13 @@ use crate::util::patch::MirPatch; use rustc_hir as hir; +use rustc_hir::lang_items; use rustc_index::vec::Idx; -use rustc_middle::middle::lang_items; use rustc_middle::mir::*; use rustc_middle::traits::Reveal; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::util::IntTypeExt; use rustc_middle::ty::{self, Ty, TyCtxt}; +use rustc_target::abi::VariantIdx; use std::fmt; use std::convert::TryInto; diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index df7df6a0809b5..a81fcb54580c2 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -9,7 +9,8 @@ use rustc_middle::mir::interpret::{ }; use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::*; -use rustc_middle::ty::{self, layout::Size, TyCtxt, TypeFoldable, TypeVisitor}; +use rustc_middle::ty::{self, TyCtxt, TypeFoldable, TypeVisitor}; +use rustc_target::abi::Size; use std::collections::BTreeSet; use std::fmt::Display; use std::fmt::Write as _; diff --git a/src/librustc_mir_build/build/matches/mod.rs b/src/librustc_mir_build/build/matches/mod.rs index a98b18c0cf1d8..a4a9271669e4e 100644 --- a/src/librustc_mir_build/build/matches/mod.rs +++ b/src/librustc_mir_build/build/matches/mod.rs @@ -16,9 +16,9 @@ use rustc_hir::HirId; use rustc_index::bit_set::BitSet; use rustc_middle::middle::region; use rustc_middle::mir::*; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty}; use rustc_span::Span; +use rustc_target::abi::VariantIdx; use smallvec::{smallvec, SmallVec}; // helper functions, broken out by category: diff --git a/src/librustc_mir_build/build/matches/simplify.rs b/src/librustc_mir_build/build/matches/simplify.rs index 664f56ae5e456..d74d8b5c7f318 100644 --- a/src/librustc_mir_build/build/matches/simplify.rs +++ b/src/librustc_mir_build/build/matches/simplify.rs @@ -15,12 +15,13 @@ use crate::build::matches::{Ascription, Binding, Candidate, MatchPair}; use crate::build::Builder; use crate::hair::{self, *}; +use rustc_attr::{SignedInt, UnsignedInt}; +use rustc_hir::RangeEnd; use rustc_middle::mir::interpret::truncate; use rustc_middle::mir::Place; use rustc_middle::ty; -use rustc_middle::ty::layout::{Integer, IntegerExt, Size}; -use rustc_attr::{SignedInt, UnsignedInt}; -use rustc_hir::RangeEnd; +use rustc_middle::ty::layout::IntegerExt; +use rustc_target::abi::{Integer, Size}; use std::mem; diff --git a/src/librustc_mir_build/build/matches/test.rs b/src/librustc_mir_build/build/matches/test.rs index 450bb0a861d74..c049842d061bf 100644 --- a/src/librustc_mir_build/build/matches/test.rs +++ b/src/librustc_mir_build/build/matches/test.rs @@ -9,14 +9,14 @@ use crate::build::matches::{Candidate, MatchPair, Test, TestKind}; use crate::build::Builder; use crate::hair::pattern::compare_const_vals; use crate::hair::*; -use rustc_middle::mir::*; -use rustc_middle::ty::layout::VariantIdx; -use rustc_middle::ty::util::IntTypeExt; -use rustc_middle::ty::{self, adjustment::PointerCast, Ty}; use rustc_data_structures::fx::FxHashMap; use rustc_hir::RangeEnd; use rustc_index::bit_set::BitSet; +use rustc_middle::mir::*; +use rustc_middle::ty::util::IntTypeExt; +use rustc_middle::ty::{self, adjustment::PointerCast, Ty}; use rustc_span::symbol::sym; +use rustc_target::abi::VariantIdx; use std::cmp::Ordering; @@ -362,7 +362,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { place: Place<'tcx>, mut ty: Ty<'tcx>, ) { - use rustc_middle::middle::lang_items::EqTraitLangItem; + use rustc_hir::lang_items::EqTraitLangItem; let mut expect = self.literal_operand(source_info.span, value); let mut val = Operand::Copy(place); diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index cec7e5bc19966..2439570202053 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -2,17 +2,17 @@ use crate::build; use crate::build::scope::DropKind; use crate::hair::cx::Cx; use crate::hair::{BindingMode, LintLevel, PatKind}; -use rustc_middle::middle::lang_items; -use rustc_middle::middle::region; -use rustc_middle::mir::*; -use rustc_middle::ty::subst::Subst; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc_attr::{self as attr, UnwindAttr}; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::lang_items; use rustc_hir::{GeneratorKind, HirIdMap, Node}; use rustc_index::vec::{Idx, IndexVec}; use rustc_infer::infer::TyCtxtInferExt; +use rustc_middle::middle::region; +use rustc_middle::mir::*; +use rustc_middle::ty::subst::Subst; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc_span::symbol::kw; use rustc_span::Span; use rustc_target::spec::abi::Abi; diff --git a/src/librustc_mir_build/hair/constant.rs b/src/librustc_mir_build/hair/constant.rs index 667f29337c2b6..e5af0b5bd6bed 100644 --- a/src/librustc_mir_build/hair/constant.rs +++ b/src/librustc_mir_build/hair/constant.rs @@ -2,8 +2,9 @@ use rustc_ast::ast; use rustc_middle::mir::interpret::{ truncate, Allocation, ConstValue, LitToConstError, LitToConstInput, Scalar, }; -use rustc_middle::ty::{self, layout::Size, ParamEnv, TyCtxt, TyS}; +use rustc_middle::ty::{self, ParamEnv, TyCtxt, TyS}; use rustc_span::symbol::Symbol; +use rustc_target::abi::Size; crate fn lit_to_const<'tcx>( tcx: TyCtxt<'tcx>, diff --git a/src/librustc_mir_build/hair/cx/mod.rs b/src/librustc_mir_build/hair/cx/mod.rs index 13a476775db02..503bd26d51fcc 100644 --- a/src/librustc_mir_build/hair/cx/mod.rs +++ b/src/librustc_mir_build/hair/cx/mod.rs @@ -14,11 +14,11 @@ use rustc_index::vec::Idx; use rustc_infer::infer::InferCtxt; use rustc_middle::middle::region; use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput}; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::subst::Subst; use rustc_middle::ty::subst::{GenericArg, InternalSubsts}; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::symbol::{sym, Symbol}; +use rustc_target::abi::VariantIdx; use rustc_trait_selection::infer::InferCtxtExt; #[derive(Clone)] diff --git a/src/librustc_mir_build/hair/mod.rs b/src/librustc_mir_build/hair/mod.rs index fadfc7660d4f9..601e4412512ab 100644 --- a/src/librustc_mir_build/hair/mod.rs +++ b/src/librustc_mir_build/hair/mod.rs @@ -11,10 +11,10 @@ use rustc_middle::infer::canonical::Canonical; use rustc_middle::middle::region; use rustc_middle::mir::{BinOp, BorrowKind, Field, UnOp}; use rustc_middle::ty::adjustment::PointerCast; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{AdtDef, Const, Ty, UpvarSubsts, UserType}; use rustc_span::Span; +use rustc_target::abi::VariantIdx; crate mod constant; crate mod cx; diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/hair/pattern/_match.rs index 03f668d562e78..8c0843124f4f1 100644 --- a/src/librustc_mir_build/hair/pattern/_match.rs +++ b/src/librustc_mir_build/hair/pattern/_match.rs @@ -236,15 +236,16 @@ use super::{compare_const_vals, PatternFoldable, PatternFolder}; use super::{FieldPat, Pat, PatKind, PatRange}; use rustc_attr::{SignedInt, UnsignedInt}; +use rustc_errors::ErrorReported; use rustc_hir::def_id::DefId; use rustc_hir::{HirId, RangeEnd}; use rustc_middle::mir::interpret::{truncate, AllocId, ConstValue, Pointer, Scalar}; use rustc_middle::mir::Field; -use rustc_middle::ty::layout::{Integer, IntegerExt, Size, VariantIdx}; +use rustc_middle::ty::layout::IntegerExt; use rustc_middle::ty::{self, Const, Ty, TyCtxt, TypeFoldable, VariantDef}; -use rustc_middle::util::common::ErrorReported; use rustc_session::lint; use rustc_span::{Span, DUMMY_SP}; +use rustc_target::abi::{Integer, Size, VariantIdx}; use arena::TypedArena; diff --git a/src/librustc_mir_build/hair/pattern/mod.rs b/src/librustc_mir_build/hair/pattern/mod.rs index f15d2fc5caa03..2b6d8e920f5ed 100644 --- a/src/librustc_mir_build/hair/pattern/mod.rs +++ b/src/librustc_mir_build/hair/pattern/mod.rs @@ -19,13 +19,13 @@ use rustc_middle::mir::interpret::{get_slice_bytes, sign_extend, ConstValue, Err use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput}; use rustc_middle::mir::UserTypeProjection; use rustc_middle::mir::{BorrowKind, Field, Mutability}; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::subst::{GenericArg, SubstsRef}; use rustc_middle::ty::{self, AdtDef, DefIdTree, Region, Ty, TyCtxt, UserType}; use rustc_middle::ty::{ CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, }; use rustc_span::{Span, DUMMY_SP}; +use rustc_target::abi::VariantIdx; use std::cmp::Ordering; use std::fmt; @@ -1047,8 +1047,8 @@ crate fn compare_const_vals<'tcx>( } ty::Int(ity) => { use rustc_attr::SignedInt; - use rustc_middle::ty::layout::{Integer, IntegerExt}; - let size = Integer::from_attr(&tcx, SignedInt(ity)).size(); + use rustc_middle::ty::layout::IntegerExt; + let size = rustc_target::abi::Integer::from_attr(&tcx, SignedInt(ity)).size(); let a = sign_extend(a, size); let b = sign_extend(b, size); Some((a as i128).cmp(&(b as i128))) diff --git a/src/librustc_passes/intrinsicck.rs b/src/librustc_passes/intrinsicck.rs index 11096c693e630..cc1af630cdd3c 100644 --- a/src/librustc_passes/intrinsicck.rs +++ b/src/librustc_passes/intrinsicck.rs @@ -4,10 +4,11 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_index::vec::Idx; -use rustc_middle::ty::layout::{LayoutError, Pointer, SizeSkeleton, VariantIdx}; +use rustc_middle::ty::layout::{LayoutError, SizeSkeleton}; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::{sym, Span}; +use rustc_target::abi::{Pointer, VariantIdx}; use rustc_target::spec::abi::Abi::RustIntrinsic; fn check_mod_intrinsics(tcx: TyCtxt<'_>, module_def_id: DefId) { diff --git a/src/librustc_passes/layout_test.rs b/src/librustc_passes/layout_test.rs index 9fa3225851ba1..da8ab727ed3aa 100644 --- a/src/librustc_passes/layout_test.rs +++ b/src/librustc_passes/layout_test.rs @@ -3,16 +3,10 @@ use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_hir::ItemKind; -use rustc_middle::ty::layout::HasDataLayout; -use rustc_middle::ty::layout::HasParamEnv; -use rustc_middle::ty::layout::HasTyCtxt; -use rustc_middle::ty::layout::LayoutOf; -use rustc_middle::ty::layout::TargetDataLayout; -use rustc_middle::ty::layout::TyAndLayout; -use rustc_middle::ty::ParamEnv; -use rustc_middle::ty::Ty; -use rustc_middle::ty::TyCtxt; +use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt, TyAndLayout}; +use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; use rustc_span::symbol::sym; +use rustc_target::abi::{HasDataLayout, LayoutOf, TargetDataLayout}; pub fn test_layout(tcx: TyCtxt<'_>) { if tcx.features().rustc_attrs { diff --git a/src/librustc_passes/weak_lang_items.rs b/src/librustc_passes/weak_lang_items.rs index 8d11af15b56ff..8e56ef0da5237 100644 --- a/src/librustc_passes/weak_lang_items.rs +++ b/src/librustc_passes/weak_lang_items.rs @@ -4,8 +4,8 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::struct_span_err; use rustc_hir as hir; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc_hir::lang_items; use rustc_hir::weak_lang_items::WEAK_ITEMS_REFS; -use rustc_middle::middle::lang_items; use rustc_middle::middle::lang_items::whitelisted; use rustc_middle::ty::TyCtxt; use rustc_session::config; diff --git a/src/librustc_trait_selection/infer.rs b/src/librustc_trait_selection/infer.rs index d7a2e720a6d0b..24eb22fbd00b1 100644 --- a/src/librustc_trait_selection/infer.rs +++ b/src/librustc_trait_selection/infer.rs @@ -2,11 +2,11 @@ use crate::traits::query::outlives_bounds::InferCtxtExt as _; use crate::traits::{self, TraitEngine, TraitEngineExt}; use rustc_hir as hir; +use rustc_hir::lang_items; use rustc_infer::infer::outlives::env::OutlivesEnvironment; use rustc_infer::traits::ObligationCause; use rustc_middle::arena::ArenaAllocatable; use rustc_middle::infer::canonical::{Canonical, CanonicalizedQueryResponse, QueryResponse}; -use rustc_middle::middle::lang_items; use rustc_middle::traits::query::Fallible; use rustc_middle::ty::{self, Ty, TypeFoldable}; use rustc_span::{Span, DUMMY_SP}; diff --git a/src/librustc_trait_selection/traits/mod.rs b/src/librustc_trait_selection/traits/mod.rs index 5f98850633075..9a853c32eaa26 100644 --- a/src/librustc_trait_selection/traits/mod.rs +++ b/src/librustc_trait_selection/traits/mod.rs @@ -24,13 +24,13 @@ use crate::infer::outlives::env::OutlivesEnvironment; use crate::infer::{InferCtxt, RegionckMode, TyCtxtInferExt}; use crate::traits::error_reporting::InferCtxtExt as _; use crate::traits::query::evaluate_obligation::InferCtxtExt as _; +use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_middle::middle::region; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::subst::{InternalSubsts, SubstsRef}; use rustc_middle::ty::{self, GenericParamDefKind, ToPredicate, Ty, TyCtxt, WithConstness}; -use rustc_middle::util::common::ErrorReported; use rustc_span::{Span, DUMMY_SP}; use std::fmt::Debug; diff --git a/src/librustc_trait_selection/traits/object_safety.rs b/src/librustc_trait_selection/traits/object_safety.rs index 3877c7f8a8c8e..20b3fa908d201 100644 --- a/src/librustc_trait_selection/traits/object_safety.rs +++ b/src/librustc_trait_selection/traits/object_safety.rs @@ -420,7 +420,7 @@ fn virtual_call_violation_for_method<'tcx>( } else { // Do sanity check to make sure the receiver actually has the layout of a pointer. - use rustc_middle::ty::layout::Abi; + use rustc_target::abi::Abi; let param_env = tcx.param_env(method.def_id); diff --git a/src/librustc_trait_selection/traits/on_unimplemented.rs b/src/librustc_trait_selection/traits/on_unimplemented.rs index 23c3bd46d2d80..cf29c4249c019 100644 --- a/src/librustc_trait_selection/traits/on_unimplemented.rs +++ b/src/librustc_trait_selection/traits/on_unimplemented.rs @@ -1,13 +1,11 @@ use fmt_macros::{Parser, Piece, Position}; -use rustc_middle::ty::{self, GenericParamDefKind, TyCtxt}; -use rustc_middle::util::common::ErrorReported; - use rustc_ast::ast::{MetaItem, NestedMetaItem}; use rustc_attr as attr; use rustc_data_structures::fx::FxHashMap; -use rustc_errors::struct_span_err; +use rustc_errors::{struct_span_err, ErrorReported}; use rustc_hir::def_id::DefId; +use rustc_middle::ty::{self, GenericParamDefKind, TyCtxt}; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::Span; diff --git a/src/librustc_trait_selection/traits/select.rs b/src/librustc_trait_selection/traits/select.rs index 1e5a1edd4d8ee..3d95824cdf00e 100644 --- a/src/librustc_trait_selection/traits/select.rs +++ b/src/librustc_trait_selection/traits/select.rs @@ -39,9 +39,9 @@ use rustc_ast::attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::lang_items; use rustc_index::bit_set::GrowableBitSet; use rustc_middle::dep_graph::{DepKind, DepNodeIndex}; -use rustc_middle::middle::lang_items; use rustc_middle::ty::fast_reject; use rustc_middle::ty::relate::TypeRelation; use rustc_middle::ty::subst::{Subst, SubstsRef}; diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs index 59b56d673fb00..1eb41e0b4d1ae 100644 --- a/src/librustc_trait_selection/traits/wf.rs +++ b/src/librustc_trait_selection/traits/wf.rs @@ -3,7 +3,7 @@ use crate::opaque_types::required_region_bounds; use crate::traits::{self, AssocTypeBoundData}; use rustc_hir as hir; use rustc_hir::def_id::DefId; -use rustc_middle::middle::lang_items; +use rustc_hir::lang_items; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness}; use rustc_span::symbol::{kw, Ident}; diff --git a/src/librustc_ty/common_traits.rs b/src/librustc_ty/common_traits.rs index 597bc8546045d..265b811571afe 100644 --- a/src/librustc_ty/common_traits.rs +++ b/src/librustc_ty/common_traits.rs @@ -1,7 +1,7 @@ //! Queries for checking whether a type implements one of a few common traits. +use rustc_hir::lang_items; use rustc_infer::infer::TyCtxtInferExt; -use rustc_middle::middle::lang_items; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::DUMMY_SP; use rustc_trait_selection::traits; diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 932032bb2b45f..c3ebcbfc832d1 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -6,18 +6,18 @@ // ignore-tidy-filelength use crate::collect::PlaceholderHirTyCollector; -use crate::middle::lang_items::SizedTraitLangItem; use crate::middle::resolve_lifetime as rl; use crate::require_c_abi_if_c_variadic; -use crate::util::common::ErrorReported; use rustc_ast::ast; use rustc_ast::util::lev_distance::find_best_match_for_name; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_errors::ErrorReported; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId, FatalError}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Namespace, Res}; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{walk_generics, Visitor as _}; +use rustc_hir::lang_items::SizedTraitLangItem; use rustc_hir::{Constness, GenericArg, GenericArgs}; use rustc_middle::ty::subst::{self, InternalSubsts, Subst, SubstsRef}; use rustc_middle::ty::{ diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 7f1631a620499..5de0184f2bba9 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -32,11 +32,10 @@ use super::FnCtxt; use crate::hir::def_id::DefId; use crate::type_error_struct; -use crate::util::common::ErrorReported; use rustc_ast::ast; -use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; +use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported}; use rustc_hir as hir; -use rustc_middle::middle::lang_items; +use rustc_hir::lang_items; use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::cast::{CastKind, CastTy}; use rustc_middle::ty::error::TypeError; diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 415b5103104a1..922d9ca6485bb 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -3,9 +3,10 @@ use super::{check_fn, Expectation, FnCtxt, GeneratorTypes}; use crate::astconv::AstConv; -use crate::middle::{lang_items, region}; +use crate::middle::region; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::lang_items; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::LateBoundRegionConversionTime; use rustc_infer::infer::{InferOk, InferResult}; diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 9e45793fcdc72..24db25a1f3456 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -1,4 +1,4 @@ -use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId}; +use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId, ErrorReported}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::intravisit; @@ -8,7 +8,6 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::subst::{InternalSubsts, Subst}; use rustc_middle::ty::util::ExplicitSelf; use rustc_middle::ty::{self, GenericParamDefKind, TyCtxt}; -use rustc_middle::util::common::ErrorReported; use rustc_span::Span; use rustc_trait_selection::traits::error_reporting::InferCtxtExt; use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode, Reveal}; diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index a44a607a70335..72220d93d929d 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -1,8 +1,7 @@ use crate::check::regionck::RegionCtxt; use crate::hir; use crate::hir::def_id::DefId; -use crate::util::common::ErrorReported; -use rustc_errors::struct_span_err; +use rustc_errors::{struct_span_err, ErrorReported}; use rustc_infer::infer::outlives::env::OutlivesEnvironment; use rustc_infer::infer::{InferOk, RegionckMode, TyCtxtInferExt}; use rustc_infer::traits::TraitEngineExt as _; diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index bfcb6fe35fe75..9c57ffaf055ac 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -15,19 +15,19 @@ use crate::check::FnCtxt; use crate::check::Needs; use crate::check::TupleArgumentsFlag::DontTupleArguments; use crate::type_error_struct; -use crate::util::common::ErrorReported; use rustc_ast::ast; use rustc_ast::util::lev_distance::find_best_match_for_name; use rustc_data_structures::fx::FxHashMap; +use rustc_errors::ErrorReported; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, DiagnosticId}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def_id::DefId; +use rustc_hir::lang_items; use rustc_hir::{ExprKind, QPath}; use rustc_infer::infer; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; -use rustc_middle::middle::lang_items; use rustc_middle::ty; use rustc_middle::ty::adjustment::{ Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index c8632086771f9..add706b5fcc9a 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -2,7 +2,6 @@ //! found or is otherwise invalid. use crate::check::FnCtxt; -use crate::middle::lang_items::FnOnceTraitLangItem; use rustc_ast::ast; use rustc_ast::util::lev_distance; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -11,6 +10,7 @@ use rustc_hir as hir; use rustc_hir::def::{DefKind, Namespace, Res}; use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::intravisit; +use rustc_hir::lang_items::FnOnceTraitLangItem; use rustc_hir::{ExprKind, Node, QPath}; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_middle::hir::map as hir_map; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 3823efe9d927e..293c4feac62f5 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -88,18 +88,19 @@ mod wfcheck; pub mod writeback; use crate::astconv::{AstConv, GenericArgCountMismatch, PathSeg}; -use crate::middle::lang_items; use rustc_ast::ast; use rustc_ast::util::parser::ExprPrecedence; use rustc_attr as attr; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_errors::ErrorReported; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, DiagnosticId}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE}; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::itemlikevisit::ItemLikeVisitor; +use rustc_hir::lang_items; use rustc_hir::{ExprKind, GenericArg, HirIdMap, Item, ItemKind, Node, PatKind, QPath}; use rustc_index::vec::Idx; use rustc_infer::infer::canonical::{Canonical, OriginalQueryValues, QueryResponse}; @@ -114,7 +115,6 @@ use rustc_middle::ty::adjustment::{ Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, PointerCast, }; use rustc_middle::ty::fold::{TypeFoldable, TypeFolder}; -use rustc_middle::ty::layout::VariantIdx; use rustc_middle::ty::query::Providers; use rustc_middle::ty::subst::{ GenericArgKind, InternalSubsts, Subst, SubstsRef, UserSelfTy, UserSubsts, @@ -132,6 +132,7 @@ use rustc_span::hygiene::DesugaringKind; use rustc_span::source_map::{original_sp, DUMMY_SP}; use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::{self, BytePos, MultiSpan, Span}; +use rustc_target::abi::VariantIdx; use rustc_target::spec::abi::Abi; use rustc_trait_selection::infer::InferCtxtExt as _; use rustc_trait_selection::opaque_types::{InferCtxtExt as _, OpaqueTypeDecl}; @@ -151,7 +152,7 @@ use std::ops::{self, Deref}; use std::slice; use crate::require_c_abi_if_c_variadic; -use crate::util::common::{indenter, ErrorReported}; +use crate::util::common::indenter; use crate::TypeAndSubsts; use self::autoderef::Autoderef; diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 6419113219162..30a53cbc397e8 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -7,8 +7,8 @@ use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::itemlikevisit::ParItemLikeVisitor; +use rustc_hir::lang_items; use rustc_hir::ItemKind; -use rustc_middle::middle::lang_items; use rustc_middle::ty::subst::{InternalSubsts, Subst}; use rustc_middle::ty::trait_def::TraitSpecializationKind; use rustc_middle::ty::{ diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index 32963b6a1f085..384a22d010e56 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -4,11 +4,11 @@ use rustc_errors::struct_span_err; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::lang_items::UnsizeTraitLangItem; use rustc_hir::ItemKind; use rustc_infer::infer; use rustc_infer::infer::outlives::env::OutlivesEnvironment; use rustc_infer::infer::{RegionckMode, TyCtxtInferExt}; -use rustc_middle::middle::lang_items::UnsizeTraitLangItem; use rustc_middle::middle::region; use rustc_middle::ty::adjustment::CoerceUnsizedInfo; use rustc_middle::ty::TypeFoldable; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 30887f840321b..13c6670f6b226 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -17,7 +17,6 @@ use crate::astconv::{AstConv, Bounds, SizedByDefault}; use crate::check::intrinsic::intrinsic_operation_unsafety; use crate::constrained_generic_params as cgp; -use crate::middle::lang_items; use crate::middle::resolve_lifetime as rl; use rustc_ast::ast; use rustc_ast::ast::{Ident, MetaItemKind}; @@ -29,6 +28,7 @@ use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc_hir::weak_lang_items; use rustc_hir::{GenericParamKind, Node, Unsafety}; use rustc_middle::hir::map::blocks::FnLikeNode; use rustc_middle::hir::map::Map; @@ -2569,7 +2569,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs { if tcx.is_weak_lang_item(id) { codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL; } - if let Some(name) = lang_items::link_name(&attrs) { + if let Some(name) = weak_lang_items::link_name(&attrs) { codegen_fn_attrs.export_name = Some(name); codegen_fn_attrs.link_name = Some(name); } diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 1927b9c99e175..7ea6c1c17869a 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -89,7 +89,7 @@ mod outlives; mod structured_errors; mod variance; -use rustc_errors::struct_span_err; +use rustc_errors::{struct_span_err, ErrorReported}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::Node; @@ -100,7 +100,6 @@ use rustc_middle::ty::query::Providers; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::util; -use rustc_middle::util::common::ErrorReported; use rustc_session::config::EntryFnType; use rustc_span::{Span, DUMMY_SP}; use rustc_target::spec::abi::Abi; diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 9f327b0b743d8..73df844a91b80 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -1,5 +1,6 @@ use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; +use rustc_hir::lang_items; use rustc_middle::ty::{self, Region, RegionVid, TypeFoldable}; use rustc_trait_selection::traits::auto_trait::{self, AutoTraitResult}; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index f8e44bc5a1ab7..e027db8b56c00 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -17,7 +17,6 @@ use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX}; use rustc_index::vec::{Idx, IndexVec}; use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData}; -use rustc_middle::middle::lang_items; use rustc_middle::middle::resolve_lifetime as rl; use rustc_middle::middle::stability; use rustc_middle::ty::fold::TypeFolder; diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 7b3fd82479ebb..2e5ecacee12df 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -15,15 +15,15 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::Res; use rustc_hir::def_id::{CrateNum, DefId}; +use rustc_hir::lang_items; use rustc_hir::Mutability; use rustc_index::vec::IndexVec; -use rustc_middle::middle::lang_items; use rustc_middle::middle::stability; -use rustc_middle::ty::layout::VariantIdx; use rustc_span::hygiene::MacroKind; use rustc_span::source_map::DUMMY_SP; use rustc_span::symbol::{sym, Symbol}; use rustc_span::{self, FileName}; +use rustc_target::abi::VariantIdx; use rustc_target::spec::abi::Abi; use crate::clean::cfg::Cfg; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index f9e9a07914d69..7841d5eef58a8 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -1,12 +1,12 @@ use rustc_ast::ast; use rustc_ast::with_globals; use rustc_data_structures::sync::Lrc; +use rustc_errors::ErrorReported; use rustc_feature::UnstableFeatures; use rustc_hir as hir; use rustc_hir::intravisit; use rustc_interface::interface; use rustc_middle::hir::map::Map; -use rustc_middle::util::common::ErrorReported; use rustc_session::{self, config, DiagnosticOutput, Session}; use rustc_span::edition::Edition; use rustc_span::source_map::SourceMap; diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs index 7634124071823..2875ee579307e 100644 --- a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs @@ -1,6 +1,7 @@ #![feature(rustc_private)] extern crate rustc_codegen_ssa; +extern crate rustc_errors; extern crate rustc_middle; #[macro_use] extern crate rustc_data_structures; @@ -14,11 +15,11 @@ extern crate rustc_target; use rustc_codegen_ssa::traits::CodegenBackend; use rustc_data_structures::owning_ref::OwningRef; use rustc_data_structures::sync::MetadataRef; +use rustc_errors::ErrorReported; use rustc_middle::dep_graph::DepGraph; use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoader, MetadataLoaderDyn}; use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; -use rustc_middle::util::common::ErrorReported; use rustc_session::config::OutputFilenames; use rustc_session::Session; use rustc_span::symbol::Symbol; diff --git a/src/test/ui-fulldeps/undef_mask.rs b/src/test/ui-fulldeps/undef_mask.rs index cbf1b63d22b0f..656d0b451bc2b 100644 --- a/src/test/ui-fulldeps/undef_mask.rs +++ b/src/test/ui-fulldeps/undef_mask.rs @@ -5,9 +5,10 @@ #![feature(rustc_private)] extern crate rustc_middle; +extern crate rustc_target; use rustc_middle::mir::interpret::UndefMask; -use rustc_middle::ty::layout::Size; +use rustc_target::abi::Size; fn main() { let mut mask = UndefMask::new(Size::from_bytes(500), false);