Rollup merge of #70634 - Centril:import-directly, r=Mark-Simulacrum

Remove some reexports in `rustc_middle`

This will help get these imports out of the way of detecting the true dependencies in and out to `rustc_middle`, thereby helping future work towards https://github.com/rust-lang/rust/issues/65031.
This commit is contained in:
Mazdak Farrokhzad 2020-04-02 14:27:58 +02:00 committed by GitHub
commit 791e872c53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
133 changed files with 419 additions and 473 deletions

View File

@ -10,17 +10,15 @@
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};
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;
pub use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
pub use rustc_target::abi::call::*;
pub use rustc_target::spec::abi::Abi;
macro_rules! for_each_kind {
($flags: ident, $f: ident, $($kind: ident),+) => ({
$(if $flags.contains(ArgAttribute::$kind) { $f(llvm::Attribute::$kind) })+
@ -450,11 +448,11 @@ fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll V
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 {

View File

@ -16,9 +16,10 @@
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 = <CodegenCx<'ll, 'tcx> 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 @@ fn target_spec(&self) -> &Target {
}
}
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 @@ fn load_operand(&mut self, place: PlaceRef<'tcx, &'ll Value>) -> OperandRef<'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 @@ fn scalar_load_metadata<'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);

View File

@ -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_codegen_ssa::mir::place::PlaceRef;
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_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::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 @@ fn const_to_opt_u128(&self, v: &'ll Value, sign_ext: bool) -> Option<u128> {
})
}
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 @@ fn scalar_to_backend(
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 @@ fn scalar_to_backend(
1,
)
};
if layout.value != layout::Pointer {
if layout.value != Pointer {
unsafe { llvm::LLVMConstPtrToInt(llval, llty) }
} else {
self.const_bitcast(llval, llty)

View File

@ -16,12 +16,11 @@
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;

View File

@ -14,14 +14,13 @@
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 @@ pub fn generate_local_symbol_name(&self, prefix: &str) -> String {
}
}
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
}
}

View File

@ -34,9 +34,7 @@
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_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 @@ fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec<MemberDes
};
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 @@ fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec<MemberDes
discriminant: None,
}]
}
layout::Variants::Multiple {
discr_kind: layout::DiscriminantKind::Tag,
Variants::Multiple {
discr_kind: DiscriminantKind::Tag,
discr_index,
ref variants,
..
@ -1457,9 +1457,9 @@ fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec<MemberDes
})
.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 @@ fn compute_field_path<'a, '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<layout::Size>,
offsets: Vec<Size>,
args: Vec<(String, Ty<'tcx>)>,
discriminant_type_metadata: Option<&'ll DIType>,
span: Span,
@ -1777,7 +1777,7 @@ fn prepare_enum_metadata(
// <unknown>
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,

View File

@ -8,35 +8,35 @@
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<FxHashMap<(Option<String>, Option<String>), &'a DIFile>>,
created_enum_disr_types: RefCell<FxHashMap<(DefId, layout::Primitive), &'a DIType>>,
created_enum_disr_types: RefCell<FxHashMap<(DefId, Primitive), &'a DIType>>,
type_map: RefCell<TypeMap<'a, 'tcx>>,
namespace_map: RefCell<DefIdMap<&'a DIScope>>,

View File

@ -7,23 +7,22 @@
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 @@ fn codegen_intrinsic_call(
}
"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 {

View File

@ -23,11 +23,10 @@
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;

View File

@ -7,11 +7,11 @@
use log::debug;
use rustc_codegen_ssa::traits::*;
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_middle::mir::mono::{Linkage, Visibility};
use rustc_middle::ty::layout::{FnAbiExt, LayoutOf};
use rustc_middle::ty::{Instance, TypeFoldable};
pub use rustc_middle::mir::mono::MonoItem;
use rustc_middle::mir::mono::{Linkage, Visibility};
use rustc_middle::ty::layout::FnAbiExt;
use rustc_middle::ty::{Instance, TypeFoldable};
use rustc_target::abi::LayoutOf;
impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {
fn predefine_static(

View File

@ -12,9 +12,10 @@
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);

View File

@ -4,10 +4,12 @@
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 @@ fn scalar_pair_element_llvm_type<'a>(
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 @@ fn is_llvm_scalar_pair(&self) -> bool {
/// 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 @@ fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type {
// 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 @@ fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type {
}
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 @@ fn immediate_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type {
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 @@ fn scalar_pair_element_llvm_type<'a>(
}
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 @@ fn scalar_pair_element_llvm_type<'a>(
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,
}
}

View File

@ -6,8 +6,9 @@
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(

View File

@ -31,14 +31,14 @@
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::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());

View File

@ -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,

View File

@ -21,10 +21,10 @@
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;

View File

@ -12,7 +12,8 @@
};
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>,

View File

@ -9,14 +9,15 @@
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 @@ fn codegen_call_terminator(
// 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 @@ fn codegen_argument(
// 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);
}

View File

@ -3,9 +3,10 @@
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 @@ pub fn simd_shuffle_indices(
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))

View File

@ -3,11 +3,10 @@
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;

View File

@ -8,8 +8,9 @@
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 @@ pub fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = 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 @@ pub fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = 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 @@ pub fn from_immediate_or_packed_pair<Bx: BuilderMethods<'a, 'tcx, Value = 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 @@ pub fn extract_field<Bx: BuilderMethods<'a, 'tcx, Value = 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 @@ pub fn extract_field<Bx: BuilderMethods<'a, 'tcx, Value = 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 @@ fn store_with_flags<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
}
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);

View File

@ -8,8 +8,10 @@
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 @@ pub fn alloca_unsized_indirect<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
}
pub fn len<Cx: ConstMethods<'tcx, Value = V>>(&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 @@ pub fn project_field<Bx: BuilderMethods<'a, 'tcx, Value = 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 @@ pub fn codegen_get_discr<Bx: BuilderMethods<'a, 'tcx, Value = 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 @@ pub fn codegen_get_discr<Bx: BuilderMethods<'a, 'tcx, Value = 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 @@ pub fn codegen_get_discr<Bx: BuilderMethods<'a, 'tcx, Value = 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 @@ pub fn codegen_set_discr<Bx: BuilderMethods<'a, 'tcx, Value = 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 @@ pub fn codegen_set_discr<Bx: BuilderMethods<'a, 'tcx, Value = 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,
..
} => {

View File

@ -8,13 +8,14 @@
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 @@ pub fn codegen_rvalue_operand(
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 @@ pub fn codegen_rvalue_operand(
);
}
}
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

View File

@ -3,17 +3,18 @@
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;

View File

@ -12,8 +12,9 @@
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;

View File

@ -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<u64>;
fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option<u128>;
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;

View File

@ -3,10 +3,10 @@
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);

View File

@ -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;

View File

@ -3,10 +3,11 @@
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 @@ fn type_int(&self) -> Self::Type {
}
}
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(),

View File

@ -22,10 +22,8 @@
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_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};

View File

@ -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;

View File

@ -5,9 +5,8 @@
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.

View File

@ -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;

View File

@ -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.

View File

@ -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.

View File

@ -4,8 +4,8 @@
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> {

View File

@ -8,9 +8,9 @@
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;

View File

@ -9,7 +9,7 @@
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::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};

View File

@ -4,6 +4,7 @@
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::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;

View File

@ -36,12 +36,13 @@
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};

View File

@ -29,12 +29,13 @@
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;

View File

@ -10,12 +10,13 @@
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 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item<'_>) {
| 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,
..

View File

@ -18,13 +18,13 @@
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;

View File

@ -15,6 +15,7 @@
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::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;

View File

@ -8,11 +8,11 @@
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;

View File

@ -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<rustc_hir::def_id::DefId>,
[few] foreign_module: rustc_middle::middle::cstore::ForeignModule,
[few] foreign_modules: Vec<rustc_middle::middle::cstore::ForeignModule>,

View File

@ -4,7 +4,6 @@
hash_stable_trait_impls, NodeIdHashingMode, StableHashingContext, StableHashingContextProvider,
};
use rustc_span::symbol::{sym, Symbol};
pub use rustc_span::CachingSourceMapView;
mod hcx;

View File

@ -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.

View File

@ -7,14 +7,12 @@
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)]

View File

@ -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_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)]

View File

@ -109,10 +109,10 @@ macro_rules! throw_machine_stop {
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 @@ fn set_alloc_id_same_memory(&mut self, id: AllocId, mem: &'tcx Allocation) {
#[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::<LittleEndian>(data, len),
layout::Endian::Big => target.write_uint128::<BigEndian>(data, len),
Endian::Little => target.write_uint128::<LittleEndian>(data, len),
Endian::Big => target.write_uint128::<BigEndian>(data, len),
}
}
#[inline]
pub fn read_target_uint(endianness: layout::Endian, mut source: &[u8]) -> Result<u128, io::Error> {
pub fn read_target_uint(endianness: Endian, mut source: &[u8]) -> Result<u128, io::Error> {
match endianness {
layout::Endian::Little => source.read_uint128::<LittleEndian>(source.len()),
layout::Endian::Big => source.read_uint128::<BigEndian>(source.len()),
Endian::Little => source.read_uint128::<LittleEndian>(source.len()),
Endian::Big => source.read_uint128::<BigEndian>(source.len()),
}
}

View File

@ -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 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Pointer arithmetic
////////////////////////////////////////////////////////////////////////////////
pub trait PointerArithmetic: layout::HasDataLayout {
pub trait PointerArithmetic: HasDataLayout {
// These are not supposed to be overridden.
#[inline(always)]
@ -100,7 +99,7 @@ fn signed_offset<'tcx>(&self, val: u64, i: i64) -> InterpResult<'tcx, u64> {
}
}
impl<T: layout::HasDataLayout> PointerArithmetic for T {}
impl<T: HasDataLayout> 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

View File

@ -6,12 +6,9 @@
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};

View File

@ -6,7 +6,6 @@
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::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;

View File

@ -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> {

View File

@ -738,7 +738,7 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
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 }
}
}

View File

@ -11,8 +11,6 @@
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::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::{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 @@
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_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 @@ pub fn lib_features(self) -> &'tcx middle::lib_features::LibFeatures {
}
/// 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)
}

View File

@ -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;

View File

@ -15,7 +15,7 @@
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;

View File

@ -11,14 +11,12 @@
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_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_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<self::layout::VariantIdx, VariantDef>,
pub variants: IndexVec<VariantIdx, VariantDef>,
/// Flags of the ADT (e.g., is this a struct? is this non-exhaustive?).
flags: AdtFlags,
/// Repr options provided by the user.

View File

@ -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_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;

View File

@ -7,7 +7,6 @@
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::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};

View File

@ -254,7 +254,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
(),
bool,
usize,
crate::ty::layout::VariantIdx,
::rustc_target::abi::VariantIdx,
u64,
String,
crate::middle::region::Scope,

View File

@ -10,7 +10,6 @@
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_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 @@ pub fn try_to_scalar(&self) -> Option<Scalar> {
}
#[inline]
pub fn try_to_bits(&self, size: ty::layout::Size) -> Option<u128> {
pub fn try_to_bits(&self, size: Size) -> Option<u128> {
if let ConstKind::Value(val) = self { val.try_to_bits(size) } else { None }
}
}

View File

@ -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};

View File

@ -8,8 +8,6 @@
#[cfg(test)]
mod tests;
pub use rustc_errors::ErrorReported;
pub fn to_readable_str(mut val: usize) -> String {
let mut groups = vec![];
loop {

View File

@ -9,10 +9,10 @@
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;

View File

@ -24,13 +24,13 @@
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 _;

View File

@ -17,10 +17,10 @@
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};

View File

@ -9,8 +9,9 @@
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,

View File

@ -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};

View File

@ -36,8 +36,8 @@
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;

View File

@ -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;

View File

@ -7,10 +7,10 @@
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 @@ fn cast_immediate(
// 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 @@ fn cast_immediate(
.into());
}
}
layout::Variants::Multiple { .. } => {}
Variants::Multiple { .. } => {}
}
// Handle casting the metadata away from a fat pointer.

View File

@ -13,11 +13,12 @@
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 @@ pub fn current_source_info(&self) -> Option<mir::SourceInfo> {
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
}
}

View File

@ -11,10 +11,10 @@
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 @@ pub fn emulate_intrinsic(
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 {

View File

@ -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;

View File

@ -11,11 +11,10 @@
use std::convert::TryFrom;
use std::ptr;
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_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_middle::ty::{self, query::TyCtxtAt, Instance, ParamEnv};
use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout};
use super::{
AllocId, AllocMap, Allocation, AllocationExtra, CheckInAllocMsg, ErrorHandled, GlobalAlloc,

View File

@ -10,12 +10,12 @@
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 @@ fn try_read_immediate_from_mplace(
};
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 @@ fn try_read_immediate_from_mplace(
)?;
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 @@ pub fn read_discriminant(
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 @@ pub fn read_discriminant(
.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 @@ pub fn read_discriminant(
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 @@ pub fn read_discriminant(
.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 @@ pub fn read_discriminant(
.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

View File

@ -4,11 +4,8 @@
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};

View File

@ -8,10 +8,10 @@
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 @@ pub(super) fn len(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> {
// 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 @@ pub fn mplace_index(
) -> 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 @@ pub(super) fn mplace_array_fields(
{
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 @@ fn mplace_subslice(
// 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 @@ fn write_immediate_to_mplace_no_validate(
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 @@ fn write_immediate_to_mplace_no_validate(
// 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 @@ pub fn write_discriminant_index(
}
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 @@ pub fn write_discriminant_index(
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,
..

View File

@ -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};

View File

@ -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 @@ fn check_argument_compat(
// 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,

View File

@ -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};

View File

@ -11,8 +11,9 @@
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 @@ fn aggregate_field_path_elem(&mut self, layout: TyAndLayout<'tcx>, field: usize)
};
}
}
layout::Variants::Single { .. } => {}
Variants::Single { .. } => {}
}
// Now we know we are projecting to a field, so figure out which one.
@ -226,11 +227,11 @@ fn aggregate_field_path_elem(&mut self, layout: TyAndLayout<'tcx>, field: usize)
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 @@ fn try_visit_primitive(
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 @@ fn visit_value(&mut self, op: OpTy<'tcx, M::PointerTag>) -> InterpResult<'tcx> {
// 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.
}
}

View File

@ -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 @@ fn walk_value(&mut self, v: Self::V) -> InterpResult<'tcx>
// 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<InterpResult<'tcx, Self::V>> =
@ -220,7 +221,7 @@ fn walk_value(&mut self, v: Self::V) -> InterpResult<'tcx>
.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 @@ fn walk_value(&mut self, v: Self::V) -> InterpResult<'tcx>
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 @@ fn walk_value(&mut self, v: Self::V) -> InterpResult<'tcx>
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(())
}
}
}

View File

@ -181,9 +181,9 @@
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};

View File

@ -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};

View File

@ -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;

View File

@ -19,13 +19,12 @@
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;

View File

@ -13,9 +13,9 @@
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;

View File

@ -63,10 +63,10 @@
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;

View File

@ -5,8 +5,9 @@
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;

View File

@ -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;

View File

@ -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;

View File

@ -9,7 +9,8 @@
};
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 _;

View File

@ -16,9 +16,9 @@
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:

View File

@ -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;

View File

@ -9,14 +9,14 @@
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 @@ fn non_scalar_compare(
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);

View File

@ -2,17 +2,17 @@
use crate::build::scope::DropKind;
use crate::hair::cx::Cx;
use crate::hair::{BindingMode, LintLevel, PatKind};
use rustc_middle::middle::lang_items;
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_attr::{self as attr, UnwindAttr};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::{GeneratorKind, HirIdMap, Node};
use rustc_index::vec::{Idx, IndexVec};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_span::symbol::kw;
use rustc_span::Span;
use rustc_target::spec::abi::Abi;

Some files were not shown because too many files have changed in this diff Show More