nix rustc_target::abi::* reexport in ty::layout
This commit is contained in:
parent
127a11a344
commit
124144704f
85 changed files with 336 additions and 372 deletions
|
@ -10,17 +10,15 @@ use rustc_codegen_ssa::mir::place::PlaceRef;
|
|||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_codegen_ssa::MemFlags;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::layout::{self};
|
||||
pub use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_target::abi::call::ArgAbi;
|
||||
use rustc_target::abi::{HasDataLayout, LayoutOf};
|
||||
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 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
|||
PassMode::Indirect(ref attrs, _) => apply(attrs, Some(self.ret.layout.llvm_type(bx))),
|
||||
_ => {}
|
||||
}
|
||||
if let layout::Abi::Scalar(ref scalar) = self.ret.layout.abi {
|
||||
if let abi::Abi::Scalar(ref scalar) = self.ret.layout.abi {
|
||||
// If the value is a boolean, the range is 0..2 and that ultimately
|
||||
// become 0..0 when the type becomes i1, which would be rejected
|
||||
// by the LLVM verifier.
|
||||
if let layout::Int(..) = scalar.value {
|
||||
if let Int(..) = scalar.value {
|
||||
if !scalar.is_bool() {
|
||||
let range = scalar.valid_range_exclusive(bx);
|
||||
if range.start != range.end {
|
||||
|
|
|
@ -16,9 +16,10 @@ use rustc_codegen_ssa::MemFlags;
|
|||
use rustc_data_structures::const_cstr;
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::layout::{self, Align, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_session::config::{self, Sanitizer};
|
||||
use rustc_target::abi::{self, Align, Size};
|
||||
use rustc_target::spec::{HasTargetSpec, Target};
|
||||
use std::borrow::Cow;
|
||||
use std::ffi::CStr;
|
||||
|
@ -60,8 +61,8 @@ impl BackendTypes for Builder<'_, 'll, 'tcx> {
|
|||
type DIVariable = <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 @@ impl HasTargetSpec for Builder<'_, '_, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> {
|
||||
impl abi::LayoutOf for Builder<'_, '_, 'tcx> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyAndLayout = TyAndLayout<'tcx>;
|
||||
|
||||
|
@ -435,17 +436,17 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
fn scalar_load_metadata<'a, 'll, 'tcx>(
|
||||
bx: &mut Builder<'a, 'll, 'tcx>,
|
||||
load: &'ll Value,
|
||||
scalar: &layout::Scalar,
|
||||
scalar: &abi::Scalar,
|
||||
) {
|
||||
let vr = scalar.valid_range.clone();
|
||||
match scalar.value {
|
||||
layout::Int(..) => {
|
||||
abi::Int(..) => {
|
||||
let range = scalar.valid_range_exclusive(bx);
|
||||
if range.start != range.end {
|
||||
bx.range_metadata(load, range);
|
||||
}
|
||||
}
|
||||
layout::Pointer if vr.start() < vr.end() && !vr.contains(&0) => {
|
||||
abi::Pointer if vr.start() < vr.end() && !vr.contains(&0) => {
|
||||
bx.nonnull_metadata(load);
|
||||
}
|
||||
_ => {}
|
||||
|
@ -465,16 +466,16 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
}
|
||||
let llval = const_llval.unwrap_or_else(|| {
|
||||
let load = self.load(place.llval, place.align);
|
||||
if let layout::Abi::Scalar(ref scalar) = place.layout.abi {
|
||||
if let abi::Abi::Scalar(ref scalar) = place.layout.abi {
|
||||
scalar_load_metadata(self, load, scalar);
|
||||
}
|
||||
load
|
||||
});
|
||||
OperandValue::Immediate(to_immediate(self, llval, place.layout))
|
||||
} else if let layout::Abi::ScalarPair(ref a, ref b) = place.layout.abi {
|
||||
} else if let abi::Abi::ScalarPair(ref a, ref b) = place.layout.abi {
|
||||
let b_offset = a.value.size(self).align_to(b.value.align(self).abi);
|
||||
|
||||
let mut load = |i, scalar: &layout::Scalar, align| {
|
||||
let mut load = |i, scalar: &abi::Scalar, align| {
|
||||
let llptr = self.struct_gep(place.llval, i as u64);
|
||||
let load = self.load(llptr, align);
|
||||
scalar_load_metadata(self, load, scalar);
|
||||
|
|
|
@ -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 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
})
|
||||
}
|
||||
|
||||
fn scalar_to_backend(
|
||||
&self,
|
||||
cv: Scalar,
|
||||
layout: &layout::Scalar,
|
||||
llty: &'ll Type,
|
||||
) -> &'ll Value {
|
||||
fn scalar_to_backend(&self, cv: Scalar, layout: &abi::Scalar, llty: &'ll Type) -> &'ll Value {
|
||||
let bitsize = if layout.is_bool() { 1 } else { layout.value.size(self).bits() };
|
||||
match cv {
|
||||
Scalar::Raw { size: 0, .. } => {
|
||||
|
@ -244,7 +237,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
Scalar::Raw { data, size } => {
|
||||
assert_eq!(size as u64, layout.value.size(self).bytes());
|
||||
let llval = self.const_uint_big(self.type_ix(bitsize), data);
|
||||
if layout.value == layout::Pointer {
|
||||
if layout.value == Pointer {
|
||||
unsafe { llvm::LLVMConstIntToPtr(llval, llty) }
|
||||
} else {
|
||||
self.const_bitcast(llval, llty)
|
||||
|
@ -278,7 +271,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
1,
|
||||
)
|
||||
};
|
||||
if layout.value != layout::Pointer {
|
||||
if layout.value != Pointer {
|
||||
unsafe { llvm::LLVMConstPtrToInt(llval, llty) }
|
||||
} else {
|
||||
self.const_bitcast(llval, llty)
|
||||
|
|
|
@ -16,12 +16,11 @@ use rustc_middle::mir::interpret::{
|
|||
read_target_uint, Allocation, ConstValue, ErrorHandled, Pointer,
|
||||
};
|
||||
use rustc_middle::mir::mono::MonoItem;
|
||||
use rustc_middle::ty::layout::{self, Align, LayoutOf, Size};
|
||||
use rustc_middle::ty::{self, Instance, Ty};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::HasDataLayout;
|
||||
use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Primitive, Scalar, Size};
|
||||
|
||||
use std::ffi::CStr;
|
||||
|
||||
|
@ -56,7 +55,7 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll
|
|||
as u64;
|
||||
llvals.push(cx.scalar_to_backend(
|
||||
Pointer::new(alloc_id, Size::from_bytes(ptr_offset)).into(),
|
||||
&layout::Scalar { value: layout::Primitive::Pointer, valid_range: 0..=!0 },
|
||||
&Scalar { value: Primitive::Pointer, valid_range: 0..=!0 },
|
||||
cx.type_i8p(),
|
||||
));
|
||||
next_offset = offset + pointer_size;
|
||||
|
|
|
@ -14,14 +14,13 @@ use rustc_data_structures::fx::FxHashMap;
|
|||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::mir::mono::CodegenUnit;
|
||||
use rustc_middle::ty::layout::{
|
||||
HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc_middle::ty::layout::{HasParamEnv, LayoutError, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
||||
use rustc_session::config::{self, CFGuard, DebugInfo};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::source_map::{Span, DUMMY_SP};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::{HasDataLayout, LayoutOf, PointeeInfo, Size, TargetDataLayout, VariantIdx};
|
||||
use rustc_target::spec::{HasTargetSpec, Target};
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
@ -817,8 +816,8 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ty::layout::HasDataLayout for CodegenCx<'ll, 'tcx> {
|
||||
fn data_layout(&self) -> &ty::layout::TargetDataLayout {
|
||||
impl HasDataLayout for CodegenCx<'ll, 'tcx> {
|
||||
fn data_layout(&self) -> &TargetDataLayout {
|
||||
&self.tcx.data_layout
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,9 +34,7 @@ use rustc_middle::ich::NodeIdHashingMode;
|
|||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::mir::interpret::truncate;
|
||||
use rustc_middle::mir::{self, Field, GeneratorLayout};
|
||||
use rustc_middle::ty::layout::{
|
||||
self, Align, Integer, IntegerExt, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc_middle::ty::layout::{self, IntegerExt, PrimitiveExt, TyAndLayout};
|
||||
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
||||
use rustc_middle::ty::Instance;
|
||||
use rustc_middle::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
|
||||
|
@ -44,7 +42,9 @@ use rustc_middle::{bug, span_bug};
|
|||
use rustc_session::config::{self, DebugInfo};
|
||||
use rustc_span::symbol::{Interner, Symbol};
|
||||
use rustc_span::{self, FileName, Span};
|
||||
use rustc_target::abi::HasDataLayout;
|
||||
use rustc_target::abi::{Abi, Align, DiscriminantKind, HasDataLayout, Integer, LayoutOf};
|
||||
use rustc_target::abi::{Int, Pointer, F32, F64};
|
||||
use rustc_target::abi::{Primitive, Size, VariantIdx, Variants};
|
||||
|
||||
use libc::{c_longlong, c_uint};
|
||||
use std::collections::hash_map::Entry;
|
||||
|
@ -1364,7 +1364,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
|
|||
};
|
||||
|
||||
match self.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
if let ty::Adt(adt, _) = &self.enum_type.kind {
|
||||
if adt.variants.is_empty() {
|
||||
return vec![];
|
||||
|
@ -1399,8 +1399,8 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
|
|||
discriminant: None,
|
||||
}]
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Tag,
|
||||
Variants::Multiple {
|
||||
discr_kind: DiscriminantKind::Tag,
|
||||
discr_index,
|
||||
ref variants,
|
||||
..
|
||||
|
@ -1457,9 +1457,9 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
|
|||
})
|
||||
.collect()
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
Variants::Multiple {
|
||||
discr_kind:
|
||||
layout::DiscriminantKind::Niche { ref niche_variants, niche_start, dataful_variant },
|
||||
DiscriminantKind::Niche { ref niche_variants, niche_start, dataful_variant },
|
||||
ref discr,
|
||||
ref variants,
|
||||
discr_index,
|
||||
|
@ -1592,7 +1592,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
|
|||
// Creates `MemberDescription`s for the fields of a single enum variant.
|
||||
struct VariantMemberDescriptionFactory<'ll, 'tcx> {
|
||||
/// Cloned from the `layout::Struct` describing the variant.
|
||||
offsets: Vec<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,
|
||||
|
|
|
@ -8,35 +8,35 @@ use self::namespace::mangled_name_of_instance;
|
|||
use self::type_names::compute_debuginfo_type_name;
|
||||
use self::utils::{create_DIArray, is_node_local_to_unit, DIB};
|
||||
|
||||
use crate::abi::FnAbi;
|
||||
use crate::builder::Builder;
|
||||
use crate::common::CodegenCx;
|
||||
use crate::llvm;
|
||||
use crate::llvm::debuginfo::{
|
||||
DIArray, DIBuilder, DIFile, DIFlags, DILexicalBlock, DISPFlags, DIScope, DIType, DIVariable,
|
||||
};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE};
|
||||
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
||||
|
||||
use crate::abi::FnAbi;
|
||||
use crate::builder::Builder;
|
||||
use crate::common::CodegenCx;
|
||||
use crate::value::Value;
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_codegen_ssa::debuginfo::type_names;
|
||||
use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind};
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
||||
use rustc_middle::ty::{self, Instance, ParamEnv, Ty};
|
||||
use rustc_session::config::{self, DebugInfo};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{self, BytePos, Span};
|
||||
use rustc_target::abi::{LayoutOf, Primitive, Size};
|
||||
|
||||
use libc::c_uint;
|
||||
use log::debug;
|
||||
use std::cell::RefCell;
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_middle::ty::layout::{self, HasTyCtxt, LayoutOf, Size};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{self, BytePos, Span};
|
||||
use smallvec::SmallVec;
|
||||
use std::cell::RefCell;
|
||||
|
||||
mod create_scope_map;
|
||||
pub mod gdb;
|
||||
|
@ -60,7 +60,7 @@ pub struct CrateDebugContext<'a, 'tcx> {
|
|||
llmod: &'a llvm::Module,
|
||||
builder: &'a mut DIBuilder<'a>,
|
||||
created_files: RefCell<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>>,
|
||||
|
|
|
@ -7,23 +7,22 @@ use crate::type_::Type;
|
|||
use crate::type_of::LayoutLlvmExt;
|
||||
use crate::va_arg::emit_va_arg;
|
||||
use crate::value::Value;
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_codegen_ssa::base::{compare_simd_types, to_immediate, wants_msvc_seh};
|
||||
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
|
||||
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
|
||||
use rustc_codegen_ssa::glue;
|
||||
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
|
||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_codegen_ssa::MemFlags;
|
||||
use rustc_hir as hir;
|
||||
use rustc_middle::ty::layout::{self, FnAbiExt, HasTyCtxt, LayoutOf, Primitive};
|
||||
use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_target::abi::HasDataLayout;
|
||||
|
||||
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{self, HasDataLayout, LayoutOf, Primitive};
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::{i128, iter, u128};
|
||||
|
@ -145,7 +144,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
}
|
||||
"va_arg" => {
|
||||
match fn_abi.ret.layout.abi {
|
||||
layout::Abi::Scalar(ref scalar) => {
|
||||
abi::Abi::Scalar(ref scalar) => {
|
||||
match scalar.value {
|
||||
Primitive::Int(..) => {
|
||||
if self.cx().size_of(ret_ty).bytes() < 4 {
|
||||
|
|
|
@ -7,11 +7,11 @@ use crate::type_of::LayoutLlvmExt;
|
|||
use log::debug;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
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(
|
||||
|
|
|
@ -12,9 +12,10 @@ use rustc_codegen_ssa::common::TypeKind;
|
|||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::layout::{self, Align, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
|
||||
use rustc_target::abi::{Align, Integer, Size};
|
||||
|
||||
use std::fmt;
|
||||
use std::ptr;
|
||||
|
@ -114,14 +115,14 @@ impl CodegenCx<'ll, 'tcx> {
|
|||
|
||||
crate fn type_pointee_for_align(&self, align: Align) -> &'ll Type {
|
||||
// FIXME(eddyb) We could find a better approximation if ity.align < align.
|
||||
let ity = layout::Integer::approximate_align(self, align);
|
||||
let ity = Integer::approximate_align(self, align);
|
||||
self.type_from_integer(ity)
|
||||
}
|
||||
|
||||
/// Return a LLVM type that has at most the required alignment,
|
||||
/// and exactly the required size, as a best-effort padding array.
|
||||
crate fn type_padding_filler(&self, size: Size, align: Align) -> &'ll Type {
|
||||
let unit = layout::Integer::approximate_align(self, align);
|
||||
let unit = Integer::approximate_align(self, align);
|
||||
let size = size.bytes();
|
||||
let unit_size = unit.size().bytes();
|
||||
assert_eq!(size % unit_size, 0);
|
||||
|
|
|
@ -4,10 +4,12 @@ use crate::type_::Type;
|
|||
use log::debug;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::layout::{self, Align, FnAbiExt, LayoutOf, PointeeInfo, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{FnAbiExt, TyAndLayout};
|
||||
use rustc_middle::ty::print::obsolete::DefPathBasedNames;
|
||||
use rustc_middle::ty::{self, Ty, TypeFoldable};
|
||||
use rustc_target::abi::TyAndLayoutMethods;
|
||||
use rustc_target::abi::{Abi, Align, FieldsShape};
|
||||
use rustc_target::abi::{Int, Pointer, F32, F64};
|
||||
use rustc_target::abi::{LayoutOf, PointeeInfo, Scalar, Size, TyAndLayoutMethods, Variants};
|
||||
|
||||
use std::fmt::Write;
|
||||
|
||||
|
@ -17,8 +19,8 @@ fn uncached_llvm_type<'a, 'tcx>(
|
|||
defer: &mut Option<(&'a Type, TyAndLayout<'tcx>)>,
|
||||
) -> &'a Type {
|
||||
match layout.abi {
|
||||
layout::Abi::Scalar(_) => bug!("handled elsewhere"),
|
||||
layout::Abi::Vector { ref element, count } => {
|
||||
Abi::Scalar(_) => bug!("handled elsewhere"),
|
||||
Abi::Vector { ref element, count } => {
|
||||
// LLVM has a separate type for 64-bit SIMD vectors on X86 called
|
||||
// `x86_mmx` which is needed for some SIMD operations. As a bit of a
|
||||
// hack (all SIMD definitions are super unstable anyway) we
|
||||
|
@ -37,7 +39,7 @@ fn uncached_llvm_type<'a, 'tcx>(
|
|||
return cx.type_vector(element, count);
|
||||
}
|
||||
}
|
||||
layout::Abi::ScalarPair(..) => {
|
||||
Abi::ScalarPair(..) => {
|
||||
return cx.type_struct(
|
||||
&[
|
||||
layout.scalar_pair_element_llvm_type(cx, 0, false),
|
||||
|
@ -46,7 +48,7 @@ fn uncached_llvm_type<'a, 'tcx>(
|
|||
false,
|
||||
);
|
||||
}
|
||||
layout::Abi::Uninhabited | layout::Abi::Aggregate { .. } => {}
|
||||
Abi::Uninhabited | Abi::Aggregate { .. } => {}
|
||||
}
|
||||
|
||||
let name = match layout.ty.kind {
|
||||
|
@ -61,14 +63,14 @@ fn uncached_llvm_type<'a, 'tcx>(
|
|||
let mut name = String::with_capacity(32);
|
||||
let printer = DefPathBasedNames::new(cx.tcx, true, true);
|
||||
printer.push_type_name(layout.ty, &mut name, false);
|
||||
if let (&ty::Adt(def, _), &layout::Variants::Single { index })
|
||||
if let (&ty::Adt(def, _), &Variants::Single { index })
|
||||
= (&layout.ty.kind, &layout.variants)
|
||||
{
|
||||
if def.is_enum() && !def.variants.is_empty() {
|
||||
write!(&mut name, "::{}", def.variants[index].ident).unwrap();
|
||||
}
|
||||
}
|
||||
if let (&ty::Generator(_, substs, _), &layout::Variants::Single { index })
|
||||
if let (&ty::Generator(_, substs, _), &Variants::Single { index })
|
||||
= (&layout.ty.kind, &layout.variants)
|
||||
{
|
||||
write!(&mut name, "::{}", substs.as_generator().variant_name(index)).unwrap();
|
||||
|
@ -79,7 +81,7 @@ fn uncached_llvm_type<'a, 'tcx>(
|
|||
};
|
||||
|
||||
match layout.fields {
|
||||
layout::FieldsShape::Union(_) => {
|
||||
FieldsShape::Union(_) => {
|
||||
let fill = cx.type_padding_filler(layout.size, layout.align.abi);
|
||||
let packed = false;
|
||||
match name {
|
||||
|
@ -91,10 +93,8 @@ fn uncached_llvm_type<'a, 'tcx>(
|
|||
}
|
||||
}
|
||||
}
|
||||
layout::FieldsShape::Array { count, .. } => {
|
||||
cx.type_array(layout.field(cx, 0).llvm_type(cx), count)
|
||||
}
|
||||
layout::FieldsShape::Arbitrary { .. } => match name {
|
||||
FieldsShape::Array { count, .. } => cx.type_array(layout.field(cx, 0).llvm_type(cx), count),
|
||||
FieldsShape::Arbitrary { .. } => match name {
|
||||
None => {
|
||||
let (llfields, packed) = struct_llfields(cx, layout);
|
||||
cx.type_struct(&llfields, packed)
|
||||
|
@ -189,7 +189,7 @@ pub trait LayoutLlvmExt<'tcx> {
|
|||
fn scalar_llvm_type_at<'a>(
|
||||
&self,
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
scalar: &layout::Scalar,
|
||||
scalar: &Scalar,
|
||||
offset: Size,
|
||||
) -> &'a Type;
|
||||
fn scalar_pair_element_llvm_type<'a>(
|
||||
|
@ -205,19 +205,16 @@ pub trait LayoutLlvmExt<'tcx> {
|
|||
impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
||||
fn is_llvm_immediate(&self) -> bool {
|
||||
match self.abi {
|
||||
layout::Abi::Scalar(_) | layout::Abi::Vector { .. } => true,
|
||||
layout::Abi::ScalarPair(..) => false,
|
||||
layout::Abi::Uninhabited | layout::Abi::Aggregate { .. } => self.is_zst(),
|
||||
Abi::Scalar(_) | Abi::Vector { .. } => true,
|
||||
Abi::ScalarPair(..) => false,
|
||||
Abi::Uninhabited | Abi::Aggregate { .. } => self.is_zst(),
|
||||
}
|
||||
}
|
||||
|
||||
fn is_llvm_scalar_pair(&self) -> bool {
|
||||
match self.abi {
|
||||
layout::Abi::ScalarPair(..) => true,
|
||||
layout::Abi::Uninhabited
|
||||
| layout::Abi::Scalar(_)
|
||||
| layout::Abi::Vector { .. }
|
||||
| layout::Abi::Aggregate { .. } => false,
|
||||
Abi::ScalarPair(..) => true,
|
||||
Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } | Abi::Aggregate { .. } => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,7 +230,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
|||
/// of that field's type - this is useful for taking the address of
|
||||
/// that field and ensuring the struct has the right alignment.
|
||||
fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type {
|
||||
if let layout::Abi::Scalar(ref scalar) = self.abi {
|
||||
if let Abi::Scalar(ref scalar) = self.abi {
|
||||
// Use a different cache for scalars because pointers to DSTs
|
||||
// can be either fat or thin (data pointers of fat pointers).
|
||||
if let Some(&llty) = cx.scalar_lltypes.borrow().get(&self.ty) {
|
||||
|
@ -255,7 +252,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
|||
|
||||
// Check the cache.
|
||||
let variant_index = match self.variants {
|
||||
layout::Variants::Single { index } => Some(index),
|
||||
Variants::Single { index } => Some(index),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(&llty) = cx.lltypes.borrow().get(&(self.ty, variant_index)) {
|
||||
|
@ -293,7 +290,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
|||
}
|
||||
|
||||
fn immediate_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type {
|
||||
if let layout::Abi::Scalar(ref scalar) = self.abi {
|
||||
if let Abi::Scalar(ref scalar) = self.abi {
|
||||
if scalar.is_bool() {
|
||||
return cx.type_i1();
|
||||
}
|
||||
|
@ -304,14 +301,14 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
|||
fn scalar_llvm_type_at<'a>(
|
||||
&self,
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
scalar: &layout::Scalar,
|
||||
scalar: &Scalar,
|
||||
offset: Size,
|
||||
) -> &'a Type {
|
||||
match scalar.value {
|
||||
layout::Int(i, _) => cx.type_from_integer(i),
|
||||
layout::F32 => cx.type_f32(),
|
||||
layout::F64 => cx.type_f64(),
|
||||
layout::Pointer => {
|
||||
Int(i, _) => cx.type_from_integer(i),
|
||||
F32 => cx.type_f32(),
|
||||
F64 => cx.type_f64(),
|
||||
Pointer => {
|
||||
// If we know the alignment, pick something better than i8.
|
||||
let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) {
|
||||
cx.type_pointee_for_align(pointee.align)
|
||||
|
@ -343,7 +340,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
|||
}
|
||||
|
||||
let (a, b) = match self.abi {
|
||||
layout::Abi::ScalarPair(ref a, ref b) => (a, b),
|
||||
Abi::ScalarPair(ref a, ref b) => (a, b),
|
||||
_ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self),
|
||||
};
|
||||
let scalar = [a, b][index];
|
||||
|
@ -365,21 +362,19 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
|||
|
||||
fn llvm_field_index(&self, index: usize) -> u64 {
|
||||
match self.abi {
|
||||
layout::Abi::Scalar(_) | layout::Abi::ScalarPair(..) => {
|
||||
Abi::Scalar(_) | Abi::ScalarPair(..) => {
|
||||
bug!("TyAndLayout::llvm_field_index({:?}): not applicable", self)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
match self.fields {
|
||||
layout::FieldsShape::Union(_) => {
|
||||
FieldsShape::Union(_) => {
|
||||
bug!("TyAndLayout::llvm_field_index({:?}): not applicable", self)
|
||||
}
|
||||
|
||||
layout::FieldsShape::Array { .. } => index as u64,
|
||||
FieldsShape::Array { .. } => index as u64,
|
||||
|
||||
layout::FieldsShape::Arbitrary { .. } => {
|
||||
1 + (self.fields.memory_index(index) as u64) * 2
|
||||
}
|
||||
FieldsShape::Arbitrary { .. } => 1 + (self.fields.memory_index(index) as u64) * 2,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,9 @@ use rustc_codegen_ssa::mir::operand::OperandRef;
|
|||
use rustc_codegen_ssa::traits::{
|
||||
BaseTypeMethods, BuilderMethods, ConstMethods, DerivedTypeMethods,
|
||||
};
|
||||
use rustc_middle::ty::layout::{Align, HasDataLayout, HasTyCtxt, LayoutOf, Size};
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Size};
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn round_pointer_up_to_alignment(
|
||||
|
|
|
@ -38,7 +38,7 @@ use rustc_middle::middle::cstore::{self, LinkagePreference};
|
|||
use rustc_middle::middle::lang_items;
|
||||
use rustc_middle::middle::lang_items::StartFnLangItem;
|
||||
use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem};
|
||||
use rustc_middle::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyAndLayout, VariantIdx};
|
||||
use rustc_middle::ty::layout::{self, HasTyCtxt, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
||||
|
@ -47,6 +47,7 @@ use rustc_session::config::{self, EntryFnType, Lto};
|
|||
use rustc_session::Session;
|
||||
use rustc_span::Span;
|
||||
use rustc_symbol_mangling::test as symbol_names_test;
|
||||
use rustc_target::abi::{Abi, Align, LayoutOf, Scalar, VariantIdx};
|
||||
|
||||
use std::cmp;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
@ -343,7 +344,7 @@ pub fn to_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
val: Bx::Value,
|
||||
layout: layout::TyAndLayout<'_>,
|
||||
) -> Bx::Value {
|
||||
if let layout::Abi::Scalar(ref scalar) = layout.abi {
|
||||
if let Abi::Scalar(ref scalar) = layout.abi {
|
||||
return to_immediate_scalar(bx, val, scalar);
|
||||
}
|
||||
val
|
||||
|
@ -352,7 +353,7 @@ pub fn to_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
pub fn to_immediate_scalar<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
bx: &mut Bx,
|
||||
val: Bx::Value,
|
||||
scalar: &layout::Scalar,
|
||||
scalar: &Scalar,
|
||||
) -> Bx::Value {
|
||||
if scalar.is_bool() {
|
||||
return bx.trunc(val, bx.cx().type_i1());
|
||||
|
|
|
@ -12,7 +12,8 @@ use rustc_middle::mir::visit::{
|
|||
};
|
||||
use rustc_middle::mir::{self, Location, TerminatorKind};
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
||||
pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
fx: &FunctionCx<'a, 'tcx, Bx>,
|
||||
|
|
|
@ -13,10 +13,11 @@ use rustc_index::vec::Idx;
|
|||
use rustc_middle::middle::lang_items;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::AssertKind;
|
||||
use rustc_middle::ty::layout::{self, FnAbiExt, HasTyCtxt, LayoutOf};
|
||||
use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt};
|
||||
use rustc_middle::ty::{self, Instance, Ty, TypeFoldable};
|
||||
use rustc_span::{source_map::Span, symbol::Symbol};
|
||||
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
|
||||
use rustc_target::abi::{self, LayoutOf};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
@ -591,7 +592,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
// we can do what we like. Here, we declare that transmuting
|
||||
// into an uninhabited type is impossible, so anything following
|
||||
// it must be unreachable.
|
||||
assert_eq!(fn_abi.ret.layout.abi, layout::Abi::Uninhabited);
|
||||
assert_eq!(fn_abi.ret.layout.abi, abi::Abi::Uninhabited);
|
||||
bx.unreachable();
|
||||
}
|
||||
return;
|
||||
|
@ -994,7 +995,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
// the load would just produce `OperandValue::Ref` instead
|
||||
// of the `OperandValue::Immediate` we need for the call.
|
||||
llval = bx.load(llval, align);
|
||||
if let layout::Abi::Scalar(ref scalar) = arg.layout.abi {
|
||||
if let abi::Abi::Scalar(ref scalar) = arg.layout.abi {
|
||||
if scalar.is_bool() {
|
||||
bx.range_metadata(llval, 0..2);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,10 @@ use crate::traits::*;
|
|||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{ConstValue, ErrorHandled};
|
||||
use rustc_middle::ty::layout::{self, HasTyCtxt};
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_target::abi::Abi;
|
||||
|
||||
use super::FunctionCx;
|
||||
|
||||
|
@ -87,7 +88,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
if let Some(prim) = field.try_to_scalar() {
|
||||
let layout = bx.layout_of(field_ty);
|
||||
let scalar = match layout.abi {
|
||||
layout::Abi::Scalar(ref x) => x,
|
||||
Abi::Scalar(ref x) => x,
|
||||
_ => bug!("from_const: invalid ByVal layout: {:#?}", layout),
|
||||
};
|
||||
bx.scalar_to_backend(prim, scalar, bx.immediate_backend_type(layout))
|
||||
|
|
|
@ -3,11 +3,10 @@ use rustc_hir::def_id::CrateNum;
|
|||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::layout::{LayoutOf, Size};
|
||||
use rustc_session::config::DebugInfo;
|
||||
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use rustc_target::abi::{LayoutOf, Size};
|
||||
|
||||
use super::operand::OperandValue;
|
||||
use super::place::PlaceRef;
|
||||
|
|
|
@ -8,8 +8,9 @@ use crate::MemFlags;
|
|||
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{ConstValue, ErrorHandled, Pointer, Scalar};
|
||||
use rustc_middle::ty::layout::{self, Align, LayoutOf, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_target::abi::{Abi, Align, LayoutOf, Size};
|
||||
|
||||
use std::fmt;
|
||||
|
||||
|
@ -78,7 +79,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
|||
let val = match val {
|
||||
ConstValue::Scalar(x) => {
|
||||
let scalar = match layout.abi {
|
||||
layout::Abi::Scalar(ref x) => x,
|
||||
Abi::Scalar(ref x) => x,
|
||||
_ => bug!("from_const: invalid ByVal layout: {:#?}", layout),
|
||||
};
|
||||
let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout));
|
||||
|
@ -86,7 +87,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
|||
}
|
||||
ConstValue::Slice { data, start, end } => {
|
||||
let a_scalar = match layout.abi {
|
||||
layout::Abi::ScalarPair(ref a, _) => a,
|
||||
Abi::ScalarPair(ref a, _) => a,
|
||||
_ => bug!("from_const: invalid ScalarPair layout: {:#?}", layout),
|
||||
};
|
||||
let a = Scalar::from(Pointer::new(
|
||||
|
@ -161,7 +162,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
|||
llval: V,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> Self {
|
||||
let val = if let layout::Abi::ScalarPair(ref a, ref b) = layout.abi {
|
||||
let val = if let Abi::ScalarPair(ref a, ref b) = layout.abi {
|
||||
debug!("Operand::from_immediate_or_packed_pair: unpacking {:?} @ {:?}", llval, layout);
|
||||
|
||||
// Deconstruct the immediate aggregate.
|
||||
|
@ -199,7 +200,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
|||
}
|
||||
|
||||
// Extract a scalar component from a pair.
|
||||
(OperandValue::Pair(a_llval, b_llval), &layout::Abi::ScalarPair(ref a, ref b)) => {
|
||||
(OperandValue::Pair(a_llval, b_llval), &Abi::ScalarPair(ref a, ref b)) => {
|
||||
if offset.bytes() == 0 {
|
||||
assert_eq!(field.size, a.value.size(bx.cx()));
|
||||
OperandValue::Immediate(a_llval)
|
||||
|
@ -211,7 +212,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
|||
}
|
||||
|
||||
// `#[repr(simd)]` types are also immediate.
|
||||
(OperandValue::Immediate(llval), &layout::Abi::Vector { .. }) => {
|
||||
(OperandValue::Immediate(llval), &Abi::Vector { .. }) => {
|
||||
OperandValue::Immediate(bx.extract_element(llval, bx.cx().const_usize(i as u64)))
|
||||
}
|
||||
|
||||
|
@ -305,7 +306,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandValue<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);
|
||||
|
|
|
@ -8,8 +8,10 @@ use crate::MemFlags;
|
|||
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::tcx::PlaceTy;
|
||||
use rustc_middle::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyAndLayout, VariantIdx};
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_target::abi::{Abi, Align, DiscriminantKind, FieldsShape, Int};
|
||||
use rustc_target::abi::{LayoutOf, VariantIdx, Variants};
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct PlaceRef<'tcx, V> {
|
||||
|
@ -66,7 +68,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
}
|
||||
|
||||
pub fn len<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 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
// Unions and newtypes only use an offset of 0.
|
||||
let llval = if offset.bytes() == 0 {
|
||||
self.llval
|
||||
} else if let layout::Abi::ScalarPair(ref a, ref b) = self.layout.abi {
|
||||
} else if let Abi::ScalarPair(ref a, ref b) = self.layout.abi {
|
||||
// Offsets have to match either first or second field.
|
||||
assert_eq!(offset, a.value.size(bx.cx()).align_to(b.value.align(bx.cx()).abi));
|
||||
bx.struct_gep(self.llval, 1)
|
||||
|
@ -198,7 +200,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
return bx.cx().const_undef(cast_to);
|
||||
}
|
||||
let (discr_scalar, discr_kind, discr_index) = match self.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
let discr_val = self
|
||||
.layout
|
||||
.ty
|
||||
|
@ -206,7 +208,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
.map_or(index.as_u32() as u128, |discr| discr.val);
|
||||
return bx.cx().const_uint_big(cast_to, discr_val);
|
||||
}
|
||||
layout::Variants::Multiple { ref discr, ref discr_kind, discr_index, .. } => {
|
||||
Variants::Multiple { ref discr, ref discr_kind, discr_index, .. } => {
|
||||
(discr, discr_kind, discr_index)
|
||||
}
|
||||
};
|
||||
|
@ -217,22 +219,18 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
|
||||
// Decode the discriminant (specifically if it's niche-encoded).
|
||||
match *discr_kind {
|
||||
layout::DiscriminantKind::Tag => {
|
||||
DiscriminantKind::Tag => {
|
||||
let signed = match discr_scalar.value {
|
||||
// We use `i1` for bytes that are always `0` or `1`,
|
||||
// e.g., `#[repr(i8)] enum E { A, B }`, but we can't
|
||||
// let LLVM interpret the `i1` as signed, because
|
||||
// then `i1 1` (i.e., `E::B`) is effectively `i8 -1`.
|
||||
layout::Int(_, signed) => !discr_scalar.is_bool() && signed,
|
||||
Int(_, signed) => !discr_scalar.is_bool() && signed,
|
||||
_ => false,
|
||||
};
|
||||
bx.intcast(encoded_discr.immediate(), cast_to, signed)
|
||||
}
|
||||
layout::DiscriminantKind::Niche {
|
||||
dataful_variant,
|
||||
ref niche_variants,
|
||||
niche_start,
|
||||
} => {
|
||||
DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start } => {
|
||||
// Rebase from niche values to discriminants, and check
|
||||
// whether the result is in range for the niche variants.
|
||||
let niche_llty = bx.cx().immediate_backend_type(encoded_discr.layout);
|
||||
|
@ -311,14 +309,10 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
return;
|
||||
}
|
||||
match self.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
assert_eq!(index, variant_index);
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Tag,
|
||||
discr_index,
|
||||
..
|
||||
} => {
|
||||
Variants::Multiple { discr_kind: DiscriminantKind::Tag, discr_index, .. } => {
|
||||
let ptr = self.project_field(bx, discr_index);
|
||||
let to =
|
||||
self.layout.ty.discriminant_for_variant(bx.tcx(), variant_index).unwrap().val;
|
||||
|
@ -328,9 +322,9 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
ptr.align,
|
||||
);
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
Variants::Multiple {
|
||||
discr_kind:
|
||||
layout::DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start },
|
||||
DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start },
|
||||
discr_index,
|
||||
..
|
||||
} => {
|
||||
|
|
|
@ -11,10 +11,11 @@ use rustc_apfloat::{ieee, Float, Round, Status};
|
|||
use rustc_middle::middle::lang_items::ExchangeMallocFnLangItem;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::cast::{CastTy, IntTy};
|
||||
use rustc_middle::ty::layout::{self, HasTyCtxt, LayoutOf};
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
use rustc_middle::ty::{self, adjustment::PointerCast, Instance, Ty, TyCtxt};
|
||||
use rustc_span::source_map::{Span, DUMMY_SP};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_target::abi::{Abi, Int, LayoutOf, Variants};
|
||||
|
||||
use std::{i128, u128};
|
||||
|
||||
|
@ -292,7 +293,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
let r_t_out = CastTy::from_ty(cast.ty).expect("bad output type for cast");
|
||||
let ll_t_in = bx.cx().immediate_backend_type(operand.layout);
|
||||
match operand.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
if let Some(discr) =
|
||||
operand.layout.ty.discriminant_for_variant(bx.tcx(), index)
|
||||
{
|
||||
|
@ -311,13 +312,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
);
|
||||
}
|
||||
}
|
||||
layout::Variants::Multiple { .. } => {}
|
||||
Variants::Multiple { .. } => {}
|
||||
}
|
||||
let llval = operand.immediate();
|
||||
|
||||
let mut signed = false;
|
||||
if let layout::Abi::Scalar(ref scalar) = operand.layout.abi {
|
||||
if let layout::Int(_, s) = scalar.value {
|
||||
if let Abi::Scalar(ref scalar) = operand.layout.abi {
|
||||
if let Int(_, s) = scalar.value {
|
||||
// We use `i1` for bytes that are always `0` or `1`,
|
||||
// e.g., `#[repr(i8)] enum E { A, B }`, but we can't
|
||||
// let LLVM interpret the `i1` as signed, because
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::ModuleCodegen;
|
|||
use rustc_ast::expand::allocator::AllocatorKind;
|
||||
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;
|
||||
|
@ -14,6 +14,7 @@ use rustc_session::{
|
|||
Session,
|
||||
};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
||||
pub use rustc_data_structures::sync::MetadataRef;
|
||||
|
||||
|
|
|
@ -12,8 +12,9 @@ use crate::mir::operand::OperandRef;
|
|||
use crate::mir::place::PlaceRef;
|
||||
use crate::MemFlags;
|
||||
|
||||
use rustc_middle::ty::layout::{Align, HasParamEnv, Size};
|
||||
use rustc_middle::ty::layout::HasParamEnv;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_target::abi::{Align, Size};
|
||||
use rustc_target::spec::HasTargetSpec;
|
||||
|
||||
use std::iter::TrustedLen;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3,10 +3,10 @@ use crate::mir::debuginfo::{FunctionDebugContext, VariableKind};
|
|||
use rustc_ast::ast::Name;
|
||||
use rustc_hir::def_id::CrateNum;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::layout::Size;
|
||||
use rustc_middle::ty::{Instance, Ty};
|
||||
use rustc_span::{SourceFile, Span};
|
||||
use rustc_target::abi::call::FnAbi;
|
||||
use rustc_target::abi::Size;
|
||||
|
||||
pub trait DebugInfoMethods<'tcx>: BackendTypes {
|
||||
fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3,10 +3,11 @@ use super::Backend;
|
|||
use super::HasCodegen;
|
||||
use crate::common::TypeKind;
|
||||
use crate::mir::place::PlaceRef;
|
||||
use rustc_middle::ty::layout::{self, TyAndLayout};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg};
|
||||
use rustc_target::abi::Integer;
|
||||
|
||||
// This depends on `Backend` and not `BackendTypes`, because consumers will probably want to use
|
||||
// `LayoutOf` or `HasTyCtxt`. This way, they don't have to add a constraint on it themselves.
|
||||
|
@ -53,8 +54,8 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn type_from_integer(&self, i: layout::Integer) -> Self::Type {
|
||||
use rustc_middle::ty::layout::Integer::*;
|
||||
fn type_from_integer(&self, i: Integer) -> Self::Type {
|
||||
use Integer::*;
|
||||
match i {
|
||||
I8 => self.type_i8(),
|
||||
I16 => self.type_i16(),
|
||||
|
|
|
@ -36,12 +36,13 @@ use rustc_hir::def_id::DefId;
|
|||
use rustc_hir::{GenericParamKind, PatKind};
|
||||
use rustc_hir::{HirIdSet, Node};
|
||||
use rustc_middle::lint::LintDiagnosticBuilder;
|
||||
use rustc_middle::ty::{self, layout::VariantIdx, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_session::lint::FutureIncompatibleInfo;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use rustc_trait_selection::traits::misc::can_type_implement_copy;
|
||||
|
||||
use crate::nonstandard_style::{method_context, MethodLateContext};
|
||||
|
|
|
@ -29,12 +29,13 @@ use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
|||
use rustc_middle::lint::LintDiagnosticBuilder;
|
||||
use rustc_middle::middle::privacy::AccessLevels;
|
||||
use rustc_middle::middle::stability;
|
||||
use rustc_middle::ty::layout::{LayoutError, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{LayoutError, TyAndLayout};
|
||||
use rustc_middle::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt};
|
||||
use rustc_session::lint::{add_elided_lifetime_in_path_suggestion, BuiltinLintDiagnostics};
|
||||
use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
||||
use std::slice;
|
||||
|
||||
|
|
|
@ -10,12 +10,13 @@ use rustc_hir::def_id::DefId;
|
|||
use rustc_hir::{is_range_literal, ExprKind, Node};
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::mir::interpret::{sign_extend, truncate};
|
||||
use rustc_middle::ty::layout::{self, IntegerExt, LayoutOf, SizeSkeleton, VariantIdx};
|
||||
use rustc_middle::ty::layout::{IntegerExt, SizeSkeleton};
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
|
||||
use rustc_span::source_map;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{DiscriminantKind, Integer, LayoutOf, VariantIdx, Variants};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use log::debug;
|
||||
|
@ -150,7 +151,7 @@ fn report_bin_hex_error(
|
|||
val: u128,
|
||||
negative: bool,
|
||||
) {
|
||||
let size = layout::Integer::from_attr(&cx.tcx, ty).size();
|
||||
let size = Integer::from_attr(&cx.tcx, ty).size();
|
||||
cx.struct_span_lint(OVERFLOWING_LITERALS, expr.span, |lint| {
|
||||
let (t, actually) = match ty {
|
||||
attr::IntType::SignedInt(t) => {
|
||||
|
@ -1034,8 +1035,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
|
|||
| Err(ty::layout::LayoutError::SizeOverflow(_)) => return,
|
||||
};
|
||||
let (variants, tag) = match layout.variants {
|
||||
layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Tag,
|
||||
Variants::Multiple {
|
||||
discr_kind: DiscriminantKind::Tag,
|
||||
ref discr,
|
||||
ref variants,
|
||||
..
|
||||
|
|
|
@ -29,13 +29,13 @@ 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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -7,14 +7,12 @@ use std::ops::{Deref, DerefMut, Range};
|
|||
|
||||
use rustc_ast::ast::Mutability;
|
||||
use rustc_data_structures::sorted_map::SortedMap;
|
||||
use rustc_target::abi::HasDataLayout;
|
||||
use rustc_target::abi::{Align, HasDataLayout, Size};
|
||||
|
||||
use super::{
|
||||
read_target_uint, write_target_uint, AllocId, InterpResult, Pointer, Scalar, ScalarMaybeUndef,
|
||||
};
|
||||
|
||||
use crate::ty::layout::{Align, Size};
|
||||
|
||||
// NOTE: When adding new fields, make sure to adjust the `Snapshot` impl in
|
||||
// `src/librustc_mir/interpret/snapshot.rs`.
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::{AllocId, CheckInAllocMsg, Pointer, RawConst, ScalarMaybeUndef};
|
||||
|
||||
use crate::mir::interpret::ConstValue;
|
||||
use crate::ty::layout::{Align, LayoutError, Size};
|
||||
use crate::ty::layout::LayoutError;
|
||||
use crate::ty::query::TyCtxtAt;
|
||||
use crate::ty::tls;
|
||||
use crate::ty::{self, layout, Ty};
|
||||
|
@ -14,6 +14,7 @@ use rustc_hir::definitions::DefPathData;
|
|||
use rustc_macros::HashStable;
|
||||
use rustc_session::CtfeBacktrace;
|
||||
use rustc_span::{def_id::DefId, Pos, Span};
|
||||
use rustc_target::abi::{Align, Size};
|
||||
use std::{any::Any, fmt, mem};
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable)]
|
||||
|
|
|
@ -109,10 +109,10 @@ use rustc_data_structures::tiny_list::TinyList;
|
|||
use rustc_hir::def_id::DefId;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_serialize::{Decodable, Encodable, Encoder};
|
||||
use rustc_target::abi::{Endian, Size};
|
||||
|
||||
use crate::mir;
|
||||
use crate::ty::codec::TyDecoder;
|
||||
use crate::ty::layout::{self, Size};
|
||||
use crate::ty::subst::GenericArgKind;
|
||||
use crate::ty::{self, Instance, Ty, TyCtxt};
|
||||
|
||||
|
@ -521,22 +521,22 @@ impl<'tcx> AllocMap<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn write_target_uint(
|
||||
endianness: layout::Endian,
|
||||
endianness: Endian,
|
||||
mut target: &mut [u8],
|
||||
data: u128,
|
||||
) -> Result<(), io::Error> {
|
||||
let len = target.len();
|
||||
match endianness {
|
||||
layout::Endian::Little => target.write_uint128::<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()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use super::{AllocId, InterpResult};
|
||||
|
||||
use crate::ty::layout::{self, HasDataLayout, Size};
|
||||
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_target::abi::{HasDataLayout, Size};
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::{self, Display};
|
||||
|
@ -37,7 +36,7 @@ impl Display for CheckInAllocMsg {
|
|||
// Pointer arithmetic
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub trait PointerArithmetic: layout::HasDataLayout {
|
||||
pub trait PointerArithmetic: HasDataLayout {
|
||||
// These are not supposed to be overridden.
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -100,7 +99,7 @@ pub trait PointerArithmetic: layout::HasDataLayout {
|
|||
}
|
||||
}
|
||||
|
||||
impl<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
|
||||
|
|
|
@ -6,12 +6,9 @@ use rustc_apfloat::{
|
|||
Float,
|
||||
};
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_target::abi::TargetDataLayout;
|
||||
use rustc_target::abi::{HasDataLayout, Size, TargetDataLayout};
|
||||
|
||||
use crate::ty::{
|
||||
layout::{HasDataLayout, Size},
|
||||
ParamEnv, Ty, TyCtxt,
|
||||
};
|
||||
use crate::ty::{ParamEnv, Ty, TyCtxt};
|
||||
|
||||
use super::{sign_extend, truncate, AllocId, Allocation, InterpResult, Pointer, PointerArithmetic};
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::mir::interpret::{GlobalAlloc, Scalar};
|
|||
use crate::mir::visit::MirVisitable;
|
||||
use crate::ty::adjustment::PointerCast;
|
||||
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
||||
use crate::ty::layout::VariantIdx;
|
||||
use crate::ty::print::{FmtPrinter, Printer};
|
||||
use crate::ty::subst::{Subst, SubstsRef};
|
||||
use crate::ty::{
|
||||
|
@ -16,6 +15,7 @@ use rustc_hir as hir;
|
|||
use rustc_hir::def::{CtorKind, Namespace};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{self, GeneratorKind};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
|
||||
use polonius_engine::Atom;
|
||||
pub use rustc_ast::ast::Mutability;
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -738,7 +738,7 @@ rustc_queries! {
|
|||
|
||||
query layout_raw(
|
||||
env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
|
||||
) -> Result<&'tcx ty::layout::Layout, ty::layout::LayoutError<'tcx>> {
|
||||
) -> Result<&'tcx rustc_target::abi::Layout, ty::layout::LayoutError<'tcx>> {
|
||||
desc { "computing layout of `{}`", env.value }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ use crate::mir::{
|
|||
};
|
||||
use crate::traits;
|
||||
use crate::traits::{Clause, Clauses, Goal, GoalKind, Goals};
|
||||
use crate::ty::layout::{Layout, TargetDataLayout, VariantIdx};
|
||||
use crate::ty::query;
|
||||
use crate::ty::steal::Steal;
|
||||
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
|
||||
|
@ -65,6 +64,7 @@ use rustc_session::Session;
|
|||
use rustc_span::source_map::MultiSpan;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{Layout, TargetDataLayout, VariantIdx};
|
||||
use rustc_target::spec::abi;
|
||||
|
||||
use smallvec::SmallVec;
|
||||
|
|
|
@ -15,7 +15,7 @@ use rustc_span::DUMMY_SP;
|
|||
use rustc_target::abi::call::{
|
||||
ArgAbi, ArgAttribute, ArgAttributes, Conv, FnAbi, PassMode, Reg, RegKind,
|
||||
};
|
||||
pub use rustc_target::abi::*;
|
||||
use rustc_target::abi::*;
|
||||
use rustc_target::spec::{abi::Abi as SpecAbi, HasTargetSpec, PanicStrategy};
|
||||
|
||||
use std::cmp;
|
||||
|
|
|
@ -18,7 +18,6 @@ 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;
|
||||
|
@ -43,7 +42,7 @@ use rustc_session::DataTypeKind;
|
|||
use rustc_span::hygiene::ExpnId;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::Align;
|
||||
use rustc_target::abi::{Align, VariantIdx};
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::{self, Ordering};
|
||||
|
@ -2078,7 +2077,7 @@ pub struct AdtDef {
|
|||
/// The `DefId` of the struct, enum or union item.
|
||||
pub did: DefId,
|
||||
/// Variants of the ADT. If this is a struct or union, then there will be a single variant.
|
||||
pub variants: IndexVec<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.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::middle::cstore::{ExternCrate, ExternCrateSource};
|
||||
use crate::middle::region;
|
||||
use crate::mir::interpret::{sign_extend, truncate, AllocId, ConstValue, Pointer, Scalar};
|
||||
use crate::ty::layout::{Integer, IntegerExt, Size};
|
||||
use crate::ty::layout::IntegerExt;
|
||||
use crate::ty::subst::{GenericArg, GenericArgKind, Subst};
|
||||
use crate::ty::{self, DefIdTree, ParamConst, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_apfloat::ieee::{Double, Single};
|
||||
|
@ -13,6 +13,7 @@ use rustc_hir::def::{DefKind, Namespace};
|
|||
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
use rustc_target::abi::{Integer, Size};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use std::cell::Cell;
|
||||
|
|
|
@ -254,7 +254,7 @@ CloneTypeFoldableAndLiftImpls! {
|
|||
(),
|
||||
bool,
|
||||
usize,
|
||||
crate::ty::layout::VariantIdx,
|
||||
::rustc_target::abi::VariantIdx,
|
||||
u64,
|
||||
String,
|
||||
crate::middle::region::Scope,
|
||||
|
|
|
@ -10,7 +10,6 @@ use crate::middle::region;
|
|||
use crate::mir::interpret::ConstValue;
|
||||
use crate::mir::interpret::{LitToConstInput, Scalar};
|
||||
use crate::mir::Promoted;
|
||||
use crate::ty::layout::VariantIdx;
|
||||
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
|
||||
use crate::ty::{
|
||||
self, AdtDef, DefIdTree, Discr, Ty, TyCtxt, TypeFlags, TypeFoldable, WithConstness,
|
||||
|
@ -24,6 +23,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
|
|||
use rustc_index::vec::Idx;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
use rustc_target::abi::{Size, VariantIdx};
|
||||
use rustc_target::spec::abi;
|
||||
use smallvec::SmallVec;
|
||||
use std::borrow::Cow;
|
||||
|
@ -2501,7 +2501,7 @@ impl<'tcx> ConstKind<'tcx> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn try_to_bits(&self, size: ty::layout::Size) -> Option<u128> {
|
||||
pub fn try_to_bits(&self, size: Size) -> Option<u128> {
|
||||
if let ConstKind::Value(val) = self { val.try_to_bits(size) } else { None }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
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::*;
|
||||
|
@ -19,7 +19,7 @@ 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};
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ use rustc_middle::mir::{
|
|||
AggregateKind, Constant, Field, Local, LocalInfo, LocalKind, Location, Operand, Place,
|
||||
PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind,
|
||||
};
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::print::Print;
|
||||
use rustc_middle::ty::{self, DefIdTree, Ty, TyCtxt};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::VariantIdx;
|
||||
|
||||
use super::borrow_set::BorrowData;
|
||||
use super::MirBorrowckCtxt;
|
||||
|
|
|
@ -24,13 +24,13 @@ use rustc_middle::mir::*;
|
|||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::cast::CastTy;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::subst::{GenericArgKind, Subst, SubstsRef, UserSubsts};
|
||||
use rustc_middle::ty::{
|
||||
self, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, RegionVid, ToPolyTraitRef, Ty,
|
||||
TyCtxt, UserType, UserTypeAnnotationIndex,
|
||||
};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use rustc_trait_selection::infer::InferCtxtExt as _;
|
||||
use rustc_trait_selection::opaque_types::{GenerateMemberConstraints, InferCtxtExt};
|
||||
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
|
||||
|
|
|
@ -9,8 +9,9 @@ use rustc_hir::def::DefKind;
|
|||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{ConstEvalErr, ErrorHandled};
|
||||
use rustc_middle::traits::Reveal;
|
||||
use rustc_middle::ty::{self, layout, layout::LayoutOf, subst::Subst, TyCtxt};
|
||||
use rustc_middle::ty::{self, subst::Subst, TyCtxt};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_target::abi::{Abi, LayoutOf};
|
||||
use std::convert::TryInto;
|
||||
|
||||
pub fn note_on_undefined_behavior_error() -> &'static str {
|
||||
|
@ -105,8 +106,8 @@ pub(super) fn op_to_const<'tcx>(
|
|||
// the usual cases of extracting e.g. a `usize`, without there being a real use case for the
|
||||
// `Undef` situation.
|
||||
let try_as_immediate = match op.layout.abi {
|
||||
layout::Abi::Scalar(..) => true,
|
||||
layout::Abi::ScalarPair(..) => match op.layout.ty.kind {
|
||||
Abi::Scalar(..) => true,
|
||||
Abi::ScalarPair(..) => match op.layout.ty.kind {
|
||||
ty::Ref(_, inner, _) => match inner.kind {
|
||||
ty::Slice(elem) => elem == ecx.tcx.types.u8,
|
||||
ty::Str => true,
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ use rustc_hir::def_id::DefId;
|
|||
use rustc_index::bit_set::{BitSet, HybridBitSet};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_middle::mir::{self, BasicBlock, Location};
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
|
||||
mod cursor;
|
||||
mod engine;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ use rustc_ast::ast::FloatTy;
|
|||
use rustc_middle::mir::interpret::{InterpResult, PointerArithmetic, Scalar};
|
||||
use rustc_middle::mir::CastKind;
|
||||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::layout::{self, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::{self, Ty, TypeAndMut, TypeFoldable};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_target::abi::LayoutOf;
|
||||
use rustc_target::abi::{LayoutOf, Size, Variants};
|
||||
|
||||
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
pub fn cast(
|
||||
|
@ -132,7 +132,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
|
||||
// Handle cast from a univariant (ZST) enum.
|
||||
match src.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
if let Some(discr) = src.layout.ty.discriminant_for_variant(*self.tcx, index) {
|
||||
assert!(src.layout.is_zst());
|
||||
let discr_layout = self.layout_of(discr.ty)?;
|
||||
|
@ -141,7 +141,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
.into());
|
||||
}
|
||||
}
|
||||
layout::Variants::Multiple { .. } => {}
|
||||
Variants::Multiple { .. } => {}
|
||||
}
|
||||
|
||||
// Handle casting the metadata away from a fat pointer.
|
||||
|
|
|
@ -13,11 +13,12 @@ use rustc_middle::mir;
|
|||
use rustc_middle::mir::interpret::{
|
||||
sign_extend, truncate, AllocId, FrameInfo, GlobalId, InterpResult, Pointer, Scalar,
|
||||
};
|
||||
use rustc_middle::ty::layout::{self, Align, HasDataLayout, LayoutOf, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{self, TyAndLayout};
|
||||
use rustc_middle::ty::query::TyCtxtAt;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_span::source_map::DUMMY_SP;
|
||||
use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Size, TargetDataLayout};
|
||||
|
||||
use super::{
|
||||
Immediate, MPlaceTy, Machine, MemPlace, MemPlaceMeta, Memory, OpTy, Operand, Place, PlaceTy,
|
||||
|
@ -173,7 +174,7 @@ impl<'mir, 'tcx, Tag, Extra> Frame<'mir, 'tcx, Tag, Extra> {
|
|||
|
||||
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout for InterpCx<'mir, 'tcx, M> {
|
||||
#[inline]
|
||||
fn data_layout(&self) -> &layout::TargetDataLayout {
|
||||
fn data_layout(&self) -> &TargetDataLayout {
|
||||
&self.tcx.data_layout
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ use rustc_middle::mir::{
|
|||
BinOp,
|
||||
};
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::layout::{LayoutOf, Primitive, Size};
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_target::abi::{Abi, LayoutOf as _, Primitive, Size};
|
||||
|
||||
use super::{ImmTy, InterpCx, Machine, OpTy, PlaceTy};
|
||||
|
||||
|
@ -134,7 +134,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
let val = self.read_scalar(args[0])?.not_undef()?;
|
||||
let bits = self.force_bits(val, layout_of.size)?;
|
||||
let kind = match layout_of.abi {
|
||||
ty::layout::Abi::Scalar(ref scalar) => scalar.value,
|
||||
Abi::Scalar(ref scalar) => scalar.value,
|
||||
_ => bug!("{} called on invalid type {:?}", intrinsic_name, ty),
|
||||
};
|
||||
let (nonzero, intrinsic_name) = match intrinsic_name {
|
||||
|
|
|
@ -11,11 +11,10 @@ use std::collections::VecDeque;
|
|||
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,
|
||||
|
|
|
@ -10,12 +10,12 @@ pub use rustc_middle::mir::interpret::ScalarMaybeUndef;
|
|||
use rustc_middle::mir::interpret::{
|
||||
sign_extend, truncate, AllocId, ConstValue, GlobalId, InterpResult, Pointer, Scalar,
|
||||
};
|
||||
use rustc_middle::ty::layout::{
|
||||
self, HasDataLayout, IntegerExt, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc_middle::ty::layout::{IntegerExt, PrimitiveExt, TyAndLayout};
|
||||
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter, Printer};
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_middle::{mir, ty};
|
||||
use rustc_target::abi::{Abi, DiscriminantKind, HasDataLayout, Integer, LayoutOf, Size};
|
||||
use rustc_target::abi::{VariantIdx, Variants};
|
||||
use std::fmt::Write;
|
||||
|
||||
/// An `Immediate` represents a single immediate self-contained Rust value.
|
||||
|
@ -266,7 +266,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
};
|
||||
|
||||
match mplace.layout.abi {
|
||||
layout::Abi::Scalar(..) => {
|
||||
Abi::Scalar(..) => {
|
||||
let scalar = self.memory.get_raw(ptr.alloc_id)?.read_scalar(
|
||||
self,
|
||||
ptr,
|
||||
|
@ -274,7 +274,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
)?;
|
||||
Ok(Some(ImmTy { imm: scalar.into(), layout: mplace.layout }))
|
||||
}
|
||||
layout::Abi::ScalarPair(ref a, ref b) => {
|
||||
Abi::ScalarPair(ref a, ref b) => {
|
||||
// We checked `ptr_align` above, so all fields will have the alignment they need.
|
||||
// We would anyway check against `ptr_align.restrict_for_offset(b_offset)`,
|
||||
// which `ptr.offset(b_offset)` cannot possibly fail to satisfy.
|
||||
|
@ -587,7 +587,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
trace!("read_discriminant_value {:#?}", rval.layout);
|
||||
|
||||
let (discr_layout, discr_kind, discr_index) = match rval.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
let discr_val = rval
|
||||
.layout
|
||||
.ty
|
||||
|
@ -595,12 +595,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
.map_or(u128::from(index.as_u32()), |discr| discr.val);
|
||||
return Ok((discr_val, index));
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
discr: ref discr_layout,
|
||||
ref discr_kind,
|
||||
discr_index,
|
||||
..
|
||||
} => (discr_layout, discr_kind, discr_index),
|
||||
Variants::Multiple { discr: ref discr_layout, ref discr_kind, discr_index, .. } => {
|
||||
(discr_layout, discr_kind, discr_index)
|
||||
}
|
||||
};
|
||||
|
||||
// read raw discriminant value
|
||||
|
@ -610,7 +607,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
trace!("discr value: {:?}", raw_discr);
|
||||
// post-process
|
||||
Ok(match *discr_kind {
|
||||
layout::DiscriminantKind::Tag => {
|
||||
DiscriminantKind::Tag => {
|
||||
let bits_discr = raw_discr
|
||||
.not_undef()
|
||||
.and_then(|raw_discr| self.force_bits(raw_discr, discr_val.layout.size))
|
||||
|
@ -627,7 +624,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
.expect("tagged layout corresponds to adt")
|
||||
.repr
|
||||
.discr_type();
|
||||
let size = layout::Integer::from_attr(self, discr_ty).size();
|
||||
let size = Integer::from_attr(self, discr_ty).size();
|
||||
truncate(sexted, size)
|
||||
} else {
|
||||
bits_discr
|
||||
|
@ -648,11 +645,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
.ok_or_else(|| err_ub!(InvalidDiscriminant(raw_discr.erase_tag())))?;
|
||||
(real_discr, index.0)
|
||||
}
|
||||
layout::DiscriminantKind::Niche {
|
||||
dataful_variant,
|
||||
ref niche_variants,
|
||||
niche_start,
|
||||
} => {
|
||||
DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start } => {
|
||||
let variants_start = niche_variants.start().as_u32();
|
||||
let variants_end = niche_variants.end().as_u32();
|
||||
let raw_discr = raw_discr
|
||||
|
|
|
@ -4,11 +4,8 @@ use rustc_apfloat::Float;
|
|||
use rustc_ast::ast::FloatTy;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{InterpResult, Scalar};
|
||||
use rustc_middle::ty::{
|
||||
self,
|
||||
layout::{LayoutOf, TyAndLayout},
|
||||
Ty,
|
||||
};
|
||||
use rustc_middle::ty::{self, layout::TyAndLayout, Ty};
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
||||
use super::{ImmTy, Immediate, InterpCx, Machine, PlaceTy};
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ use std::hash::Hash;
|
|||
use rustc_macros::HashStable;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::truncate;
|
||||
use rustc_middle::ty::layout::{
|
||||
self, Align, HasDataLayout, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc_middle::ty::layout::{PrimitiveExt, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_target::abi::{Abi, Align, DiscriminantKind, FieldsShape};
|
||||
use rustc_target::abi::{HasDataLayout, LayoutOf, Size, VariantIdx, Variants};
|
||||
|
||||
use super::{
|
||||
AllocId, AllocMap, Allocation, AllocationExtra, ImmTy, Immediate, InterpCx, InterpResult,
|
||||
|
@ -219,7 +219,7 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
|
|||
// Go through the layout. There are lots of types that support a length,
|
||||
// e.g., SIMD types.
|
||||
match self.layout.fields {
|
||||
layout::FieldsShape::Array { count, .. } => Ok(count),
|
||||
FieldsShape::Array { count, .. } => Ok(count),
|
||||
_ => bug!("len not supported on sized type {:?}", self.layout.ty),
|
||||
}
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ where
|
|||
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
|
||||
// Not using the layout method because we want to compute on u64
|
||||
match base.layout.fields {
|
||||
layout::FieldsShape::Array { stride, .. } => {
|
||||
FieldsShape::Array { stride, .. } => {
|
||||
let len = base.len(self)?;
|
||||
if index >= len {
|
||||
// This can only be reached in ConstProp and non-rustc-MIR.
|
||||
|
@ -463,7 +463,7 @@ where
|
|||
{
|
||||
let len = base.len(self)?; // also asserts that we have a type where this makes sense
|
||||
let stride = match base.layout.fields {
|
||||
layout::FieldsShape::Array { stride, .. } => stride,
|
||||
FieldsShape::Array { stride, .. } => stride,
|
||||
_ => bug!("mplace_array_fields: expected an array layout"),
|
||||
};
|
||||
let layout = base.layout.field(self, 0)?;
|
||||
|
@ -493,7 +493,7 @@ where
|
|||
// Not using layout method because that works with usize, and does not work with slices
|
||||
// (that have count 0 in their layout).
|
||||
let from_offset = match base.layout.fields {
|
||||
layout::FieldsShape::Array { stride, .. } => stride * from, // `Size` multiplication is checked
|
||||
FieldsShape::Array { stride, .. } => stride * from, // `Size` multiplication is checked
|
||||
_ => bug!("Unexpected layout of index access: {:#?}", base.layout),
|
||||
};
|
||||
|
||||
|
@ -802,7 +802,7 @@ where
|
|||
match value {
|
||||
Immediate::Scalar(scalar) => {
|
||||
match dest.layout.abi {
|
||||
layout::Abi::Scalar(_) => {} // fine
|
||||
Abi::Scalar(_) => {} // fine
|
||||
_ => {
|
||||
bug!("write_immediate_to_mplace: invalid Scalar layout: {:#?}", dest.layout)
|
||||
}
|
||||
|
@ -819,7 +819,7 @@ where
|
|||
// We would anyway check against `ptr_align.restrict_for_offset(b_offset)`,
|
||||
// which `ptr.offset(b_offset)` cannot possibly fail to satisfy.
|
||||
let (a, b) = match dest.layout.abi {
|
||||
layout::Abi::ScalarPair(ref a, ref b) => (&a.value, &b.value),
|
||||
Abi::ScalarPair(ref a, ref b) => (&a.value, &b.value),
|
||||
_ => bug!(
|
||||
"write_immediate_to_mplace: invalid ScalarPair layout: {:#?}",
|
||||
dest.layout
|
||||
|
@ -1067,11 +1067,11 @@ where
|
|||
}
|
||||
|
||||
match dest.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
assert_eq!(index, variant_index);
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Tag,
|
||||
Variants::Multiple {
|
||||
discr_kind: DiscriminantKind::Tag,
|
||||
discr: ref discr_layout,
|
||||
discr_index,
|
||||
..
|
||||
|
@ -1091,9 +1091,9 @@ where
|
|||
let discr_dest = self.place_field(dest, discr_index)?;
|
||||
self.write_scalar(Scalar::from_uint(discr_val, size), discr_dest)?;
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
Variants::Multiple {
|
||||
discr_kind:
|
||||
layout::DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start },
|
||||
DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start },
|
||||
discr: ref discr_layout,
|
||||
discr_index,
|
||||
..
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use std::borrow::Cow;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use rustc_middle::ty::layout::{self, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::Instance;
|
||||
use rustc_middle::{mir, ty};
|
||||
use rustc_target::abi::{self, LayoutOf as _};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use super::{
|
||||
|
@ -142,12 +143,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// Different valid ranges are okay (once we enforce validity,
|
||||
// that will take care to make it UB to leave the range, just
|
||||
// like for transmute).
|
||||
(layout::Abi::Scalar(ref caller), layout::Abi::Scalar(ref callee)) => {
|
||||
(abi::Abi::Scalar(ref caller), abi::Abi::Scalar(ref callee)) => {
|
||||
caller.value == callee.value
|
||||
}
|
||||
(
|
||||
layout::Abi::ScalarPair(ref caller1, ref caller2),
|
||||
layout::Abi::ScalarPair(ref callee1, ref callee2),
|
||||
abi::Abi::ScalarPair(ref caller1, ref caller2),
|
||||
abi::Abi::ScalarPair(ref callee1, ref callee2),
|
||||
) => caller1.value == callee1.value && caller2.value == callee2.value,
|
||||
// Be conservative
|
||||
_ => false,
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
|
|
@ -11,8 +11,9 @@ use std::ops::RangeInclusive;
|
|||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir as hir;
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::layout::{self, LayoutOf, TyAndLayout, VariantIdx};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_target::abi::{Abi, LayoutOf, Scalar, VariantIdx, Variants};
|
||||
|
||||
use std::hash::Hash;
|
||||
|
||||
|
@ -180,7 +181,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
|
|||
fn aggregate_field_path_elem(&mut self, layout: TyAndLayout<'tcx>, field: usize) -> PathElem {
|
||||
// First, check if we are projecting to a variant.
|
||||
match layout.variants {
|
||||
layout::Variants::Multiple { discr_index, .. } => {
|
||||
Variants::Multiple { discr_index, .. } => {
|
||||
if discr_index == field {
|
||||
return match layout.ty.kind {
|
||||
ty::Adt(def, ..) if def.is_enum() => PathElem::EnumTag,
|
||||
|
@ -189,7 +190,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
|
|||
};
|
||||
}
|
||||
}
|
||||
layout::Variants::Single { .. } => {}
|
||||
Variants::Single { .. } => {}
|
||||
}
|
||||
|
||||
// Now we know we are projecting to a field, so figure out which one.
|
||||
|
@ -226,11 +227,11 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
|
|||
ty::Adt(def, ..) if def.is_enum() => {
|
||||
// we might be projecting *to* a variant, or to a field *in* a variant.
|
||||
match layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
// Inside a variant
|
||||
PathElem::Field(def.variants[index].fields[field].ident.name)
|
||||
}
|
||||
layout::Variants::Multiple { .. } => bug!("we handled variants above"),
|
||||
Variants::Multiple { .. } => bug!("we handled variants above"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -539,7 +540,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
|
|||
fn visit_scalar(
|
||||
&mut self,
|
||||
op: OpTy<'tcx, M::PointerTag>,
|
||||
scalar_layout: &layout::Scalar,
|
||||
scalar_layout: &Scalar,
|
||||
) -> InterpResult<'tcx> {
|
||||
let value = self.ecx.read_scalar(op)?;
|
||||
let valid_range = &scalar_layout.valid_range;
|
||||
|
@ -685,22 +686,22 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
|
|||
// scalars, we do the same check on every "level" (e.g., first we check
|
||||
// MyNewtype and then the scalar in there).
|
||||
match op.layout.abi {
|
||||
layout::Abi::Uninhabited => {
|
||||
Abi::Uninhabited => {
|
||||
throw_validation_failure!(
|
||||
format_args!("a value of uninhabited type {:?}", op.layout.ty),
|
||||
self.path
|
||||
);
|
||||
}
|
||||
layout::Abi::Scalar(ref scalar_layout) => {
|
||||
Abi::Scalar(ref scalar_layout) => {
|
||||
self.visit_scalar(op, scalar_layout)?;
|
||||
}
|
||||
layout::Abi::ScalarPair { .. } | layout::Abi::Vector { .. } => {
|
||||
Abi::ScalarPair { .. } | Abi::Vector { .. } => {
|
||||
// These have fields that we already visited above, so we already checked
|
||||
// all their scalar-level restrictions.
|
||||
// There is also no equivalent to `rustc_layout_scalar_valid_range_start`
|
||||
// that would make skipping them here an issue.
|
||||
}
|
||||
layout::Abi::Aggregate { .. } => {
|
||||
Abi::Aggregate { .. } => {
|
||||
// Nothing to do.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
use rustc_middle::mir::interpret::InterpResult;
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::layout::{self, TyAndLayout, VariantIdx};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_target::abi::{FieldsShape, VariantIdx, Variants};
|
||||
|
||||
use super::{InterpCx, MPlaceTy, Machine, OpTy};
|
||||
|
||||
|
@ -207,10 +208,10 @@ macro_rules! make_value_visitor {
|
|||
|
||||
// Visit the fields of this value.
|
||||
match v.layout().fields {
|
||||
layout::FieldsShape::Union(fields) => {
|
||||
FieldsShape::Union(fields) => {
|
||||
self.visit_union(v, fields)?;
|
||||
},
|
||||
layout::FieldsShape::Arbitrary { ref offsets, .. } => {
|
||||
FieldsShape::Arbitrary { ref offsets, .. } => {
|
||||
// FIXME: We collect in a vec because otherwise there are lifetime
|
||||
// errors: Projecting to a field needs access to `ecx`.
|
||||
let fields: Vec<InterpResult<'tcx, Self::V>> =
|
||||
|
@ -220,7 +221,7 @@ macro_rules! make_value_visitor {
|
|||
.collect();
|
||||
self.visit_aggregate(v, fields.into_iter())?;
|
||||
},
|
||||
layout::FieldsShape::Array { .. } => {
|
||||
FieldsShape::Array { .. } => {
|
||||
// Let's get an mplace first.
|
||||
let mplace = v.to_op(self.ecx())?.assert_mem_place(self.ecx());
|
||||
// Now we can go over all the fields.
|
||||
|
@ -237,7 +238,7 @@ macro_rules! make_value_visitor {
|
|||
match v.layout().variants {
|
||||
// If this is a multi-variant layout, find the right variant and proceed
|
||||
// with *its* fields.
|
||||
layout::Variants::Multiple { .. } => {
|
||||
Variants::Multiple { .. } => {
|
||||
let op = v.to_op(self.ecx())?;
|
||||
let idx = self.ecx().read_discriminant(op)?.1;
|
||||
let inner = v.project_downcast(self.ecx(), idx)?;
|
||||
|
@ -246,7 +247,7 @@ macro_rules! make_value_visitor {
|
|||
self.visit_variant(v, idx, inner)
|
||||
}
|
||||
// For single-variant layouts, we already did anything there is to do.
|
||||
layout::Variants::Single { .. } => Ok(())
|
||||
Variants::Single { .. } => Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
|
|
@ -19,13 +19,12 @@ use rustc_middle::mir::{
|
|||
SourceInfo, SourceScope, SourceScopeData, Statement, StatementKind, Terminator, TerminatorKind,
|
||||
UnOp, RETURN_PLACE,
|
||||
};
|
||||
use rustc_middle::ty::layout::{
|
||||
HasDataLayout, HasTyCtxt, LayoutError, LayoutOf, Size, TargetDataLayout, TyAndLayout,
|
||||
};
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutError, TyAndLayout};
|
||||
use rustc_middle::ty::subst::{InternalSubsts, Subst};
|
||||
use rustc_middle::ty::{self, ConstKind, Instance, ParamEnv, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::{def_id::DefId, Span};
|
||||
use rustc_target::abi::{HasDataLayout, LayoutOf, Size, TargetDataLayout};
|
||||
use rustc_trait_selection::traits;
|
||||
|
||||
use crate::const_eval::error_to_const_error;
|
||||
|
|
|
@ -13,9 +13,9 @@ use rustc_data_structures::fx::FxHashMap;
|
|||
use rustc_hir as hir;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use std::fmt;
|
||||
|
||||
pub struct ElaborateDrops;
|
||||
|
|
|
@ -63,10 +63,10 @@ use rustc_index::bit_set::{BitMatrix, BitSet};
|
|||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::GeneratorSubsts;
|
||||
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use std::borrow::Cow;
|
||||
use std::iter;
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ use rustc_middle::mir::{
|
|||
BasicBlock, BasicBlockData, Body, BodyAndCache, Local, Operand, Rvalue, StatementKind,
|
||||
TerminatorKind,
|
||||
};
|
||||
use rustc_middle::ty::layout::{Abi, TyAndLayout, Variants};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use rustc_target::abi::{Abi, Variants};
|
||||
|
||||
pub struct UninhabitedEnumBranching;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ 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;
|
||||
|
|
|
@ -9,7 +9,8 @@ use rustc_middle::mir::interpret::{
|
|||
};
|
||||
use rustc_middle::mir::visit::Visitor;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{self, layout::Size, TyCtxt, TypeFoldable, TypeVisitor};
|
||||
use rustc_middle::ty::{self, TyCtxt, TypeFoldable, TypeVisitor};
|
||||
use rustc_target::abi::Size;
|
||||
use std::collections::BTreeSet;
|
||||
use std::fmt::Display;
|
||||
use std::fmt::Write as _;
|
||||
|
|
|
@ -16,9 +16,9 @@ use rustc_hir::HirId;
|
|||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_middle::middle::region;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
|
||||
// helper functions, broken out by category:
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -9,14 +9,14 @@ use crate::build::matches::{Candidate, MatchPair, Test, TestKind};
|
|||
use crate::build::Builder;
|
||||
use crate::hair::pattern::compare_const_vals;
|
||||
use crate::hair::*;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::util::IntTypeExt;
|
||||
use rustc_middle::ty::{self, adjustment::PointerCast, Ty};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::RangeEnd;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::util::IntTypeExt;
|
||||
use rustc_middle::ty::{self, adjustment::PointerCast, Ty};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_target::abi::VariantIdx;
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
|
|
|
@ -2,8 +2,9 @@ use rustc_ast::ast;
|
|||
use rustc_middle::mir::interpret::{
|
||||
truncate, Allocation, ConstValue, LitToConstError, LitToConstInput, Scalar,
|
||||
};
|
||||
use rustc_middle::ty::{self, layout::Size, ParamEnv, TyCtxt, TyS};
|
||||
use rustc_middle::ty::{self, ParamEnv, TyCtxt, TyS};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::Size;
|
||||
|
||||
crate fn lit_to_const<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
|
|
@ -14,11 +14,11 @@ use rustc_index::vec::Idx;
|
|||
use rustc_infer::infer::InferCtxt;
|
||||
use rustc_middle::middle::region;
|
||||
use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::subst::Subst;
|
||||
use rustc_middle::ty::subst::{GenericArg, InternalSubsts};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use rustc_trait_selection::infer::InferCtxtExt;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
|
@ -11,10 +11,10 @@ use rustc_middle::infer::canonical::Canonical;
|
|||
use rustc_middle::middle::region;
|
||||
use rustc_middle::mir::{BinOp, BorrowKind, Field, UnOp};
|
||||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::{AdtDef, Const, Ty, UpvarSubsts, UserType};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::VariantIdx;
|
||||
|
||||
crate mod constant;
|
||||
crate mod cx;
|
||||
|
|
|
@ -240,11 +240,12 @@ use rustc_hir::def_id::DefId;
|
|||
use rustc_hir::{HirId, RangeEnd};
|
||||
use rustc_middle::mir::interpret::{truncate, AllocId, ConstValue, Pointer, Scalar};
|
||||
use rustc_middle::mir::Field;
|
||||
use rustc_middle::ty::layout::{Integer, IntegerExt, Size, VariantIdx};
|
||||
use rustc_middle::ty::layout::IntegerExt;
|
||||
use rustc_middle::ty::{self, Const, Ty, TyCtxt, TypeFoldable, VariantDef};
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
use rustc_session::lint;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_target::abi::{Integer, Size, VariantIdx};
|
||||
|
||||
use arena::TypedArena;
|
||||
|
||||
|
|
|
@ -19,13 +19,13 @@ use rustc_middle::mir::interpret::{get_slice_bytes, sign_extend, ConstValue, Err
|
|||
use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
|
||||
use rustc_middle::mir::UserTypeProjection;
|
||||
use rustc_middle::mir::{BorrowKind, Field, Mutability};
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::subst::{GenericArg, SubstsRef};
|
||||
use rustc_middle::ty::{self, AdtDef, DefIdTree, Region, Ty, TyCtxt, UserType};
|
||||
use rustc_middle::ty::{
|
||||
CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations,
|
||||
};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
|
@ -1047,8 +1047,8 @@ crate fn compare_const_vals<'tcx>(
|
|||
}
|
||||
ty::Int(ity) => {
|
||||
use rustc_attr::SignedInt;
|
||||
use rustc_middle::ty::layout::{Integer, IntegerExt};
|
||||
let size = Integer::from_attr(&tcx, SignedInt(ity)).size();
|
||||
use rustc_middle::ty::layout::IntegerExt;
|
||||
let size = rustc_target::abi::Integer::from_attr(&tcx, SignedInt(ity)).size();
|
||||
let a = sign_extend(a, size);
|
||||
let b = sign_extend(b, size);
|
||||
Some((a as i128).cmp(&(b as i128)))
|
||||
|
|
|
@ -4,10 +4,11 @@ use rustc_hir::def::{DefKind, Res};
|
|||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::ty::layout::{LayoutError, Pointer, SizeSkeleton, VariantIdx};
|
||||
use rustc_middle::ty::layout::{LayoutError, SizeSkeleton};
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_span::{sym, Span};
|
||||
use rustc_target::abi::{Pointer, VariantIdx};
|
||||
use rustc_target::spec::abi::Abi::RustIntrinsic;
|
||||
|
||||
fn check_mod_intrinsics(tcx: TyCtxt<'_>, module_def_id: DefId) {
|
||||
|
|
|
@ -3,16 +3,10 @@ use rustc_hir as hir;
|
|||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::ItemKind;
|
||||
use rustc_middle::ty::layout::HasDataLayout;
|
||||
use rustc_middle::ty::layout::HasParamEnv;
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
use rustc_middle::ty::layout::TargetDataLayout;
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::ParamEnv;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt, TyAndLayout};
|
||||
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_target::abi::{HasDataLayout, LayoutOf, TargetDataLayout};
|
||||
|
||||
pub fn test_layout(tcx: TyCtxt<'_>) {
|
||||
if tcx.features().rustc_attrs {
|
||||
|
|
|
@ -420,7 +420,7 @@ fn virtual_call_violation_for_method<'tcx>(
|
|||
} else {
|
||||
// Do sanity check to make sure the receiver actually has the layout of a pointer.
|
||||
|
||||
use rustc_middle::ty::layout::Abi;
|
||||
use rustc_target::abi::Abi;
|
||||
|
||||
let param_env = tcx.param_env(method.def_id);
|
||||
|
||||
|
|
|
@ -114,7 +114,6 @@ use rustc_middle::ty::adjustment::{
|
|||
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, PointerCast,
|
||||
};
|
||||
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder};
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::subst::{
|
||||
GenericArgKind, InternalSubsts, Subst, SubstsRef, UserSelfTy, UserSubsts,
|
||||
|
@ -132,6 +131,7 @@ use rustc_span::hygiene::DesugaringKind;
|
|||
use rustc_span::source_map::{original_sp, DUMMY_SP};
|
||||
use rustc_span::symbol::{kw, sym, Ident};
|
||||
use rustc_span::{self, BytePos, MultiSpan, Span};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_trait_selection::infer::InferCtxtExt as _;
|
||||
use rustc_trait_selection::opaque_types::{InferCtxtExt as _, OpaqueTypeDecl};
|
||||
|
|
|
@ -19,11 +19,11 @@ use rustc_hir::Mutability;
|
|||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::middle::lang_items;
|
||||
use rustc_middle::middle::stability;
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::source_map::DUMMY_SP;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::{self, FileName};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use crate::clean::cfg::Cfg;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue