Auto merge of #70692 - Centril:rollup-d0t4ecx, r=Centril
Rollup of 8 pull requests Successful merges: - #70281 (Implement Hash for Infallible) - #70421 (parse: recover on `const fn()` / `async fn()`) - #70615 (Renamed `PerDefTables` to `Tables`) - #70631 (Update cargo) - #70634 (Remove some reexports in `rustc_middle`) - #70658 (add `STILL_FURTHER_SPECIALIZABLE` flag) - #70678 (Add missing markdown rust annotation) - #70681 (Handle unterminated raw strings with no #s properly) Failed merges: r? @ghost
This commit is contained in:
commit
537ccdf3ac
@ -87,7 +87,7 @@ Feedback on the design and usage is always appreciated!
|
||||
|
||||
The `Generator` trait in `std::ops` currently looks like:
|
||||
|
||||
```
|
||||
```rust
|
||||
# #![feature(arbitrary_self_types, generator_trait)]
|
||||
# use std::ops::GeneratorState;
|
||||
# use std::pin::Pin;
|
||||
@ -107,7 +107,7 @@ point for executing the `Generator` itself.
|
||||
|
||||
The return value of `resume`, `GeneratorState`, looks like:
|
||||
|
||||
```
|
||||
```rust
|
||||
pub enum GeneratorState<Y, R> {
|
||||
Yielded(Y),
|
||||
Complete(R),
|
||||
|
@ -41,6 +41,7 @@
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::fmt;
|
||||
use crate::hash::{Hash, Hasher};
|
||||
|
||||
mod num;
|
||||
|
||||
@ -746,3 +747,10 @@ fn from(x: !) -> Self {
|
||||
x
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "convert_infallible_hash", since = "1.44.0")]
|
||||
impl Hash for Infallible {
|
||||
fn hash<H: Hasher>(&self, _: &mut H) {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
@ -10,17 +10,15 @@
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_codegen_ssa::MemFlags;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::layout::{self};
|
||||
pub use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_target::abi::call::ArgAbi;
|
||||
use rustc_target::abi::{HasDataLayout, LayoutOf};
|
||||
pub use rustc_target::abi::call::*;
|
||||
use rustc_target::abi::{self, HasDataLayout, Int, LayoutOf};
|
||||
pub use rustc_target::spec::abi::Abi;
|
||||
|
||||
use libc::c_uint;
|
||||
|
||||
pub use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
|
||||
pub use rustc_target::abi::call::*;
|
||||
pub use rustc_target::spec::abi::Abi;
|
||||
|
||||
macro_rules! for_each_kind {
|
||||
($flags: ident, $f: ident, $($kind: ident),+) => ({
|
||||
$(if $flags.contains(ArgAttribute::$kind) { $f(llvm::Attribute::$kind) })+
|
||||
@ -450,11 +448,11 @@ fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll V
|
||||
PassMode::Indirect(ref attrs, _) => apply(attrs, Some(self.ret.layout.llvm_type(bx))),
|
||||
_ => {}
|
||||
}
|
||||
if let layout::Abi::Scalar(ref scalar) = self.ret.layout.abi {
|
||||
if let abi::Abi::Scalar(ref scalar) = self.ret.layout.abi {
|
||||
// If the value is a boolean, the range is 0..2 and that ultimately
|
||||
// become 0..0 when the type becomes i1, which would be rejected
|
||||
// by the LLVM verifier.
|
||||
if let layout::Int(..) = scalar.value {
|
||||
if let Int(..) = scalar.value {
|
||||
if !scalar.is_bool() {
|
||||
let range = scalar.valid_range_exclusive(bx);
|
||||
if range.start != range.end {
|
||||
|
@ -16,9 +16,10 @@
|
||||
use rustc_data_structures::const_cstr;
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::layout::{self, Align, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_session::config::{self, Sanitizer};
|
||||
use rustc_target::abi::{self, Align, Size};
|
||||
use rustc_target::spec::{HasTargetSpec, Target};
|
||||
use std::borrow::Cow;
|
||||
use std::ffi::CStr;
|
||||
@ -60,8 +61,8 @@ impl BackendTypes for Builder<'_, 'll, 'tcx> {
|
||||
type DIVariable = <CodegenCx<'ll, 'tcx> as BackendTypes>::DIVariable;
|
||||
}
|
||||
|
||||
impl ty::layout::HasDataLayout for Builder<'_, '_, '_> {
|
||||
fn data_layout(&self) -> &ty::layout::TargetDataLayout {
|
||||
impl abi::HasDataLayout for Builder<'_, '_, '_> {
|
||||
fn data_layout(&self) -> &abi::TargetDataLayout {
|
||||
self.cx.data_layout()
|
||||
}
|
||||
}
|
||||
@ -84,7 +85,7 @@ fn target_spec(&self) -> &Target {
|
||||
}
|
||||
}
|
||||
|
||||
impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> {
|
||||
impl abi::LayoutOf for Builder<'_, '_, 'tcx> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyAndLayout = TyAndLayout<'tcx>;
|
||||
|
||||
@ -435,17 +436,17 @@ fn load_operand(&mut self, place: PlaceRef<'tcx, &'ll Value>) -> OperandRef<'tcx
|
||||
fn scalar_load_metadata<'a, 'll, 'tcx>(
|
||||
bx: &mut Builder<'a, 'll, 'tcx>,
|
||||
load: &'ll Value,
|
||||
scalar: &layout::Scalar,
|
||||
scalar: &abi::Scalar,
|
||||
) {
|
||||
let vr = scalar.valid_range.clone();
|
||||
match scalar.value {
|
||||
layout::Int(..) => {
|
||||
abi::Int(..) => {
|
||||
let range = scalar.valid_range_exclusive(bx);
|
||||
if range.start != range.end {
|
||||
bx.range_metadata(load, range);
|
||||
}
|
||||
}
|
||||
layout::Pointer if vr.start() < vr.end() && !vr.contains(&0) => {
|
||||
abi::Pointer if vr.start() < vr.end() && !vr.contains(&0) => {
|
||||
bx.nonnull_metadata(load);
|
||||
}
|
||||
_ => {}
|
||||
@ -465,16 +466,16 @@ fn scalar_load_metadata<'a, 'll, 'tcx>(
|
||||
}
|
||||
let llval = const_llval.unwrap_or_else(|| {
|
||||
let load = self.load(place.llval, place.align);
|
||||
if let layout::Abi::Scalar(ref scalar) = place.layout.abi {
|
||||
if let abi::Abi::Scalar(ref scalar) = place.layout.abi {
|
||||
scalar_load_metadata(self, load, scalar);
|
||||
}
|
||||
load
|
||||
});
|
||||
OperandValue::Immediate(to_immediate(self, llval, place.layout))
|
||||
} else if let layout::Abi::ScalarPair(ref a, ref b) = place.layout.abi {
|
||||
} else if let abi::Abi::ScalarPair(ref a, ref b) = place.layout.abi {
|
||||
let b_offset = a.value.size(self).align_to(b.value.align(self).abi);
|
||||
|
||||
let mut load = |i, scalar: &layout::Scalar, align| {
|
||||
let mut load = |i, scalar: &abi::Scalar, align| {
|
||||
let llptr = self.struct_gep(place.llval, i as u64);
|
||||
let load = self.load(llptr, align);
|
||||
scalar_load_metadata(self, load, scalar);
|
||||
|
@ -2,26 +2,24 @@
|
||||
|
||||
//! Code that is useful in various codegen modules.
|
||||
|
||||
use crate::consts;
|
||||
use crate::consts::{self, const_alloc_to_llvm};
|
||||
pub use crate::context::CodegenCx;
|
||||
use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, OperandBundleDef, True};
|
||||
use crate::type_::Type;
|
||||
use crate::type_of::LayoutLlvmExt;
|
||||
use crate::value::Value;
|
||||
use log::debug;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_middle::bug;
|
||||
|
||||
use crate::consts::const_alloc_to_llvm;
|
||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||
use rustc_middle::mir::interpret::{Allocation, GlobalAlloc, Scalar};
|
||||
use rustc_middle::ty::layout::{self, HasDataLayout, LayoutOf, Size, TyAndLayout};
|
||||
|
||||
use libc::{c_char, c_uint};
|
||||
|
||||
use rustc_ast::ast::Mutability;
|
||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::mir::interpret::{Allocation, GlobalAlloc, Scalar};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::{self, HasDataLayout, LayoutOf, Pointer, Size};
|
||||
|
||||
pub use crate::context::CodegenCx;
|
||||
use libc::{c_char, c_uint};
|
||||
use log::debug;
|
||||
|
||||
/*
|
||||
* A note on nomenclature of linking: "extern", "foreign", and "upcall".
|
||||
@ -229,12 +227,7 @@ fn const_to_opt_u128(&self, v: &'ll Value, sign_ext: bool) -> Option<u128> {
|
||||
})
|
||||
}
|
||||
|
||||
fn scalar_to_backend(
|
||||
&self,
|
||||
cv: Scalar,
|
||||
layout: &layout::Scalar,
|
||||
llty: &'ll Type,
|
||||
) -> &'ll Value {
|
||||
fn scalar_to_backend(&self, cv: Scalar, layout: &abi::Scalar, llty: &'ll Type) -> &'ll Value {
|
||||
let bitsize = if layout.is_bool() { 1 } else { layout.value.size(self).bits() };
|
||||
match cv {
|
||||
Scalar::Raw { size: 0, .. } => {
|
||||
@ -244,7 +237,7 @@ fn scalar_to_backend(
|
||||
Scalar::Raw { data, size } => {
|
||||
assert_eq!(size as u64, layout.value.size(self).bytes());
|
||||
let llval = self.const_uint_big(self.type_ix(bitsize), data);
|
||||
if layout.value == layout::Pointer {
|
||||
if layout.value == Pointer {
|
||||
unsafe { llvm::LLVMConstIntToPtr(llval, llty) }
|
||||
} else {
|
||||
self.const_bitcast(llval, llty)
|
||||
@ -278,7 +271,7 @@ fn scalar_to_backend(
|
||||
1,
|
||||
)
|
||||
};
|
||||
if layout.value != layout::Pointer {
|
||||
if layout.value != Pointer {
|
||||
unsafe { llvm::LLVMConstPtrToInt(llval, llty) }
|
||||
} else {
|
||||
self.const_bitcast(llval, llty)
|
||||
|
@ -16,12 +16,11 @@
|
||||
read_target_uint, Allocation, ConstValue, ErrorHandled, Pointer,
|
||||
};
|
||||
use rustc_middle::mir::mono::MonoItem;
|
||||
use rustc_middle::ty::layout::{self, Align, LayoutOf, Size};
|
||||
use rustc_middle::ty::{self, Instance, Ty};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::HasDataLayout;
|
||||
use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Primitive, Scalar, Size};
|
||||
|
||||
use std::ffi::CStr;
|
||||
|
||||
@ -56,7 +55,7 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll
|
||||
as u64;
|
||||
llvals.push(cx.scalar_to_backend(
|
||||
Pointer::new(alloc_id, Size::from_bytes(ptr_offset)).into(),
|
||||
&layout::Scalar { value: layout::Primitive::Pointer, valid_range: 0..=!0 },
|
||||
&Scalar { value: Primitive::Pointer, valid_range: 0..=!0 },
|
||||
cx.type_i8p(),
|
||||
));
|
||||
next_offset = offset + pointer_size;
|
||||
|
@ -14,14 +14,13 @@
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::mir::mono::CodegenUnit;
|
||||
use rustc_middle::ty::layout::{
|
||||
HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc_middle::ty::layout::{HasParamEnv, LayoutError, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
||||
use rustc_session::config::{self, CFGuard, DebugInfo};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::source_map::{Span, DUMMY_SP};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::{HasDataLayout, LayoutOf, PointeeInfo, Size, TargetDataLayout, VariantIdx};
|
||||
use rustc_target::spec::{HasTargetSpec, Target};
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
@ -817,8 +816,8 @@ pub fn generate_local_symbol_name(&self, prefix: &str) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
impl ty::layout::HasDataLayout for CodegenCx<'ll, 'tcx> {
|
||||
fn data_layout(&self) -> &ty::layout::TargetDataLayout {
|
||||
impl HasDataLayout for CodegenCx<'ll, 'tcx> {
|
||||
fn data_layout(&self) -> &TargetDataLayout {
|
||||
&self.tcx.data_layout
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,7 @@
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::mir::interpret::truncate;
|
||||
use rustc_middle::mir::{self, Field, GeneratorLayout};
|
||||
use rustc_middle::ty::layout::{
|
||||
self, Align, Integer, IntegerExt, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc_middle::ty::layout::{self, IntegerExt, PrimitiveExt, TyAndLayout};
|
||||
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
||||
use rustc_middle::ty::Instance;
|
||||
use rustc_middle::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
|
||||
@ -44,7 +42,9 @@
|
||||
use rustc_session::config::{self, DebugInfo};
|
||||
use rustc_span::symbol::{Interner, Symbol};
|
||||
use rustc_span::{self, FileName, Span};
|
||||
use rustc_target::abi::HasDataLayout;
|
||||
use rustc_target::abi::{Abi, Align, DiscriminantKind, HasDataLayout, Integer, LayoutOf};
|
||||
use rustc_target::abi::{Int, Pointer, F32, F64};
|
||||
use rustc_target::abi::{Primitive, Size, VariantIdx, Variants};
|
||||
|
||||
use libc::{c_longlong, c_uint};
|
||||
use std::collections::hash_map::Entry;
|
||||
@ -1364,7 +1364,7 @@ fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec<MemberDes
|
||||
};
|
||||
|
||||
match self.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
if let ty::Adt(adt, _) = &self.enum_type.kind {
|
||||
if adt.variants.is_empty() {
|
||||
return vec![];
|
||||
@ -1399,8 +1399,8 @@ fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec<MemberDes
|
||||
discriminant: None,
|
||||
}]
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Tag,
|
||||
Variants::Multiple {
|
||||
discr_kind: DiscriminantKind::Tag,
|
||||
discr_index,
|
||||
ref variants,
|
||||
..
|
||||
@ -1457,9 +1457,9 @@ fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec<MemberDes
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
Variants::Multiple {
|
||||
discr_kind:
|
||||
layout::DiscriminantKind::Niche { ref niche_variants, niche_start, dataful_variant },
|
||||
DiscriminantKind::Niche { ref niche_variants, niche_start, dataful_variant },
|
||||
ref discr,
|
||||
ref variants,
|
||||
discr_index,
|
||||
@ -1592,7 +1592,7 @@ fn compute_field_path<'a, 'tcx>(
|
||||
// Creates `MemberDescription`s for the fields of a single enum variant.
|
||||
struct VariantMemberDescriptionFactory<'ll, 'tcx> {
|
||||
/// Cloned from the `layout::Struct` describing the variant.
|
||||
offsets: Vec<layout::Size>,
|
||||
offsets: Vec<Size>,
|
||||
args: Vec<(String, Ty<'tcx>)>,
|
||||
discriminant_type_metadata: Option<&'ll DIType>,
|
||||
span: Span,
|
||||
@ -1777,7 +1777,7 @@ fn prepare_enum_metadata(
|
||||
// <unknown>
|
||||
let file_metadata = unknown_file_metadata(cx);
|
||||
|
||||
let discriminant_type_metadata = |discr: layout::Primitive| {
|
||||
let discriminant_type_metadata = |discr: Primitive| {
|
||||
let enumerators_metadata: Vec<_> = match enum_type.kind {
|
||||
ty::Adt(def, _) => def
|
||||
.discriminants(cx.tcx)
|
||||
@ -1870,10 +1870,8 @@ fn prepare_enum_metadata(
|
||||
let layout = cx.layout_of(enum_type);
|
||||
|
||||
if let (
|
||||
&layout::Abi::Scalar(_),
|
||||
&layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Tag, ref discr, ..
|
||||
},
|
||||
&Abi::Scalar(_),
|
||||
&Variants::Multiple { discr_kind: DiscriminantKind::Tag, ref discr, .. },
|
||||
) = (&layout.abi, &layout.variants)
|
||||
{
|
||||
return FinalMetadata(discriminant_type_metadata(discr.value));
|
||||
@ -1881,16 +1879,11 @@ fn prepare_enum_metadata(
|
||||
|
||||
if use_enum_fallback(cx) {
|
||||
let discriminant_type_metadata = match layout.variants {
|
||||
layout::Variants::Single { .. }
|
||||
| layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Niche { .. },
|
||||
..
|
||||
} => None,
|
||||
layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Tag,
|
||||
ref discr,
|
||||
..
|
||||
} => Some(discriminant_type_metadata(discr.value)),
|
||||
Variants::Single { .. }
|
||||
| Variants::Multiple { discr_kind: DiscriminantKind::Niche { .. }, .. } => None,
|
||||
Variants::Multiple { discr_kind: DiscriminantKind::Tag, ref discr, .. } => {
|
||||
Some(discriminant_type_metadata(discr.value))
|
||||
}
|
||||
};
|
||||
|
||||
let enum_metadata = {
|
||||
@ -1938,10 +1931,10 @@ fn prepare_enum_metadata(
|
||||
};
|
||||
let discriminator_metadata = match layout.variants {
|
||||
// A single-variant enum has no discriminant.
|
||||
layout::Variants::Single { .. } => None,
|
||||
Variants::Single { .. } => None,
|
||||
|
||||
layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Niche { .. },
|
||||
Variants::Multiple {
|
||||
discr_kind: DiscriminantKind::Niche { .. },
|
||||
ref discr,
|
||||
discr_index,
|
||||
..
|
||||
@ -1951,10 +1944,10 @@ fn prepare_enum_metadata(
|
||||
let align = discr.value.align(cx);
|
||||
|
||||
let discr_type = match discr.value {
|
||||
layout::Int(t, _) => t,
|
||||
layout::F32 => Integer::I32,
|
||||
layout::F64 => Integer::I64,
|
||||
layout::Pointer => cx.data_layout().ptr_sized_integer(),
|
||||
Int(t, _) => t,
|
||||
F32 => Integer::I32,
|
||||
F64 => Integer::I64,
|
||||
Pointer => cx.data_layout().ptr_sized_integer(),
|
||||
}
|
||||
.to_ty(cx.tcx, false);
|
||||
|
||||
@ -1976,11 +1969,8 @@ fn prepare_enum_metadata(
|
||||
}
|
||||
}
|
||||
|
||||
layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Tag,
|
||||
ref discr,
|
||||
discr_index,
|
||||
..
|
||||
Variants::Multiple {
|
||||
discr_kind: DiscriminantKind::Tag, ref discr, discr_index, ..
|
||||
} => {
|
||||
let discr_type = discr.value.to_ty(cx.tcx);
|
||||
let (size, align) = cx.size_and_align_of(discr_type);
|
||||
@ -2005,8 +1995,8 @@ fn prepare_enum_metadata(
|
||||
};
|
||||
|
||||
let mut outer_fields = match layout.variants {
|
||||
layout::Variants::Single { .. } => vec![],
|
||||
layout::Variants::Multiple { .. } => {
|
||||
Variants::Single { .. } => vec![],
|
||||
Variants::Multiple { .. } => {
|
||||
let tuple_mdf = TupleMemberDescriptionFactory {
|
||||
ty: enum_type,
|
||||
component_types: outer_field_tys,
|
||||
|
@ -8,35 +8,35 @@
|
||||
use self::type_names::compute_debuginfo_type_name;
|
||||
use self::utils::{create_DIArray, is_node_local_to_unit, DIB};
|
||||
|
||||
use crate::abi::FnAbi;
|
||||
use crate::builder::Builder;
|
||||
use crate::common::CodegenCx;
|
||||
use crate::llvm;
|
||||
use crate::llvm::debuginfo::{
|
||||
DIArray, DIBuilder, DIFile, DIFlags, DILexicalBlock, DISPFlags, DIScope, DIType, DIVariable,
|
||||
};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE};
|
||||
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
||||
|
||||
use crate::abi::FnAbi;
|
||||
use crate::builder::Builder;
|
||||
use crate::common::CodegenCx;
|
||||
use crate::value::Value;
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_codegen_ssa::debuginfo::type_names;
|
||||
use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind};
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
||||
use rustc_middle::ty::{self, Instance, ParamEnv, Ty};
|
||||
use rustc_session::config::{self, DebugInfo};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{self, BytePos, Span};
|
||||
use rustc_target::abi::{LayoutOf, Primitive, Size};
|
||||
|
||||
use libc::c_uint;
|
||||
use log::debug;
|
||||
use std::cell::RefCell;
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_middle::ty::layout::{self, HasTyCtxt, LayoutOf, Size};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{self, BytePos, Span};
|
||||
use smallvec::SmallVec;
|
||||
use std::cell::RefCell;
|
||||
|
||||
mod create_scope_map;
|
||||
pub mod gdb;
|
||||
@ -60,7 +60,7 @@ pub struct CrateDebugContext<'a, 'tcx> {
|
||||
llmod: &'a llvm::Module,
|
||||
builder: &'a mut DIBuilder<'a>,
|
||||
created_files: RefCell<FxHashMap<(Option<String>, Option<String>), &'a DIFile>>,
|
||||
created_enum_disr_types: RefCell<FxHashMap<(DefId, layout::Primitive), &'a DIType>>,
|
||||
created_enum_disr_types: RefCell<FxHashMap<(DefId, Primitive), &'a DIType>>,
|
||||
|
||||
type_map: RefCell<TypeMap<'a, 'tcx>>,
|
||||
namespace_map: RefCell<DefIdMap<&'a DIScope>>,
|
||||
|
@ -7,23 +7,22 @@
|
||||
use crate::type_of::LayoutLlvmExt;
|
||||
use crate::va_arg::emit_va_arg;
|
||||
use crate::value::Value;
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_codegen_ssa::base::{compare_simd_types, to_immediate, wants_msvc_seh};
|
||||
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
|
||||
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
|
||||
use rustc_codegen_ssa::glue;
|
||||
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
|
||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_codegen_ssa::MemFlags;
|
||||
use rustc_hir as hir;
|
||||
use rustc_middle::ty::layout::{self, FnAbiExt, HasTyCtxt, LayoutOf, Primitive};
|
||||
use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_target::abi::HasDataLayout;
|
||||
|
||||
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{self, HasDataLayout, LayoutOf, Primitive};
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::{i128, iter, u128};
|
||||
@ -145,7 +144,7 @@ fn codegen_intrinsic_call(
|
||||
}
|
||||
"va_arg" => {
|
||||
match fn_abi.ret.layout.abi {
|
||||
layout::Abi::Scalar(ref scalar) => {
|
||||
abi::Abi::Scalar(ref scalar) => {
|
||||
match scalar.value {
|
||||
Primitive::Int(..) => {
|
||||
if self.cx().size_of(ret_ty).bytes() < 4 {
|
||||
|
@ -23,11 +23,10 @@
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_codegen_ssa::ModuleCodegen;
|
||||
use rustc_codegen_ssa::{CodegenResults, CompiledModule};
|
||||
use rustc_errors::{FatalError, Handler};
|
||||
use rustc_errors::{ErrorReported, FatalError, Handler};
|
||||
use rustc_middle::dep_graph::{DepGraph, WorkProduct};
|
||||
use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
use rustc_serialize::json;
|
||||
use rustc_session::config::{self, OptLevel, OutputFilenames, PrintRequest};
|
||||
use rustc_session::Session;
|
||||
|
@ -7,11 +7,11 @@
|
||||
use log::debug;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_middle::mir::mono::{Linkage, Visibility};
|
||||
use rustc_middle::ty::layout::{FnAbiExt, LayoutOf};
|
||||
use rustc_middle::ty::{Instance, TypeFoldable};
|
||||
|
||||
pub use rustc_middle::mir::mono::MonoItem;
|
||||
use rustc_middle::mir::mono::{Linkage, Visibility};
|
||||
use rustc_middle::ty::layout::FnAbiExt;
|
||||
use rustc_middle::ty::{Instance, TypeFoldable};
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
||||
impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
fn predefine_static(
|
||||
|
@ -12,9 +12,10 @@
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::layout::{self, Align, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
|
||||
use rustc_target::abi::{Align, Integer, Size};
|
||||
|
||||
use std::fmt;
|
||||
use std::ptr;
|
||||
@ -114,14 +115,14 @@ impl CodegenCx<'ll, 'tcx> {
|
||||
|
||||
crate fn type_pointee_for_align(&self, align: Align) -> &'ll Type {
|
||||
// FIXME(eddyb) We could find a better approximation if ity.align < align.
|
||||
let ity = layout::Integer::approximate_align(self, align);
|
||||
let ity = Integer::approximate_align(self, align);
|
||||
self.type_from_integer(ity)
|
||||
}
|
||||
|
||||
/// Return a LLVM type that has at most the required alignment,
|
||||
/// and exactly the required size, as a best-effort padding array.
|
||||
crate fn type_padding_filler(&self, size: Size, align: Align) -> &'ll Type {
|
||||
let unit = layout::Integer::approximate_align(self, align);
|
||||
let unit = Integer::approximate_align(self, align);
|
||||
let size = size.bytes();
|
||||
let unit_size = unit.size().bytes();
|
||||
assert_eq!(size % unit_size, 0);
|
||||
|
@ -4,10 +4,12 @@
|
||||
use log::debug;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::layout::{self, Align, FnAbiExt, LayoutOf, PointeeInfo, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{FnAbiExt, TyAndLayout};
|
||||
use rustc_middle::ty::print::obsolete::DefPathBasedNames;
|
||||
use rustc_middle::ty::{self, Ty, TypeFoldable};
|
||||
use rustc_target::abi::TyAndLayoutMethods;
|
||||
use rustc_target::abi::{Abi, Align, FieldsShape};
|
||||
use rustc_target::abi::{Int, Pointer, F32, F64};
|
||||
use rustc_target::abi::{LayoutOf, PointeeInfo, Scalar, Size, TyAndLayoutMethods, Variants};
|
||||
|
||||
use std::fmt::Write;
|
||||
|
||||
@ -17,8 +19,8 @@ fn uncached_llvm_type<'a, 'tcx>(
|
||||
defer: &mut Option<(&'a Type, TyAndLayout<'tcx>)>,
|
||||
) -> &'a Type {
|
||||
match layout.abi {
|
||||
layout::Abi::Scalar(_) => bug!("handled elsewhere"),
|
||||
layout::Abi::Vector { ref element, count } => {
|
||||
Abi::Scalar(_) => bug!("handled elsewhere"),
|
||||
Abi::Vector { ref element, count } => {
|
||||
// LLVM has a separate type for 64-bit SIMD vectors on X86 called
|
||||
// `x86_mmx` which is needed for some SIMD operations. As a bit of a
|
||||
// hack (all SIMD definitions are super unstable anyway) we
|
||||
@ -37,7 +39,7 @@ fn uncached_llvm_type<'a, 'tcx>(
|
||||
return cx.type_vector(element, count);
|
||||
}
|
||||
}
|
||||
layout::Abi::ScalarPair(..) => {
|
||||
Abi::ScalarPair(..) => {
|
||||
return cx.type_struct(
|
||||
&[
|
||||
layout.scalar_pair_element_llvm_type(cx, 0, false),
|
||||
@ -46,7 +48,7 @@ fn uncached_llvm_type<'a, 'tcx>(
|
||||
false,
|
||||
);
|
||||
}
|
||||
layout::Abi::Uninhabited | layout::Abi::Aggregate { .. } => {}
|
||||
Abi::Uninhabited | Abi::Aggregate { .. } => {}
|
||||
}
|
||||
|
||||
let name = match layout.ty.kind {
|
||||
@ -61,14 +63,14 @@ fn uncached_llvm_type<'a, 'tcx>(
|
||||
let mut name = String::with_capacity(32);
|
||||
let printer = DefPathBasedNames::new(cx.tcx, true, true);
|
||||
printer.push_type_name(layout.ty, &mut name, false);
|
||||
if let (&ty::Adt(def, _), &layout::Variants::Single { index })
|
||||
if let (&ty::Adt(def, _), &Variants::Single { index })
|
||||
= (&layout.ty.kind, &layout.variants)
|
||||
{
|
||||
if def.is_enum() && !def.variants.is_empty() {
|
||||
write!(&mut name, "::{}", def.variants[index].ident).unwrap();
|
||||
}
|
||||
}
|
||||
if let (&ty::Generator(_, substs, _), &layout::Variants::Single { index })
|
||||
if let (&ty::Generator(_, substs, _), &Variants::Single { index })
|
||||
= (&layout.ty.kind, &layout.variants)
|
||||
{
|
||||
write!(&mut name, "::{}", substs.as_generator().variant_name(index)).unwrap();
|
||||
@ -79,7 +81,7 @@ fn uncached_llvm_type<'a, 'tcx>(
|
||||
};
|
||||
|
||||
match layout.fields {
|
||||
layout::FieldsShape::Union(_) => {
|
||||
FieldsShape::Union(_) => {
|
||||
let fill = cx.type_padding_filler(layout.size, layout.align.abi);
|
||||
let packed = false;
|
||||
match name {
|
||||
@ -91,10 +93,8 @@ fn uncached_llvm_type<'a, 'tcx>(
|
||||
}
|
||||
}
|
||||
}
|
||||
layout::FieldsShape::Array { count, .. } => {
|
||||
cx.type_array(layout.field(cx, 0).llvm_type(cx), count)
|
||||
}
|
||||
layout::FieldsShape::Arbitrary { .. } => match name {
|
||||
FieldsShape::Array { count, .. } => cx.type_array(layout.field(cx, 0).llvm_type(cx), count),
|
||||
FieldsShape::Arbitrary { .. } => match name {
|
||||
None => {
|
||||
let (llfields, packed) = struct_llfields(cx, layout);
|
||||
cx.type_struct(&llfields, packed)
|
||||
@ -189,7 +189,7 @@ pub trait LayoutLlvmExt<'tcx> {
|
||||
fn scalar_llvm_type_at<'a>(
|
||||
&self,
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
scalar: &layout::Scalar,
|
||||
scalar: &Scalar,
|
||||
offset: Size,
|
||||
) -> &'a Type;
|
||||
fn scalar_pair_element_llvm_type<'a>(
|
||||
@ -205,19 +205,16 @@ fn scalar_pair_element_llvm_type<'a>(
|
||||
impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
||||
fn is_llvm_immediate(&self) -> bool {
|
||||
match self.abi {
|
||||
layout::Abi::Scalar(_) | layout::Abi::Vector { .. } => true,
|
||||
layout::Abi::ScalarPair(..) => false,
|
||||
layout::Abi::Uninhabited | layout::Abi::Aggregate { .. } => self.is_zst(),
|
||||
Abi::Scalar(_) | Abi::Vector { .. } => true,
|
||||
Abi::ScalarPair(..) => false,
|
||||
Abi::Uninhabited | Abi::Aggregate { .. } => self.is_zst(),
|
||||
}
|
||||
}
|
||||
|
||||
fn is_llvm_scalar_pair(&self) -> bool {
|
||||
match self.abi {
|
||||
layout::Abi::ScalarPair(..) => true,
|
||||
layout::Abi::Uninhabited
|
||||
| layout::Abi::Scalar(_)
|
||||
| layout::Abi::Vector { .. }
|
||||
| layout::Abi::Aggregate { .. } => false,
|
||||
Abi::ScalarPair(..) => true,
|
||||
Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } | Abi::Aggregate { .. } => false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,7 +230,7 @@ fn is_llvm_scalar_pair(&self) -> bool {
|
||||
/// of that field's type - this is useful for taking the address of
|
||||
/// that field and ensuring the struct has the right alignment.
|
||||
fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type {
|
||||
if let layout::Abi::Scalar(ref scalar) = self.abi {
|
||||
if let Abi::Scalar(ref scalar) = self.abi {
|
||||
// Use a different cache for scalars because pointers to DSTs
|
||||
// can be either fat or thin (data pointers of fat pointers).
|
||||
if let Some(&llty) = cx.scalar_lltypes.borrow().get(&self.ty) {
|
||||
@ -255,7 +252,7 @@ fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type {
|
||||
|
||||
// Check the cache.
|
||||
let variant_index = match self.variants {
|
||||
layout::Variants::Single { index } => Some(index),
|
||||
Variants::Single { index } => Some(index),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(&llty) = cx.lltypes.borrow().get(&(self.ty, variant_index)) {
|
||||
@ -293,7 +290,7 @@ fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type {
|
||||
}
|
||||
|
||||
fn immediate_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type {
|
||||
if let layout::Abi::Scalar(ref scalar) = self.abi {
|
||||
if let Abi::Scalar(ref scalar) = self.abi {
|
||||
if scalar.is_bool() {
|
||||
return cx.type_i1();
|
||||
}
|
||||
@ -304,14 +301,14 @@ fn immediate_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type {
|
||||
fn scalar_llvm_type_at<'a>(
|
||||
&self,
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
scalar: &layout::Scalar,
|
||||
scalar: &Scalar,
|
||||
offset: Size,
|
||||
) -> &'a Type {
|
||||
match scalar.value {
|
||||
layout::Int(i, _) => cx.type_from_integer(i),
|
||||
layout::F32 => cx.type_f32(),
|
||||
layout::F64 => cx.type_f64(),
|
||||
layout::Pointer => {
|
||||
Int(i, _) => cx.type_from_integer(i),
|
||||
F32 => cx.type_f32(),
|
||||
F64 => cx.type_f64(),
|
||||
Pointer => {
|
||||
// If we know the alignment, pick something better than i8.
|
||||
let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) {
|
||||
cx.type_pointee_for_align(pointee.align)
|
||||
@ -343,7 +340,7 @@ fn scalar_pair_element_llvm_type<'a>(
|
||||
}
|
||||
|
||||
let (a, b) = match self.abi {
|
||||
layout::Abi::ScalarPair(ref a, ref b) => (a, b),
|
||||
Abi::ScalarPair(ref a, ref b) => (a, b),
|
||||
_ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self),
|
||||
};
|
||||
let scalar = [a, b][index];
|
||||
@ -365,21 +362,19 @@ fn scalar_pair_element_llvm_type<'a>(
|
||||
|
||||
fn llvm_field_index(&self, index: usize) -> u64 {
|
||||
match self.abi {
|
||||
layout::Abi::Scalar(_) | layout::Abi::ScalarPair(..) => {
|
||||
Abi::Scalar(_) | Abi::ScalarPair(..) => {
|
||||
bug!("TyAndLayout::llvm_field_index({:?}): not applicable", self)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
match self.fields {
|
||||
layout::FieldsShape::Union(_) => {
|
||||
FieldsShape::Union(_) => {
|
||||
bug!("TyAndLayout::llvm_field_index({:?}): not applicable", self)
|
||||
}
|
||||
|
||||
layout::FieldsShape::Array { .. } => index as u64,
|
||||
FieldsShape::Array { .. } => index as u64,
|
||||
|
||||
layout::FieldsShape::Arbitrary { .. } => {
|
||||
1 + (self.fields.memory_index(index) as u64) * 2
|
||||
}
|
||||
FieldsShape::Arbitrary { .. } => 1 + (self.fields.memory_index(index) as u64) * 2,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,9 @@
|
||||
use rustc_codegen_ssa::traits::{
|
||||
BaseTypeMethods, BuilderMethods, ConstMethods, DerivedTypeMethods,
|
||||
};
|
||||
use rustc_middle::ty::layout::{Align, HasDataLayout, HasTyCtxt, LayoutOf, Size};
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Size};
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn round_pointer_up_to_alignment(
|
||||
|
@ -31,14 +31,14 @@
|
||||
use rustc_data_structures::sync::{par_iter, Lock, ParallelIterator};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::lang_items::StartFnLangItem;
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
|
||||
use rustc_middle::middle::cstore::EncodedMetadata;
|
||||
use rustc_middle::middle::cstore::{self, LinkagePreference};
|
||||
use rustc_middle::middle::lang_items;
|
||||
use rustc_middle::middle::lang_items::StartFnLangItem;
|
||||
use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem};
|
||||
use rustc_middle::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyAndLayout, VariantIdx};
|
||||
use rustc_middle::ty::layout::{self, HasTyCtxt, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
||||
@ -47,6 +47,7 @@
|
||||
use rustc_session::Session;
|
||||
use rustc_span::Span;
|
||||
use rustc_symbol_mangling::test as symbol_names_test;
|
||||
use rustc_target::abi::{Abi, Align, LayoutOf, Scalar, VariantIdx};
|
||||
|
||||
use std::cmp;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
@ -343,7 +344,7 @@ pub fn to_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
val: Bx::Value,
|
||||
layout: layout::TyAndLayout<'_>,
|
||||
) -> Bx::Value {
|
||||
if let layout::Abi::Scalar(ref scalar) = layout.abi {
|
||||
if let Abi::Scalar(ref scalar) = layout.abi {
|
||||
return to_immediate_scalar(bx, val, scalar);
|
||||
}
|
||||
val
|
||||
@ -352,7 +353,7 @@ pub fn to_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub fn to_immediate_scalar<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
bx: &mut Bx,
|
||||
val: Bx::Value,
|
||||
scalar: &layout::Scalar,
|
||||
scalar: &Scalar,
|
||||
) -> Bx::Value {
|
||||
if scalar.is_bool() {
|
||||
return bx.trunc(val, bx.cx().type_i1());
|
||||
|
@ -1,17 +1,16 @@
|
||||
#![allow(non_camel_case_types, non_snake_case)]
|
||||
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::Span;
|
||||
|
||||
use crate::base;
|
||||
use crate::traits::*;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::middle::lang_items::LangItem;
|
||||
|
||||
use crate::traits::BuilderMethods;
|
||||
use rustc_hir as hir;
|
||||
use crate::traits::*;
|
||||
|
||||
pub enum IntPredicate {
|
||||
IntEQ,
|
||||
|
@ -21,10 +21,10 @@
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_hir::def_id::CrateNum;
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_middle::dep_graph::WorkProduct;
|
||||
use rustc_middle::middle::cstore::{CrateSource, LibSource, NativeLibrary};
|
||||
use rustc_middle::middle::dependency_format::Dependencies;
|
||||
use rustc_middle::middle::lang_items::LangItem;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_session::config::{OutputFilenames, OutputType, RUST_CGU_EXT};
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
@ -12,7 +12,8 @@
|
||||
};
|
||||
use rustc_middle::mir::{self, Location, TerminatorKind};
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
||||
pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
fx: &FunctionCx<'a, 'tcx, Bx>,
|
||||
|
@ -9,14 +9,15 @@
|
||||
use crate::traits::*;
|
||||
use crate::MemFlags;
|
||||
|
||||
use rustc_hir::lang_items;
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::middle::lang_items;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::AssertKind;
|
||||
use rustc_middle::ty::layout::{self, FnAbiExt, HasTyCtxt, LayoutOf};
|
||||
use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt};
|
||||
use rustc_middle::ty::{self, Instance, Ty, TypeFoldable};
|
||||
use rustc_span::{source_map::Span, symbol::Symbol};
|
||||
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
|
||||
use rustc_target::abi::{self, LayoutOf};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use std::borrow::Cow;
|
||||
@ -591,7 +592,7 @@ fn codegen_call_terminator(
|
||||
// we can do what we like. Here, we declare that transmuting
|
||||
// into an uninhabited type is impossible, so anything following
|
||||
// it must be unreachable.
|
||||
assert_eq!(fn_abi.ret.layout.abi, layout::Abi::Uninhabited);
|
||||
assert_eq!(fn_abi.ret.layout.abi, abi::Abi::Uninhabited);
|
||||
bx.unreachable();
|
||||
}
|
||||
return;
|
||||
@ -994,7 +995,7 @@ fn codegen_argument(
|
||||
// the load would just produce `OperandValue::Ref` instead
|
||||
// of the `OperandValue::Immediate` we need for the call.
|
||||
llval = bx.load(llval, align);
|
||||
if let layout::Abi::Scalar(ref scalar) = arg.layout.abi {
|
||||
if let abi::Abi::Scalar(ref scalar) = arg.layout.abi {
|
||||
if scalar.is_bool() {
|
||||
bx.range_metadata(llval, 0..2);
|
||||
}
|
||||
|
@ -3,9 +3,10 @@
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{ConstValue, ErrorHandled};
|
||||
use rustc_middle::ty::layout::{self, HasTyCtxt};
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_target::abi::Abi;
|
||||
|
||||
use super::FunctionCx;
|
||||
|
||||
@ -87,7 +88,7 @@ pub fn simd_shuffle_indices(
|
||||
if let Some(prim) = field.try_to_scalar() {
|
||||
let layout = bx.layout_of(field_ty);
|
||||
let scalar = match layout.abi {
|
||||
layout::Abi::Scalar(ref x) => x,
|
||||
Abi::Scalar(ref x) => x,
|
||||
_ => bug!("from_const: invalid ByVal layout: {:#?}", layout),
|
||||
};
|
||||
bx.scalar_to_backend(prim, scalar, bx.immediate_backend_type(layout))
|
||||
|
@ -3,11 +3,10 @@
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::layout::{LayoutOf, Size};
|
||||
use rustc_session::config::DebugInfo;
|
||||
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use rustc_target::abi::{LayoutOf, Size};
|
||||
|
||||
use super::operand::OperandValue;
|
||||
use super::place::PlaceRef;
|
||||
|
@ -8,8 +8,9 @@
|
||||
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{ConstValue, ErrorHandled, Pointer, Scalar};
|
||||
use rustc_middle::ty::layout::{self, Align, LayoutOf, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_target::abi::{Abi, Align, LayoutOf, Size};
|
||||
|
||||
use std::fmt;
|
||||
|
||||
@ -78,7 +79,7 @@ pub fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
let val = match val {
|
||||
ConstValue::Scalar(x) => {
|
||||
let scalar = match layout.abi {
|
||||
layout::Abi::Scalar(ref x) => x,
|
||||
Abi::Scalar(ref x) => x,
|
||||
_ => bug!("from_const: invalid ByVal layout: {:#?}", layout),
|
||||
};
|
||||
let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout));
|
||||
@ -86,7 +87,7 @@ pub fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
}
|
||||
ConstValue::Slice { data, start, end } => {
|
||||
let a_scalar = match layout.abi {
|
||||
layout::Abi::ScalarPair(ref a, _) => a,
|
||||
Abi::ScalarPair(ref a, _) => a,
|
||||
_ => bug!("from_const: invalid ScalarPair layout: {:#?}", layout),
|
||||
};
|
||||
let a = Scalar::from(Pointer::new(
|
||||
@ -161,7 +162,7 @@ pub fn from_immediate_or_packed_pair<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
llval: V,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> Self {
|
||||
let val = if let layout::Abi::ScalarPair(ref a, ref b) = layout.abi {
|
||||
let val = if let Abi::ScalarPair(ref a, ref b) = layout.abi {
|
||||
debug!("Operand::from_immediate_or_packed_pair: unpacking {:?} @ {:?}", llval, layout);
|
||||
|
||||
// Deconstruct the immediate aggregate.
|
||||
@ -199,7 +200,7 @@ pub fn extract_field<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
}
|
||||
|
||||
// Extract a scalar component from a pair.
|
||||
(OperandValue::Pair(a_llval, b_llval), &layout::Abi::ScalarPair(ref a, ref b)) => {
|
||||
(OperandValue::Pair(a_llval, b_llval), &Abi::ScalarPair(ref a, ref b)) => {
|
||||
if offset.bytes() == 0 {
|
||||
assert_eq!(field.size, a.value.size(bx.cx()));
|
||||
OperandValue::Immediate(a_llval)
|
||||
@ -211,7 +212,7 @@ pub fn extract_field<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
}
|
||||
|
||||
// `#[repr(simd)]` types are also immediate.
|
||||
(OperandValue::Immediate(llval), &layout::Abi::Vector { .. }) => {
|
||||
(OperandValue::Immediate(llval), &Abi::Vector { .. }) => {
|
||||
OperandValue::Immediate(bx.extract_element(llval, bx.cx().const_usize(i as u64)))
|
||||
}
|
||||
|
||||
@ -305,7 +306,7 @@ fn store_with_flags<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
}
|
||||
OperandValue::Pair(a, b) => {
|
||||
let (a_scalar, b_scalar) = match dest.layout.abi {
|
||||
layout::Abi::ScalarPair(ref a, ref b) => (a, b),
|
||||
Abi::ScalarPair(ref a, ref b) => (a, b),
|
||||
_ => bug!("store_with_flags: invalid ScalarPair layout: {:#?}", dest.layout),
|
||||
};
|
||||
let b_offset = a_scalar.value.size(bx).align_to(b_scalar.value.align(bx).abi);
|
||||
|
@ -8,8 +8,10 @@
|
||||
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::tcx::PlaceTy;
|
||||
use rustc_middle::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyAndLayout, VariantIdx};
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_target::abi::{Abi, Align, DiscriminantKind, FieldsShape, Int};
|
||||
use rustc_target::abi::{LayoutOf, VariantIdx, Variants};
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct PlaceRef<'tcx, V> {
|
||||
@ -66,7 +68,7 @@ pub fn alloca_unsized_indirect<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
}
|
||||
|
||||
pub fn len<Cx: ConstMethods<'tcx, Value = V>>(&self, cx: &Cx) -> V {
|
||||
if let layout::FieldsShape::Array { count, .. } = self.layout.fields {
|
||||
if let FieldsShape::Array { count, .. } = self.layout.fields {
|
||||
if self.layout.is_unsized() {
|
||||
assert_eq!(count, 0);
|
||||
self.llextra.unwrap()
|
||||
@ -94,7 +96,7 @@ pub fn project_field<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
// Unions and newtypes only use an offset of 0.
|
||||
let llval = if offset.bytes() == 0 {
|
||||
self.llval
|
||||
} else if let layout::Abi::ScalarPair(ref a, ref b) = self.layout.abi {
|
||||
} else if let Abi::ScalarPair(ref a, ref b) = self.layout.abi {
|
||||
// Offsets have to match either first or second field.
|
||||
assert_eq!(offset, a.value.size(bx.cx()).align_to(b.value.align(bx.cx()).abi));
|
||||
bx.struct_gep(self.llval, 1)
|
||||
@ -198,7 +200,7 @@ pub fn codegen_get_discr<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
return bx.cx().const_undef(cast_to);
|
||||
}
|
||||
let (discr_scalar, discr_kind, discr_index) = match self.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
let discr_val = self
|
||||
.layout
|
||||
.ty
|
||||
@ -206,7 +208,7 @@ pub fn codegen_get_discr<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
.map_or(index.as_u32() as u128, |discr| discr.val);
|
||||
return bx.cx().const_uint_big(cast_to, discr_val);
|
||||
}
|
||||
layout::Variants::Multiple { ref discr, ref discr_kind, discr_index, .. } => {
|
||||
Variants::Multiple { ref discr, ref discr_kind, discr_index, .. } => {
|
||||
(discr, discr_kind, discr_index)
|
||||
}
|
||||
};
|
||||
@ -217,22 +219,18 @@ pub fn codegen_get_discr<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
|
||||
// Decode the discriminant (specifically if it's niche-encoded).
|
||||
match *discr_kind {
|
||||
layout::DiscriminantKind::Tag => {
|
||||
DiscriminantKind::Tag => {
|
||||
let signed = match discr_scalar.value {
|
||||
// We use `i1` for bytes that are always `0` or `1`,
|
||||
// e.g., `#[repr(i8)] enum E { A, B }`, but we can't
|
||||
// let LLVM interpret the `i1` as signed, because
|
||||
// then `i1 1` (i.e., `E::B`) is effectively `i8 -1`.
|
||||
layout::Int(_, signed) => !discr_scalar.is_bool() && signed,
|
||||
Int(_, signed) => !discr_scalar.is_bool() && signed,
|
||||
_ => false,
|
||||
};
|
||||
bx.intcast(encoded_discr.immediate(), cast_to, signed)
|
||||
}
|
||||
layout::DiscriminantKind::Niche {
|
||||
dataful_variant,
|
||||
ref niche_variants,
|
||||
niche_start,
|
||||
} => {
|
||||
DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start } => {
|
||||
// Rebase from niche values to discriminants, and check
|
||||
// whether the result is in range for the niche variants.
|
||||
let niche_llty = bx.cx().immediate_backend_type(encoded_discr.layout);
|
||||
@ -311,14 +309,10 @@ pub fn codegen_set_discr<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
return;
|
||||
}
|
||||
match self.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
assert_eq!(index, variant_index);
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Tag,
|
||||
discr_index,
|
||||
..
|
||||
} => {
|
||||
Variants::Multiple { discr_kind: DiscriminantKind::Tag, discr_index, .. } => {
|
||||
let ptr = self.project_field(bx, discr_index);
|
||||
let to =
|
||||
self.layout.ty.discriminant_for_variant(bx.tcx(), variant_index).unwrap().val;
|
||||
@ -328,9 +322,9 @@ pub fn codegen_set_discr<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
ptr.align,
|
||||
);
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
Variants::Multiple {
|
||||
discr_kind:
|
||||
layout::DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start },
|
||||
DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start },
|
||||
discr_index,
|
||||
..
|
||||
} => {
|
||||
|
@ -8,13 +8,14 @@
|
||||
use crate::MemFlags;
|
||||
|
||||
use rustc_apfloat::{ieee, Float, Round, Status};
|
||||
use rustc_middle::middle::lang_items::ExchangeMallocFnLangItem;
|
||||
use rustc_hir::lang_items::ExchangeMallocFnLangItem;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::cast::{CastTy, IntTy};
|
||||
use rustc_middle::ty::layout::{self, HasTyCtxt, LayoutOf};
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
use rustc_middle::ty::{self, adjustment::PointerCast, Instance, Ty, TyCtxt};
|
||||
use rustc_span::source_map::{Span, DUMMY_SP};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_target::abi::{Abi, Int, LayoutOf, Variants};
|
||||
|
||||
use std::{i128, u128};
|
||||
|
||||
@ -292,7 +293,7 @@ pub fn codegen_rvalue_operand(
|
||||
let r_t_out = CastTy::from_ty(cast.ty).expect("bad output type for cast");
|
||||
let ll_t_in = bx.cx().immediate_backend_type(operand.layout);
|
||||
match operand.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
if let Some(discr) =
|
||||
operand.layout.ty.discriminant_for_variant(bx.tcx(), index)
|
||||
{
|
||||
@ -311,13 +312,13 @@ pub fn codegen_rvalue_operand(
|
||||
);
|
||||
}
|
||||
}
|
||||
layout::Variants::Multiple { .. } => {}
|
||||
Variants::Multiple { .. } => {}
|
||||
}
|
||||
let llval = operand.immediate();
|
||||
|
||||
let mut signed = false;
|
||||
if let layout::Abi::Scalar(ref scalar) = operand.layout.abi {
|
||||
if let layout::Int(_, s) = scalar.value {
|
||||
if let Abi::Scalar(ref scalar) = operand.layout.abi {
|
||||
if let Int(_, s) = scalar.value {
|
||||
// We use `i1` for bytes that are always `0` or `1`,
|
||||
// e.g., `#[repr(i8)] enum E { A, B }`, but we can't
|
||||
// let LLVM interpret the `i1` as signed, because
|
||||
|
@ -3,17 +3,18 @@
|
||||
use crate::ModuleCodegen;
|
||||
|
||||
use rustc_ast::expand::allocator::AllocatorKind;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_middle::dep_graph::DepGraph;
|
||||
use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout};
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
use rustc_session::{
|
||||
config::{self, OutputFilenames, PrintRequest},
|
||||
Session,
|
||||
};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
||||
pub use rustc_data_structures::sync::MetadataRef;
|
||||
|
||||
|
@ -12,8 +12,9 @@
|
||||
use crate::mir::place::PlaceRef;
|
||||
use crate::MemFlags;
|
||||
|
||||
use rustc_middle::ty::layout::{Align, HasParamEnv, Size};
|
||||
use rustc_middle::ty::layout::HasParamEnv;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_target::abi::{Align, Size};
|
||||
use rustc_target::spec::HasTargetSpec;
|
||||
|
||||
use std::iter::TrustedLen;
|
||||
|
@ -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 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::HasCodegen;
|
||||
use crate::common::TypeKind;
|
||||
use crate::mir::place::PlaceRef;
|
||||
use rustc_middle::ty::layout::{self, TyAndLayout};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg};
|
||||
use rustc_target::abi::Integer;
|
||||
|
||||
// This depends on `Backend` and not `BackendTypes`, because consumers will probably want to use
|
||||
// `LayoutOf` or `HasTyCtxt`. This way, they don't have to add a constraint on it themselves.
|
||||
@ -53,8 +54,8 @@ fn type_int(&self) -> Self::Type {
|
||||
}
|
||||
}
|
||||
|
||||
fn type_from_integer(&self, i: layout::Integer) -> Self::Type {
|
||||
use rustc_middle::ty::layout::Integer::*;
|
||||
fn type_from_integer(&self, i: Integer) -> Self::Type {
|
||||
use Integer::*;
|
||||
match i {
|
||||
I8 => self.type_i8(),
|
||||
I16 => self.type_i16(),
|
||||
|
@ -22,10 +22,8 @@
|
||||
use rustc_codegen_ssa::{traits::CodegenBackend, CodegenResults};
|
||||
use rustc_data_structures::profiling::print_time_passes_entry;
|
||||
use rustc_data_structures::sync::SeqCst;
|
||||
use rustc_errors::{
|
||||
registry::{InvalidErrorCode, Registry},
|
||||
PResult,
|
||||
};
|
||||
use rustc_errors::registry::{InvalidErrorCode, Registry};
|
||||
use rustc_errors::{ErrorReported, PResult};
|
||||
use rustc_feature::{find_gated_cfg, UnstableFeatures};
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_interface::util::{collect_crate_types, get_builtin_codegen_backend};
|
||||
@ -34,7 +32,6 @@
|
||||
use rustc_metadata::locator;
|
||||
use rustc_middle::middle::cstore::MetadataLoader;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
use rustc_save_analysis as save;
|
||||
use rustc_save_analysis::DumpHandler;
|
||||
use rustc_serialize::json::{self, ToJson};
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_hir_pretty as pprust_hir;
|
||||
use rustc_middle::hir::map as hir_map;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
use rustc_mir::util::{write_mir_graphviz, write_mir_pretty};
|
||||
use rustc_session::config::{Input, PpMode, PpSourceMode};
|
||||
use rustc_session::Session;
|
||||
|
@ -5,9 +5,8 @@
|
||||
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::SubregionOrigin;
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_errors::{struct_span_err, ErrorReported};
|
||||
|
||||
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
/// Print the error message for lifetime errors when both the concerned regions are anonymous.
|
||||
|
@ -1,9 +1,8 @@
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError::*;
|
||||
use crate::infer::InferCtxt;
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_errors::{DiagnosticBuilder, ErrorReported};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
use rustc_span::source_map::Span;
|
||||
|
||||
mod different_lifetimes;
|
||||
|
@ -4,9 +4,9 @@
|
||||
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError::SubSupConflict;
|
||||
use crate::infer::SubregionOrigin;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_hir::{Expr, ExprKind::Closure, Node};
|
||||
use rustc_middle::ty::RegionKind;
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
|
||||
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
/// Print the error message for lifetime errors when binding escapes a closure.
|
||||
|
@ -3,9 +3,8 @@
|
||||
use crate::infer::error_reporting::msg_span_from_free_region;
|
||||
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_errors::{Applicability, ErrorReported};
|
||||
use rustc_middle::ty::{BoundRegion, FreeRegion, RegionKind};
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
|
||||
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
/// Print the error message for lifetime errors when the return type is a static impl Trait.
|
||||
|
@ -4,8 +4,8 @@
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::{Subtype, ValuePairs};
|
||||
use crate::traits::ObligationCauseCode::CompareImplMethodObligation;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
use rustc_span::Span;
|
||||
|
||||
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
|
@ -8,9 +8,9 @@
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_data_structures::OnDrop;
|
||||
use rustc_errors::registry::Registry;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_lint::LintStore;
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
use rustc_parse::new_parser_from_source_str;
|
||||
use rustc_session::config::{self, ErrorOutputType, Input, OutputFilenames};
|
||||
use rustc_session::early_error;
|
||||
|
@ -9,7 +9,7 @@
|
||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_data_structures::sync::{par_iter, Lrc, Once, ParallelIterator, WorkerLocal};
|
||||
use rustc_data_structures::{box_region_allow_access, declare_box_region_type, parallel};
|
||||
use rustc_errors::PResult;
|
||||
use rustc_errors::{ErrorReported, PResult};
|
||||
use rustc_expand::base::ExtCtxt;
|
||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::Definitions;
|
||||
@ -21,7 +21,6 @@
|
||||
use rustc_middle::middle::cstore::{CrateStore, MetadataLoader, MetadataLoaderDyn};
|
||||
use rustc_middle::ty::steal::Steal;
|
||||
use rustc_middle::ty::{self, GlobalCtxt, ResolverOutputs, TyCtxt};
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
use rustc_mir as mir;
|
||||
use rustc_mir_build as mir_build;
|
||||
use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str};
|
||||
|
@ -4,6 +4,7 @@
|
||||
use rustc_ast::{self, ast};
|
||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_data_structures::sync::{Lrc, Once, WorkerLocal};
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_hir::Crate;
|
||||
use rustc_incremental::DepGraphFuture;
|
||||
@ -12,7 +13,6 @@
|
||||
use rustc_middle::dep_graph::DepGraph;
|
||||
use rustc_middle::ty::steal::Steal;
|
||||
use rustc_middle::ty::{GlobalCtxt, ResolverOutputs, TyCtxt};
|
||||
use rustc_middle::util::common::ErrorReported;
|
||||
use rustc_session::config::{OutputFilenames, OutputType};
|
||||
use rustc_session::{output::find_crate_name, Session};
|
||||
use rustc_span::symbol::sym;
|
||||
|
@ -148,6 +148,10 @@ pub enum LiteralKind {
|
||||
pub struct UnvalidatedRawStr {
|
||||
/// The prefix (`r###"`) is valid
|
||||
valid_start: bool,
|
||||
|
||||
/// The postfix (`"###`) is valid
|
||||
valid_end: bool,
|
||||
|
||||
/// The number of leading `#`
|
||||
n_start_hashes: usize,
|
||||
/// The number of trailing `#`. `n_end_hashes` <= `n_start_hashes`
|
||||
@ -197,7 +201,7 @@ pub fn validate(self) -> Result<ValidatedRawStr, LexRawStrError> {
|
||||
let n_start_safe: u16 =
|
||||
self.n_start_hashes.try_into().map_err(|_| LexRawStrError::TooManyDelimiters)?;
|
||||
|
||||
if self.n_start_hashes > self.n_end_hashes {
|
||||
if self.n_start_hashes > self.n_end_hashes || !self.valid_end {
|
||||
Err(LexRawStrError::NoTerminator {
|
||||
expected: self.n_start_hashes,
|
||||
found: self.n_end_hashes,
|
||||
@ -687,6 +691,7 @@ fn raw_double_quoted_string(&mut self, prefix_len: usize) -> UnvalidatedRawStr {
|
||||
_ => {
|
||||
return UnvalidatedRawStr {
|
||||
valid_start,
|
||||
valid_end: false,
|
||||
n_start_hashes,
|
||||
n_end_hashes: 0,
|
||||
possible_terminator_offset,
|
||||
@ -702,6 +707,7 @@ fn raw_double_quoted_string(&mut self, prefix_len: usize) -> UnvalidatedRawStr {
|
||||
if self.is_eof() {
|
||||
return UnvalidatedRawStr {
|
||||
valid_start,
|
||||
valid_end: false,
|
||||
n_start_hashes,
|
||||
n_end_hashes: max_hashes,
|
||||
possible_terminator_offset,
|
||||
@ -727,6 +733,7 @@ fn raw_double_quoted_string(&mut self, prefix_len: usize) -> UnvalidatedRawStr {
|
||||
if n_end_hashes == n_start_hashes {
|
||||
return UnvalidatedRawStr {
|
||||
valid_start,
|
||||
valid_end: true,
|
||||
n_start_hashes,
|
||||
n_end_hashes,
|
||||
possible_terminator_offset: None,
|
||||
|
@ -23,6 +23,7 @@ fn test_naked_raw_str() {
|
||||
n_start_hashes: 0,
|
||||
n_end_hashes: 0,
|
||||
valid_start: true,
|
||||
valid_end: true,
|
||||
possible_terminator_offset: None,
|
||||
},
|
||||
Ok(ValidatedRawStr { n_hashes: 0 }),
|
||||
@ -37,6 +38,7 @@ fn test_raw_no_start() {
|
||||
n_start_hashes: 0,
|
||||
n_end_hashes: 0,
|
||||
valid_start: true,
|
||||
valid_end: true,
|
||||
possible_terminator_offset: None,
|
||||
},
|
||||
Ok(ValidatedRawStr { n_hashes: 0 }),
|
||||
@ -51,6 +53,7 @@ fn test_too_many_terminators() {
|
||||
UnvalidatedRawStr {
|
||||
n_start_hashes: 1,
|
||||
n_end_hashes: 1,
|
||||
valid_end: true,
|
||||
valid_start: true,
|
||||
possible_terminator_offset: None,
|
||||
},
|
||||
@ -65,6 +68,7 @@ fn test_unterminated() {
|
||||
UnvalidatedRawStr {
|
||||
n_start_hashes: 1,
|
||||
n_end_hashes: 0,
|
||||
valid_end: false,
|
||||
valid_start: true,
|
||||
possible_terminator_offset: None,
|
||||
},
|
||||
@ -80,6 +84,7 @@ fn test_unterminated() {
|
||||
n_start_hashes: 2,
|
||||
n_end_hashes: 1,
|
||||
valid_start: true,
|
||||
valid_end: false,
|
||||
possible_terminator_offset: Some(7),
|
||||
},
|
||||
Err(LexRawStrError::NoTerminator {
|
||||
@ -95,6 +100,7 @@ fn test_unterminated() {
|
||||
n_start_hashes: 2,
|
||||
n_end_hashes: 0,
|
||||
valid_start: true,
|
||||
valid_end: false,
|
||||
possible_terminator_offset: None,
|
||||
},
|
||||
Err(LexRawStrError::NoTerminator {
|
||||
@ -113,9 +119,30 @@ fn test_invalid_start() {
|
||||
n_start_hashes: 1,
|
||||
n_end_hashes: 0,
|
||||
valid_start: false,
|
||||
valid_end: false,
|
||||
possible_terminator_offset: None,
|
||||
},
|
||||
Err(LexRawStrError::InvalidStarter),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_unterminated_no_pound() {
|
||||
// https://github.com/rust-lang/rust/issues/70677
|
||||
check_raw_str(
|
||||
r#"""#,
|
||||
UnvalidatedRawStr {
|
||||
n_start_hashes: 0,
|
||||
n_end_hashes: 0,
|
||||
valid_start: true,
|
||||
valid_end: false,
|
||||
possible_terminator_offset: None,
|
||||
},
|
||||
Err(LexRawStrError::NoTerminator {
|
||||
expected: 0,
|
||||
found: 0,
|
||||
possible_terminator_offset: None,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -36,12 +36,13 @@
|
||||
use rustc_hir::{GenericParamKind, PatKind};
|
||||
use rustc_hir::{HirIdSet, Node};
|
||||
use rustc_middle::lint::LintDiagnosticBuilder;
|
||||
use rustc_middle::ty::{self, layout::VariantIdx, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_session::lint::FutureIncompatibleInfo;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use rustc_trait_selection::traits::misc::can_type_implement_copy;
|
||||
|
||||
use crate::nonstandard_style::{method_context, MethodLateContext};
|
||||
|
@ -29,12 +29,13 @@
|
||||
use rustc_middle::lint::LintDiagnosticBuilder;
|
||||
use rustc_middle::middle::privacy::AccessLevels;
|
||||
use rustc_middle::middle::stability;
|
||||
use rustc_middle::ty::layout::{LayoutError, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{LayoutError, TyAndLayout};
|
||||
use rustc_middle::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt};
|
||||
use rustc_session::lint::{add_elided_lifetime_in_path_suggestion, BuiltinLintDiagnostics};
|
||||
use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
||||
use std::slice;
|
||||
|
||||
|
@ -10,12 +10,13 @@
|
||||
use rustc_hir::{is_range_literal, ExprKind, Node};
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::mir::interpret::{sign_extend, truncate};
|
||||
use rustc_middle::ty::layout::{self, IntegerExt, LayoutOf, SizeSkeleton, VariantIdx};
|
||||
use rustc_middle::ty::layout::{IntegerExt, SizeSkeleton};
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
|
||||
use rustc_span::source_map;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{DiscriminantKind, Integer, LayoutOf, VariantIdx, Variants};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use log::debug;
|
||||
@ -150,7 +151,7 @@ fn report_bin_hex_error(
|
||||
val: u128,
|
||||
negative: bool,
|
||||
) {
|
||||
let size = layout::Integer::from_attr(&cx.tcx, ty).size();
|
||||
let size = Integer::from_attr(&cx.tcx, ty).size();
|
||||
cx.struct_span_lint(OVERFLOWING_LITERALS, expr.span, |lint| {
|
||||
let (t, actually) = match ty {
|
||||
attr::IntType::SignedInt(t) => {
|
||||
@ -1034,8 +1035,8 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item<'_>) {
|
||||
| Err(ty::layout::LayoutError::SizeOverflow(_)) => return,
|
||||
};
|
||||
let (variants, tag) = match layout.variants {
|
||||
layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Tag,
|
||||
Variants::Multiple {
|
||||
discr_kind: DiscriminantKind::Tag,
|
||||
ref discr,
|
||||
ref variants,
|
||||
..
|
||||
|
@ -18,13 +18,13 @@
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::DefPathTable;
|
||||
use rustc_hir::definitions::{DefKey, DefPath, DefPathData, DefPathHash};
|
||||
use rustc_hir::lang_items;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_middle::dep_graph::{self, DepNode, DepNodeExt, DepNodeIndex};
|
||||
use rustc_middle::hir::exports::Export;
|
||||
use rustc_middle::middle::cstore::{CrateSource, ExternCrate};
|
||||
use rustc_middle::middle::cstore::{ForeignModule, LinkagePreference, NativeLibrary};
|
||||
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
|
||||
use rustc_middle::middle::lang_items;
|
||||
use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
|
||||
use rustc_middle::mir::{self, interpret, BodyAndCache, Promoted};
|
||||
use rustc_middle::ty::codec::TyDecoder;
|
||||
@ -633,7 +633,7 @@ fn is_proc_macro(&self, id: DefIndex) -> bool {
|
||||
}
|
||||
|
||||
fn maybe_kind(&self, item_id: DefIndex) -> Option<EntryKind> {
|
||||
self.root.per_def.kind.get(self, item_id).map(|k| k.decode(self))
|
||||
self.root.tables.kind.get(self, item_id).map(|k| k.decode(self))
|
||||
}
|
||||
|
||||
fn kind(&self, item_id: DefIndex) -> EntryKind {
|
||||
@ -665,7 +665,7 @@ fn item_ident(&self, item_index: DefIndex, sess: &Session) -> Ident {
|
||||
.expect("no name in item_ident");
|
||||
let span = self
|
||||
.root
|
||||
.per_def
|
||||
.tables
|
||||
.ident_span
|
||||
.get(self, item_index)
|
||||
.map(|data| data.decode((self, sess)))
|
||||
@ -688,7 +688,7 @@ fn def_kind(&self, index: DefIndex) -> Option<DefKind> {
|
||||
}
|
||||
|
||||
fn get_span(&self, index: DefIndex, sess: &Session) -> Span {
|
||||
self.root.per_def.span.get(self, index).unwrap().decode((self, sess))
|
||||
self.root.tables.span.get(self, index).unwrap().decode((self, sess))
|
||||
}
|
||||
|
||||
fn load_proc_macro(&self, id: DefIndex, sess: &Session) -> SyntaxExtension {
|
||||
@ -781,7 +781,7 @@ fn get_variant(
|
||||
ctor_did,
|
||||
data.discr,
|
||||
self.root
|
||||
.per_def
|
||||
.tables
|
||||
.children
|
||||
.get(self, index)
|
||||
.unwrap_or(Lazy::empty())
|
||||
@ -812,7 +812,7 @@ fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> &'tcx ty::AdtDef
|
||||
|
||||
let variants = if let ty::AdtKind::Enum = adt_kind {
|
||||
self.root
|
||||
.per_def
|
||||
.tables
|
||||
.children
|
||||
.get(self, item_id)
|
||||
.unwrap_or(Lazy::empty())
|
||||
@ -831,7 +831,7 @@ fn get_explicit_predicates(
|
||||
item_id: DefIndex,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> ty::GenericPredicates<'tcx> {
|
||||
self.root.per_def.explicit_predicates.get(self, item_id).unwrap().decode((self, tcx))
|
||||
self.root.tables.explicit_predicates.get(self, item_id).unwrap().decode((self, tcx))
|
||||
}
|
||||
|
||||
fn get_inferred_outlives(
|
||||
@ -840,7 +840,7 @@ fn get_inferred_outlives(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
|
||||
self.root
|
||||
.per_def
|
||||
.tables
|
||||
.inferred_outlives
|
||||
.get(self, item_id)
|
||||
.map(|predicates| predicates.decode((self, tcx)))
|
||||
@ -852,31 +852,31 @@ fn get_super_predicates(
|
||||
item_id: DefIndex,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> ty::GenericPredicates<'tcx> {
|
||||
self.root.per_def.super_predicates.get(self, item_id).unwrap().decode((self, tcx))
|
||||
self.root.tables.super_predicates.get(self, item_id).unwrap().decode((self, tcx))
|
||||
}
|
||||
|
||||
fn get_generics(&self, item_id: DefIndex, sess: &Session) -> ty::Generics {
|
||||
self.root.per_def.generics.get(self, item_id).unwrap().decode((self, sess))
|
||||
self.root.tables.generics.get(self, item_id).unwrap().decode((self, sess))
|
||||
}
|
||||
|
||||
fn get_type(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
self.root.per_def.ty.get(self, id).unwrap().decode((self, tcx))
|
||||
self.root.tables.ty.get(self, id).unwrap().decode((self, tcx))
|
||||
}
|
||||
|
||||
fn get_stability(&self, id: DefIndex) -> Option<attr::Stability> {
|
||||
match self.is_proc_macro(id) {
|
||||
true => self.root.proc_macro_stability,
|
||||
false => self.root.per_def.stability.get(self, id).map(|stab| stab.decode(self)),
|
||||
false => self.root.tables.stability.get(self, id).map(|stab| stab.decode(self)),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_const_stability(&self, id: DefIndex) -> Option<attr::ConstStability> {
|
||||
self.root.per_def.const_stability.get(self, id).map(|stab| stab.decode(self))
|
||||
self.root.tables.const_stability.get(self, id).map(|stab| stab.decode(self))
|
||||
}
|
||||
|
||||
fn get_deprecation(&self, id: DefIndex) -> Option<attr::Deprecation> {
|
||||
self.root
|
||||
.per_def
|
||||
.tables
|
||||
.deprecation
|
||||
.get(self, id)
|
||||
.filter(|_| !self.is_proc_macro(id))
|
||||
@ -886,7 +886,7 @@ fn get_deprecation(&self, id: DefIndex) -> Option<attr::Deprecation> {
|
||||
fn get_visibility(&self, id: DefIndex) -> ty::Visibility {
|
||||
match self.is_proc_macro(id) {
|
||||
true => ty::Visibility::Public,
|
||||
false => self.root.per_def.visibility.get(self, id).unwrap().decode(self),
|
||||
false => self.root.tables.visibility.get(self, id).unwrap().decode(self),
|
||||
}
|
||||
}
|
||||
|
||||
@ -914,7 +914,7 @@ fn get_coerce_unsized_info(&self, id: DefIndex) -> Option<ty::adjustment::Coerce
|
||||
}
|
||||
|
||||
fn get_impl_trait(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Option<ty::TraitRef<'tcx>> {
|
||||
self.root.per_def.impl_trait_ref.get(self, id).map(|tr| tr.decode((self, tcx)))
|
||||
self.root.tables.impl_trait_ref.get(self, id).map(|tr| tr.decode((self, tcx)))
|
||||
}
|
||||
|
||||
/// Iterates over all the stability attributes in the given crate.
|
||||
@ -984,7 +984,7 @@ fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F, sess: &Session)
|
||||
|
||||
// Iterate over all children.
|
||||
let macros_only = self.dep_kind.lock().macros_only();
|
||||
let children = self.root.per_def.children.get(self, id).unwrap_or(Lazy::empty());
|
||||
let children = self.root.tables.children.get(self, id).unwrap_or(Lazy::empty());
|
||||
for child_index in children.decode((self, sess)) {
|
||||
if macros_only {
|
||||
continue;
|
||||
@ -1004,7 +1004,7 @@ fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F, sess: &Session)
|
||||
EntryKind::ForeignMod => {
|
||||
let child_children = self
|
||||
.root
|
||||
.per_def
|
||||
.tables
|
||||
.children
|
||||
.get(self, child_index)
|
||||
.unwrap_or(Lazy::empty());
|
||||
@ -1016,7 +1016,7 @@ fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F, sess: &Session)
|
||||
vis: self.get_visibility(child_index),
|
||||
span: self
|
||||
.root
|
||||
.per_def
|
||||
.tables
|
||||
.span
|
||||
.get(self, child_index)
|
||||
.unwrap()
|
||||
@ -1096,13 +1096,13 @@ fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F, sess: &Session)
|
||||
}
|
||||
|
||||
fn is_item_mir_available(&self, id: DefIndex) -> bool {
|
||||
!self.is_proc_macro(id) && self.root.per_def.mir.get(self, id).is_some()
|
||||
!self.is_proc_macro(id) && self.root.tables.mir.get(self, id).is_some()
|
||||
}
|
||||
|
||||
fn get_optimized_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> BodyAndCache<'tcx> {
|
||||
let mut cache = self
|
||||
.root
|
||||
.per_def
|
||||
.tables
|
||||
.mir
|
||||
.get(self, id)
|
||||
.filter(|_| !self.is_proc_macro(id))
|
||||
@ -1121,7 +1121,7 @@ fn get_promoted_mir(
|
||||
) -> IndexVec<Promoted, BodyAndCache<'tcx>> {
|
||||
let mut cache = self
|
||||
.root
|
||||
.per_def
|
||||
.tables
|
||||
.promoted_mir
|
||||
.get(self, id)
|
||||
.filter(|_| !self.is_proc_macro(id))
|
||||
@ -1172,7 +1172,7 @@ fn get_associated_item(&self, id: DefIndex, sess: &Session) -> ty::AssocItem {
|
||||
}
|
||||
|
||||
fn get_item_variances(&self, id: DefIndex) -> Vec<ty::Variance> {
|
||||
self.root.per_def.variances.get(self, id).unwrap_or(Lazy::empty()).decode(self).collect()
|
||||
self.root.tables.variances.get(self, id).unwrap_or(Lazy::empty()).decode(self).collect()
|
||||
}
|
||||
|
||||
fn get_ctor_kind(&self, node_id: DefIndex) -> CtorKind {
|
||||
@ -1209,7 +1209,7 @@ fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribu
|
||||
|
||||
Lrc::from(
|
||||
self.root
|
||||
.per_def
|
||||
.tables
|
||||
.attributes
|
||||
.get(self, item_id)
|
||||
.unwrap_or(Lazy::empty())
|
||||
@ -1220,7 +1220,7 @@ fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribu
|
||||
|
||||
fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec<Spanned<ast::Name>> {
|
||||
self.root
|
||||
.per_def
|
||||
.tables
|
||||
.children
|
||||
.get(self, id)
|
||||
.unwrap_or(Lazy::empty())
|
||||
@ -1236,7 +1236,7 @@ fn get_inherent_implementations_for_type(
|
||||
) -> &'tcx [DefId] {
|
||||
tcx.arena.alloc_from_iter(
|
||||
self.root
|
||||
.per_def
|
||||
.tables
|
||||
.inherent_impls
|
||||
.get(self, id)
|
||||
.unwrap_or(Lazy::empty())
|
||||
@ -1416,7 +1416,7 @@ fn generator_kind(&self, id: DefIndex) -> Option<hir::GeneratorKind> {
|
||||
}
|
||||
|
||||
fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> {
|
||||
self.root.per_def.fn_sig.get(self, id).unwrap().decode((self, tcx))
|
||||
self.root.tables.fn_sig.get(self, id).unwrap().decode((self, tcx))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -15,6 +15,7 @@
|
||||
use rustc_hir::definitions::DefPathTable;
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::itemlikevisit::{ItemLikeVisitor, ParItemLikeVisitor};
|
||||
use rustc_hir::lang_items;
|
||||
use rustc_hir::{AnonConst, GenericParamKind};
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::hir::map::Map;
|
||||
@ -25,17 +26,16 @@
|
||||
use rustc_middle::middle::exported_symbols::{
|
||||
metadata_symbol_name, ExportedSymbol, SymbolExportLevel,
|
||||
};
|
||||
use rustc_middle::middle::lang_items;
|
||||
use rustc_middle::mir::{self, interpret};
|
||||
use rustc_middle::traits::specialization_graph;
|
||||
use rustc_middle::ty::codec::{self as ty_codec, TyEncoder};
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::{self, SymbolName, Ty, TyCtxt};
|
||||
use rustc_serialize::{opaque, Encodable, Encoder, SpecializedEncoder};
|
||||
use rustc_session::config::{self, CrateType};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::{self, ExternalSource, FileName, SourceFile, Span};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use std::hash::Hash;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::path::Path;
|
||||
@ -45,7 +45,7 @@ struct EncodeContext<'tcx> {
|
||||
opaque: opaque::Encoder,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
||||
per_def: PerDefTableBuilders<'tcx>,
|
||||
tables: TableBuilders<'tcx>,
|
||||
|
||||
lazy_state: LazyState,
|
||||
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
|
||||
@ -497,8 +497,8 @@ fn encode_crate_root(&mut self) -> Lazy<CrateRoot<'tcx>> {
|
||||
};
|
||||
|
||||
i = self.position();
|
||||
let per_def = self.per_def.encode(&mut self.opaque);
|
||||
let per_def_bytes = self.position() - i;
|
||||
let tables = self.tables.encode(&mut self.opaque);
|
||||
let tables_bytes = self.position() - i;
|
||||
|
||||
// Encode the proc macro data
|
||||
i = self.position();
|
||||
@ -560,7 +560,7 @@ fn encode_crate_root(&mut self) -> Lazy<CrateRoot<'tcx>> {
|
||||
impls,
|
||||
exported_symbols,
|
||||
interpret_alloc_index,
|
||||
per_def,
|
||||
tables,
|
||||
});
|
||||
|
||||
let total_bytes = self.position();
|
||||
@ -585,7 +585,7 @@ fn encode_crate_root(&mut self) -> Lazy<CrateRoot<'tcx>> {
|
||||
println!(" def-path table bytes: {}", def_path_table_bytes);
|
||||
println!(" proc-macro-data-bytes: {}", proc_macro_data_bytes);
|
||||
println!(" item bytes: {}", item_bytes);
|
||||
println!(" per-def table bytes: {}", per_def_bytes);
|
||||
println!(" table bytes: {}", tables_bytes);
|
||||
println!(" zero bytes: {}", zero_bytes);
|
||||
println!(" total bytes: {}", total_bytes);
|
||||
}
|
||||
@ -597,12 +597,12 @@ fn encode_crate_root(&mut self) -> Lazy<CrateRoot<'tcx>> {
|
||||
impl EncodeContext<'tcx> {
|
||||
fn encode_variances_of(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_variances_of({:?})", def_id);
|
||||
record!(self.per_def.variances[def_id] <- &self.tcx.variances_of(def_id)[..]);
|
||||
record!(self.tables.variances[def_id] <- &self.tcx.variances_of(def_id)[..]);
|
||||
}
|
||||
|
||||
fn encode_item_type(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_item_type({:?})", def_id);
|
||||
record!(self.per_def.ty[def_id] <- self.tcx.type_of(def_id));
|
||||
record!(self.tables.ty[def_id] <- self.tcx.type_of(def_id));
|
||||
}
|
||||
|
||||
fn encode_enum_variant_info(&mut self, enum_did: DefId, index: VariantIdx) {
|
||||
@ -621,12 +621,12 @@ fn encode_enum_variant_info(&mut self, enum_did: DefId, index: VariantIdx) {
|
||||
let enum_id = tcx.hir().as_local_hir_id(enum_did).unwrap();
|
||||
let enum_vis = &tcx.hir().expect_item(enum_id).vis;
|
||||
|
||||
record!(self.per_def.kind[def_id] <- EntryKind::Variant(self.lazy(data)));
|
||||
record!(self.per_def.visibility[def_id] <-
|
||||
record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data)));
|
||||
record!(self.tables.visibility[def_id] <-
|
||||
ty::Visibility::from_hir(enum_vis, enum_id, self.tcx));
|
||||
record!(self.per_def.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.per_def.attributes[def_id] <- &self.tcx.get_attrs(def_id)[..]);
|
||||
record!(self.per_def.children[def_id] <- variant.fields.iter().map(|f| {
|
||||
record!(self.tables.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.tables.attributes[def_id] <- &self.tcx.get_attrs(def_id)[..]);
|
||||
record!(self.tables.children[def_id] <- variant.fields.iter().map(|f| {
|
||||
assert!(f.did.is_local());
|
||||
f.did.index
|
||||
}));
|
||||
@ -637,7 +637,7 @@ fn encode_enum_variant_info(&mut self, enum_did: DefId, index: VariantIdx) {
|
||||
if variant.ctor_kind == CtorKind::Fn {
|
||||
// FIXME(eddyb) encode signature only in `encode_enum_variant_ctor`.
|
||||
if let Some(ctor_def_id) = variant.ctor_def_id {
|
||||
record!(self.per_def.fn_sig[def_id] <- tcx.fn_sig(ctor_def_id));
|
||||
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(ctor_def_id));
|
||||
}
|
||||
// FIXME(eddyb) is this ever used?
|
||||
self.encode_variances_of(def_id);
|
||||
@ -672,14 +672,14 @@ fn encode_enum_variant_ctor(&mut self, enum_did: DefId, index: VariantIdx) {
|
||||
ctor_vis = ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX));
|
||||
}
|
||||
|
||||
record!(self.per_def.kind[def_id] <- EntryKind::Variant(self.lazy(data)));
|
||||
record!(self.per_def.visibility[def_id] <- ctor_vis);
|
||||
record!(self.per_def.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data)));
|
||||
record!(self.tables.visibility[def_id] <- ctor_vis);
|
||||
record!(self.tables.span[def_id] <- self.tcx.def_span(def_id));
|
||||
self.encode_stability(def_id);
|
||||
self.encode_deprecation(def_id);
|
||||
self.encode_item_type(def_id);
|
||||
if variant.ctor_kind == CtorKind::Fn {
|
||||
record!(self.per_def.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
self.encode_variances_of(def_id);
|
||||
}
|
||||
self.encode_generics(def_id);
|
||||
@ -707,11 +707,11 @@ fn encode_info_for_mod(
|
||||
},
|
||||
};
|
||||
|
||||
record!(self.per_def.kind[def_id] <- EntryKind::Mod(self.lazy(data)));
|
||||
record!(self.per_def.visibility[def_id] <- ty::Visibility::from_hir(vis, id, self.tcx));
|
||||
record!(self.per_def.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.per_def.attributes[def_id] <- attrs);
|
||||
record!(self.per_def.children[def_id] <- md.item_ids.iter().map(|item_id| {
|
||||
record!(self.tables.kind[def_id] <- EntryKind::Mod(self.lazy(data)));
|
||||
record!(self.tables.visibility[def_id] <- ty::Visibility::from_hir(vis, id, self.tcx));
|
||||
record!(self.tables.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.tables.attributes[def_id] <- attrs);
|
||||
record!(self.tables.children[def_id] <- md.item_ids.iter().map(|item_id| {
|
||||
tcx.hir().local_def_id(item_id.id).index
|
||||
}));
|
||||
self.encode_stability(def_id);
|
||||
@ -729,10 +729,10 @@ fn encode_field(&mut self, adt_def_id: DefId, variant_index: VariantIdx, field_i
|
||||
let variant_id = tcx.hir().as_local_hir_id(variant.def_id).unwrap();
|
||||
let variant_data = tcx.hir().expect_variant_data(variant_id);
|
||||
|
||||
record!(self.per_def.kind[def_id] <- EntryKind::Field);
|
||||
record!(self.per_def.visibility[def_id] <- field.vis);
|
||||
record!(self.per_def.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.per_def.attributes[def_id] <- variant_data.fields()[field_index].attrs);
|
||||
record!(self.tables.kind[def_id] <- EntryKind::Field);
|
||||
record!(self.tables.visibility[def_id] <- field.vis);
|
||||
record!(self.tables.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.tables.attributes[def_id] <- variant_data.fields()[field_index].attrs);
|
||||
self.encode_ident_span(def_id, field.ident);
|
||||
self.encode_stability(def_id);
|
||||
self.encode_deprecation(def_id);
|
||||
@ -771,14 +771,14 @@ fn encode_struct_ctor(&mut self, adt_def_id: DefId, def_id: DefId) {
|
||||
ctor_vis = ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX));
|
||||
}
|
||||
|
||||
record!(self.per_def.kind[def_id] <- EntryKind::Struct(self.lazy(data), adt_def.repr));
|
||||
record!(self.per_def.visibility[def_id] <- ctor_vis);
|
||||
record!(self.per_def.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.tables.kind[def_id] <- EntryKind::Struct(self.lazy(data), adt_def.repr));
|
||||
record!(self.tables.visibility[def_id] <- ctor_vis);
|
||||
record!(self.tables.span[def_id] <- self.tcx.def_span(def_id));
|
||||
self.encode_stability(def_id);
|
||||
self.encode_deprecation(def_id);
|
||||
self.encode_item_type(def_id);
|
||||
if variant.ctor_kind == CtorKind::Fn {
|
||||
record!(self.per_def.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
self.encode_variances_of(def_id);
|
||||
}
|
||||
self.encode_generics(def_id);
|
||||
@ -790,12 +790,12 @@ fn encode_struct_ctor(&mut self, adt_def_id: DefId, def_id: DefId) {
|
||||
|
||||
fn encode_generics(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_generics({:?})", def_id);
|
||||
record!(self.per_def.generics[def_id] <- self.tcx.generics_of(def_id));
|
||||
record!(self.tables.generics[def_id] <- self.tcx.generics_of(def_id));
|
||||
}
|
||||
|
||||
fn encode_explicit_predicates(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_explicit_predicates({:?})", def_id);
|
||||
record!(self.per_def.explicit_predicates[def_id] <-
|
||||
record!(self.tables.explicit_predicates[def_id] <-
|
||||
self.tcx.explicit_predicates_of(def_id));
|
||||
}
|
||||
|
||||
@ -803,13 +803,13 @@ fn encode_inferred_outlives(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_inferred_outlives({:?})", def_id);
|
||||
let inferred_outlives = self.tcx.inferred_outlives_of(def_id);
|
||||
if !inferred_outlives.is_empty() {
|
||||
record!(self.per_def.inferred_outlives[def_id] <- inferred_outlives);
|
||||
record!(self.tables.inferred_outlives[def_id] <- inferred_outlives);
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_super_predicates(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_super_predicates({:?})", def_id);
|
||||
record!(self.per_def.super_predicates[def_id] <- self.tcx.super_predicates_of(def_id));
|
||||
record!(self.tables.super_predicates[def_id] <- self.tcx.super_predicates_of(def_id));
|
||||
}
|
||||
|
||||
fn encode_info_for_trait_item(&mut self, def_id: DefId) {
|
||||
@ -826,7 +826,7 @@ fn encode_info_for_trait_item(&mut self, def_id: DefId) {
|
||||
hir::Defaultness::Final => span_bug!(ast_item.span, "traits cannot have final items"),
|
||||
};
|
||||
|
||||
record!(self.per_def.kind[def_id] <- match trait_item.kind {
|
||||
record!(self.tables.kind[def_id] <- match trait_item.kind {
|
||||
ty::AssocKind::Const => {
|
||||
let rendered = rustc_hir_pretty::to_string(
|
||||
&(&self.tcx.hir() as &dyn intravisit::Map<'_>),
|
||||
@ -867,9 +867,9 @@ fn encode_info_for_trait_item(&mut self, def_id: DefId) {
|
||||
ty::AssocKind::Type => EntryKind::AssocType(container),
|
||||
ty::AssocKind::OpaqueTy => span_bug!(ast_item.span, "opaque type in trait"),
|
||||
});
|
||||
record!(self.per_def.visibility[def_id] <- trait_item.vis);
|
||||
record!(self.per_def.span[def_id] <- ast_item.span);
|
||||
record!(self.per_def.attributes[def_id] <- ast_item.attrs);
|
||||
record!(self.tables.visibility[def_id] <- trait_item.vis);
|
||||
record!(self.tables.span[def_id] <- ast_item.span);
|
||||
record!(self.tables.attributes[def_id] <- ast_item.attrs);
|
||||
self.encode_ident_span(def_id, ast_item.ident);
|
||||
self.encode_stability(def_id);
|
||||
self.encode_const_stability(def_id);
|
||||
@ -886,7 +886,7 @@ fn encode_info_for_trait_item(&mut self, def_id: DefId) {
|
||||
ty::AssocKind::OpaqueTy => unreachable!(),
|
||||
}
|
||||
if trait_item.kind == ty::AssocKind::Method {
|
||||
record!(self.per_def.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
self.encode_variances_of(def_id);
|
||||
}
|
||||
self.encode_generics(def_id);
|
||||
@ -919,7 +919,7 @@ fn encode_info_for_impl_item(&mut self, def_id: DefId) {
|
||||
}
|
||||
};
|
||||
|
||||
record!(self.per_def.kind[def_id] <- match impl_item.kind {
|
||||
record!(self.tables.kind[def_id] <- match impl_item.kind {
|
||||
ty::AssocKind::Const => {
|
||||
if let hir::ImplItemKind::Const(_, body_id) = ast_item.kind {
|
||||
let qualifs = self.tcx.at(ast_item.span).mir_const_qualif(def_id);
|
||||
@ -951,16 +951,16 @@ fn encode_info_for_impl_item(&mut self, def_id: DefId) {
|
||||
ty::AssocKind::OpaqueTy => EntryKind::AssocOpaqueTy(container),
|
||||
ty::AssocKind::Type => EntryKind::AssocType(container)
|
||||
});
|
||||
record!(self.per_def.visibility[def_id] <- impl_item.vis);
|
||||
record!(self.per_def.span[def_id] <- ast_item.span);
|
||||
record!(self.per_def.attributes[def_id] <- ast_item.attrs);
|
||||
record!(self.tables.visibility[def_id] <- impl_item.vis);
|
||||
record!(self.tables.span[def_id] <- ast_item.span);
|
||||
record!(self.tables.attributes[def_id] <- ast_item.attrs);
|
||||
self.encode_ident_span(def_id, impl_item.ident);
|
||||
self.encode_stability(def_id);
|
||||
self.encode_const_stability(def_id);
|
||||
self.encode_deprecation(def_id);
|
||||
self.encode_item_type(def_id);
|
||||
if impl_item.kind == ty::AssocKind::Method {
|
||||
record!(self.per_def.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
self.encode_variances_of(def_id);
|
||||
}
|
||||
self.encode_generics(def_id);
|
||||
@ -1005,14 +1005,14 @@ fn encode_fn_param_names(&mut self, param_names: &[ast::Ident]) -> Lazy<[ast::Na
|
||||
fn encode_optimized_mir(&mut self, def_id: DefId) {
|
||||
debug!("EntryBuilder::encode_mir({:?})", def_id);
|
||||
if self.tcx.mir_keys(LOCAL_CRATE).contains(&def_id) {
|
||||
record!(self.per_def.mir[def_id] <- self.tcx.optimized_mir(def_id));
|
||||
record!(self.tables.mir[def_id] <- self.tcx.optimized_mir(def_id));
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_promoted_mir(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_promoted_mir({:?})", def_id);
|
||||
if self.tcx.mir_keys(LOCAL_CRATE).contains(&def_id) {
|
||||
record!(self.per_def.promoted_mir[def_id] <- self.tcx.promoted_mir(def_id));
|
||||
record!(self.tables.promoted_mir[def_id] <- self.tcx.promoted_mir(def_id));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1021,7 +1021,7 @@ fn encode_inherent_implementations(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_inherent_implementations({:?})", def_id);
|
||||
let implementations = self.tcx.inherent_impls(def_id);
|
||||
if !implementations.is_empty() {
|
||||
record!(self.per_def.inherent_impls[def_id] <- implementations.iter().map(|&def_id| {
|
||||
record!(self.tables.inherent_impls[def_id] <- implementations.iter().map(|&def_id| {
|
||||
assert!(def_id.is_local());
|
||||
def_id.index
|
||||
}));
|
||||
@ -1031,21 +1031,21 @@ fn encode_inherent_implementations(&mut self, def_id: DefId) {
|
||||
fn encode_stability(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_stability({:?})", def_id);
|
||||
if let Some(stab) = self.tcx.lookup_stability(def_id) {
|
||||
record!(self.per_def.stability[def_id] <- stab)
|
||||
record!(self.tables.stability[def_id] <- stab)
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_const_stability(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_const_stability({:?})", def_id);
|
||||
if let Some(stab) = self.tcx.lookup_const_stability(def_id) {
|
||||
record!(self.per_def.const_stability[def_id] <- stab)
|
||||
record!(self.tables.const_stability[def_id] <- stab)
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_deprecation(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_deprecation({:?})", def_id);
|
||||
if let Some(depr) = self.tcx.lookup_deprecation(def_id) {
|
||||
record!(self.per_def.deprecation[def_id] <- depr);
|
||||
record!(self.tables.deprecation[def_id] <- depr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1066,7 +1066,7 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) {
|
||||
|
||||
self.encode_ident_span(def_id, item.ident);
|
||||
|
||||
record!(self.per_def.kind[def_id] <- match item.kind {
|
||||
record!(self.tables.kind[def_id] <- match item.kind {
|
||||
hir::ItemKind::Static(_, hir::Mutability::Mut, _) => EntryKind::MutStatic,
|
||||
hir::ItemKind::Static(_, hir::Mutability::Not, _) => EntryKind::ImmStatic,
|
||||
hir::ItemKind::Const(_, body_id) => {
|
||||
@ -1172,26 +1172,26 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) {
|
||||
hir::ItemKind::ExternCrate(_) |
|
||||
hir::ItemKind::Use(..) => bug!("cannot encode info for item {:?}", item),
|
||||
});
|
||||
record!(self.per_def.visibility[def_id] <-
|
||||
record!(self.tables.visibility[def_id] <-
|
||||
ty::Visibility::from_hir(&item.vis, item.hir_id, tcx));
|
||||
record!(self.per_def.span[def_id] <- item.span);
|
||||
record!(self.per_def.attributes[def_id] <- item.attrs);
|
||||
record!(self.tables.span[def_id] <- item.span);
|
||||
record!(self.tables.attributes[def_id] <- item.attrs);
|
||||
// FIXME(eddyb) there should be a nicer way to do this.
|
||||
match item.kind {
|
||||
hir::ItemKind::ForeignMod(ref fm) => record!(self.per_def.children[def_id] <-
|
||||
hir::ItemKind::ForeignMod(ref fm) => record!(self.tables.children[def_id] <-
|
||||
fm.items
|
||||
.iter()
|
||||
.map(|foreign_item| tcx.hir().local_def_id(
|
||||
foreign_item.hir_id).index)
|
||||
),
|
||||
hir::ItemKind::Enum(..) => record!(self.per_def.children[def_id] <-
|
||||
hir::ItemKind::Enum(..) => record!(self.tables.children[def_id] <-
|
||||
self.tcx.adt_def(def_id).variants.iter().map(|v| {
|
||||
assert!(v.def_id.is_local());
|
||||
v.def_id.index
|
||||
})
|
||||
),
|
||||
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
|
||||
record!(self.per_def.children[def_id] <-
|
||||
record!(self.tables.children[def_id] <-
|
||||
self.tcx.adt_def(def_id).non_enum_variant().fields.iter().map(|f| {
|
||||
assert!(f.did.is_local());
|
||||
f.did.index
|
||||
@ -1200,7 +1200,7 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) {
|
||||
}
|
||||
hir::ItemKind::Impl { .. } | hir::ItemKind::Trait(..) => {
|
||||
let associated_item_def_ids = self.tcx.associated_item_def_ids(def_id);
|
||||
record!(self.per_def.children[def_id] <-
|
||||
record!(self.tables.children[def_id] <-
|
||||
associated_item_def_ids.iter().map(|&def_id| {
|
||||
assert!(def_id.is_local());
|
||||
def_id.index
|
||||
@ -1225,11 +1225,11 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) {
|
||||
_ => {}
|
||||
}
|
||||
if let hir::ItemKind::Fn(..) = item.kind {
|
||||
record!(self.per_def.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
}
|
||||
if let hir::ItemKind::Impl { .. } = item.kind {
|
||||
if let Some(trait_ref) = self.tcx.impl_trait_ref(def_id) {
|
||||
record!(self.per_def.impl_trait_ref[def_id] <- trait_ref);
|
||||
record!(self.tables.impl_trait_ref[def_id] <- trait_ref);
|
||||
}
|
||||
}
|
||||
self.encode_inherent_implementations(def_id);
|
||||
@ -1288,19 +1288,19 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) {
|
||||
/// Serialize the text of exported macros
|
||||
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef<'_>) {
|
||||
let def_id = self.tcx.hir().local_def_id(macro_def.hir_id);
|
||||
record!(self.per_def.kind[def_id] <- EntryKind::MacroDef(self.lazy(macro_def.ast.clone())));
|
||||
record!(self.per_def.visibility[def_id] <- ty::Visibility::Public);
|
||||
record!(self.per_def.span[def_id] <- macro_def.span);
|
||||
record!(self.per_def.attributes[def_id] <- macro_def.attrs);
|
||||
record!(self.tables.kind[def_id] <- EntryKind::MacroDef(self.lazy(macro_def.ast.clone())));
|
||||
record!(self.tables.visibility[def_id] <- ty::Visibility::Public);
|
||||
record!(self.tables.span[def_id] <- macro_def.span);
|
||||
record!(self.tables.attributes[def_id] <- macro_def.attrs);
|
||||
self.encode_ident_span(def_id, macro_def.ident);
|
||||
self.encode_stability(def_id);
|
||||
self.encode_deprecation(def_id);
|
||||
}
|
||||
|
||||
fn encode_info_for_generic_param(&mut self, def_id: DefId, kind: EntryKind, encode_type: bool) {
|
||||
record!(self.per_def.kind[def_id] <- kind);
|
||||
record!(self.per_def.visibility[def_id] <- ty::Visibility::Public);
|
||||
record!(self.per_def.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.tables.kind[def_id] <- kind);
|
||||
record!(self.tables.visibility[def_id] <- ty::Visibility::Public);
|
||||
record!(self.tables.span[def_id] <- self.tcx.def_span(def_id));
|
||||
if encode_type {
|
||||
self.encode_item_type(def_id);
|
||||
}
|
||||
@ -1314,7 +1314,7 @@ fn encode_info_for_closure(&mut self, def_id: DefId) {
|
||||
let hir_id = self.tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
let ty = self.tcx.typeck_tables_of(def_id).node_type(hir_id);
|
||||
|
||||
record!(self.per_def.kind[def_id] <- match ty.kind {
|
||||
record!(self.tables.kind[def_id] <- match ty.kind {
|
||||
ty::Generator(..) => {
|
||||
let data = self.tcx.generator_kind(def_id).unwrap();
|
||||
EntryKind::Generator(data)
|
||||
@ -1324,12 +1324,12 @@ fn encode_info_for_closure(&mut self, def_id: DefId) {
|
||||
|
||||
_ => bug!("closure that is neither generator nor closure"),
|
||||
});
|
||||
record!(self.per_def.visibility[def_id] <- ty::Visibility::Public);
|
||||
record!(self.per_def.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.per_def.attributes[def_id] <- &self.tcx.get_attrs(def_id)[..]);
|
||||
record!(self.tables.visibility[def_id] <- ty::Visibility::Public);
|
||||
record!(self.tables.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.tables.attributes[def_id] <- &self.tcx.get_attrs(def_id)[..]);
|
||||
self.encode_item_type(def_id);
|
||||
if let ty::Closure(def_id, substs) = ty.kind {
|
||||
record!(self.per_def.fn_sig[def_id] <- substs.as_closure().sig());
|
||||
record!(self.tables.fn_sig[def_id] <- substs.as_closure().sig());
|
||||
}
|
||||
self.encode_generics(def_id);
|
||||
self.encode_optimized_mir(def_id);
|
||||
@ -1343,9 +1343,9 @@ fn encode_info_for_anon_const(&mut self, def_id: DefId) {
|
||||
let const_data = self.encode_rendered_const_for_body(body_id);
|
||||
let qualifs = self.tcx.mir_const_qualif(def_id);
|
||||
|
||||
record!(self.per_def.kind[def_id] <- EntryKind::Const(qualifs, const_data));
|
||||
record!(self.per_def.visibility[def_id] <- ty::Visibility::Public);
|
||||
record!(self.per_def.span[def_id] <- self.tcx.def_span(def_id));
|
||||
record!(self.tables.kind[def_id] <- EntryKind::Const(qualifs, const_data));
|
||||
record!(self.tables.visibility[def_id] <- ty::Visibility::Public);
|
||||
record!(self.tables.span[def_id] <- self.tcx.def_span(def_id));
|
||||
self.encode_item_type(def_id);
|
||||
self.encode_generics(def_id);
|
||||
self.encode_explicit_predicates(def_id);
|
||||
@ -1516,7 +1516,7 @@ fn encode_info_for_foreign_item(&mut self, def_id: DefId, nitem: &hir::ForeignIt
|
||||
|
||||
debug!("EncodeContext::encode_info_for_foreign_item({:?})", def_id);
|
||||
|
||||
record!(self.per_def.kind[def_id] <- match nitem.kind {
|
||||
record!(self.tables.kind[def_id] <- match nitem.kind {
|
||||
hir::ForeignItemKind::Fn(_, ref names, _) => {
|
||||
let data = FnData {
|
||||
asyncness: hir::IsAsync::NotAsync,
|
||||
@ -1533,17 +1533,17 @@ fn encode_info_for_foreign_item(&mut self, def_id: DefId, nitem: &hir::ForeignIt
|
||||
hir::ForeignItemKind::Static(_, hir::Mutability::Not) => EntryKind::ForeignImmStatic,
|
||||
hir::ForeignItemKind::Type => EntryKind::ForeignType,
|
||||
});
|
||||
record!(self.per_def.visibility[def_id] <-
|
||||
record!(self.tables.visibility[def_id] <-
|
||||
ty::Visibility::from_hir(&nitem.vis, nitem.hir_id, self.tcx));
|
||||
record!(self.per_def.span[def_id] <- nitem.span);
|
||||
record!(self.per_def.attributes[def_id] <- nitem.attrs);
|
||||
record!(self.tables.span[def_id] <- nitem.span);
|
||||
record!(self.tables.attributes[def_id] <- nitem.attrs);
|
||||
self.encode_ident_span(def_id, nitem.ident);
|
||||
self.encode_stability(def_id);
|
||||
self.encode_const_stability(def_id);
|
||||
self.encode_deprecation(def_id);
|
||||
self.encode_item_type(def_id);
|
||||
if let hir::ForeignItemKind::Fn(..) = nitem.kind {
|
||||
record!(self.per_def.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||
self.encode_variances_of(def_id);
|
||||
}
|
||||
self.encode_generics(def_id);
|
||||
@ -1630,7 +1630,7 @@ fn encode_info_for_expr(&mut self, expr: &hir::Expr<'_>) {
|
||||
}
|
||||
|
||||
fn encode_ident_span(&mut self, def_id: DefId, ident: Ident) {
|
||||
record!(self.per_def.ident_span[def_id] <- ident.span);
|
||||
record!(self.tables.ident_span[def_id] <- ident.span);
|
||||
}
|
||||
|
||||
/// In some cases, along with the item itself, we also
|
||||
@ -1846,7 +1846,7 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
|
||||
let mut ecx = EncodeContext {
|
||||
opaque: encoder,
|
||||
tcx,
|
||||
per_def: Default::default(),
|
||||
tables: Default::default(),
|
||||
lazy_state: LazyState::NoNode,
|
||||
type_shorthands: Default::default(),
|
||||
predicate_shorthands: Default::default(),
|
||||
|
@ -8,11 +8,11 @@
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::CtorKind;
|
||||
use rustc_hir::def_id::{DefId, DefIndex};
|
||||
use rustc_hir::lang_items;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::hir::exports::Export;
|
||||
use rustc_middle::middle::cstore::{DepKind, ForeignModule, LinkagePreference, NativeLibrary};
|
||||
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
|
||||
use rustc_middle::middle::lang_items;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::{self, ReprOptions, Ty};
|
||||
use rustc_serialize::opaque::Encoder;
|
||||
@ -197,7 +197,7 @@ macro_rules! Lazy {
|
||||
impls: Lazy<[TraitImpls]>,
|
||||
interpret_alloc_index: Lazy<[u32]>,
|
||||
|
||||
per_def: LazyPerDefTables<'tcx>,
|
||||
tables: LazyTables<'tcx>,
|
||||
|
||||
/// The DefIndex's of any proc macros declared by this crate.
|
||||
proc_macro_data: Option<Lazy<[DefIndex]>>,
|
||||
@ -228,22 +228,22 @@ macro_rules! Lazy {
|
||||
impls: Lazy<[DefIndex]>,
|
||||
}
|
||||
|
||||
/// Define `LazyPerDefTables` and `PerDefTableBuilders` at the same time.
|
||||
macro_rules! define_per_def_tables {
|
||||
/// Define `LazyTables` and `TableBuilders` at the same time.
|
||||
macro_rules! define_tables {
|
||||
($($name:ident: Table<DefIndex, $T:ty>),+ $(,)?) => {
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
crate struct LazyPerDefTables<'tcx> {
|
||||
crate struct LazyTables<'tcx> {
|
||||
$($name: Lazy!(Table<DefIndex, $T>)),+
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct PerDefTableBuilders<'tcx> {
|
||||
struct TableBuilders<'tcx> {
|
||||
$($name: TableBuilder<DefIndex, $T>),+
|
||||
}
|
||||
|
||||
impl PerDefTableBuilders<'tcx> {
|
||||
fn encode(&self, buf: &mut Encoder) -> LazyPerDefTables<'tcx> {
|
||||
LazyPerDefTables {
|
||||
impl TableBuilders<'tcx> {
|
||||
fn encode(&self, buf: &mut Encoder) -> LazyTables<'tcx> {
|
||||
LazyTables {
|
||||
$($name: self.$name.encode(buf)),+
|
||||
}
|
||||
}
|
||||
@ -251,7 +251,7 @@ fn encode(&self, buf: &mut Encoder) -> LazyPerDefTables<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
define_per_def_tables! {
|
||||
define_tables! {
|
||||
kind: Table<DefIndex, Lazy<EntryKind>>,
|
||||
visibility: Table<DefIndex, Lazy<ty::Visibility>>,
|
||||
span: Table<DefIndex, Lazy<Span>>,
|
||||
|
@ -11,7 +11,7 @@
|
||||
macro_rules! arena_types {
|
||||
($macro:path, $args:tt, $tcx:lifetime) => (
|
||||
$macro!($args, [
|
||||
[] layouts: rustc_middle::ty::layout::Layout,
|
||||
[] layouts: rustc_target::abi::Layout,
|
||||
[] generics: rustc_middle::ty::Generics,
|
||||
[] trait_def: rustc_middle::ty::TraitDef,
|
||||
[] adt_def: rustc_middle::ty::AdtDef,
|
||||
@ -106,7 +106,7 @@ macro_rules! arena_types {
|
||||
String
|
||||
>,
|
||||
[few] get_lib_features: rustc_middle::middle::lib_features::LibFeatures,
|
||||
[few] defined_lib_features: rustc_middle::middle::lang_items::LanguageItems,
|
||||
[few] defined_lib_features: rustc_hir::lang_items::LanguageItems,
|
||||
[few] visible_parent_map: rustc_hir::def_id::DefIdMap<rustc_hir::def_id::DefId>,
|
||||
[few] foreign_module: rustc_middle::middle::cstore::ForeignModule,
|
||||
[few] foreign_modules: Vec<rustc_middle::middle::cstore::ForeignModule>,
|
||||
|
@ -4,7 +4,6 @@
|
||||
hash_stable_trait_impls, NodeIdHashingMode, StableHashingContext, StableHashingContextProvider,
|
||||
};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
pub use rustc_span::CachingSourceMapView;
|
||||
|
||||
mod hcx;
|
||||
|
||||
|
@ -7,17 +7,13 @@
|
||||
//! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`.
|
||||
//! * Functions called by the compiler itself.
|
||||
|
||||
pub use self::LangItem::*;
|
||||
|
||||
use crate::ty::{self, TyCtxt};
|
||||
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
pub use rustc_hir::weak_lang_items::link_name;
|
||||
pub use rustc_hir::{LangItem, LanguageItems};
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
/// Returns the `DefId` for a given `LangItem`.
|
||||
/// If not found, fatally aborts compilation.
|
||||
|
@ -7,14 +7,12 @@
|
||||
|
||||
use rustc_ast::ast::Mutability;
|
||||
use rustc_data_structures::sorted_map::SortedMap;
|
||||
use rustc_target::abi::HasDataLayout;
|
||||
use rustc_target::abi::{Align, HasDataLayout, Size};
|
||||
|
||||
use super::{
|
||||
read_target_uint, write_target_uint, AllocId, InterpResult, Pointer, Scalar, ScalarMaybeUndef,
|
||||
};
|
||||
|
||||
use crate::ty::layout::{Align, Size};
|
||||
|
||||
// NOTE: When adding new fields, make sure to adjust the `Snapshot` impl in
|
||||
// `src/librustc_mir/interpret/snapshot.rs`.
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::{AllocId, CheckInAllocMsg, Pointer, RawConst, ScalarMaybeUndef};
|
||||
|
||||
use crate::mir::interpret::ConstValue;
|
||||
use crate::ty::layout::{Align, LayoutError, Size};
|
||||
use crate::ty::layout::LayoutError;
|
||||
use crate::ty::query::TyCtxtAt;
|
||||
use crate::ty::tls;
|
||||
use crate::ty::{self, layout, Ty};
|
||||
@ -14,6 +14,7 @@
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_session::CtfeBacktrace;
|
||||
use rustc_span::{def_id::DefId, Pos, Span};
|
||||
use rustc_target::abi::{Align, Size};
|
||||
use std::{any::Any, fmt, mem};
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable)]
|
||||
|
@ -109,10 +109,10 @@ macro_rules! throw_machine_stop {
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_serialize::{Decodable, Encodable, Encoder};
|
||||
use rustc_target::abi::{Endian, Size};
|
||||
|
||||
use crate::mir;
|
||||
use crate::ty::codec::TyDecoder;
|
||||
use crate::ty::layout::{self, Size};
|
||||
use crate::ty::subst::GenericArgKind;
|
||||
use crate::ty::{self, Instance, Ty, TyCtxt};
|
||||
|
||||
@ -521,22 +521,22 @@ fn set_alloc_id_same_memory(&mut self, id: AllocId, mem: &'tcx Allocation) {
|
||||
|
||||
#[inline]
|
||||
pub fn write_target_uint(
|
||||
endianness: layout::Endian,
|
||||
endianness: Endian,
|
||||
mut target: &mut [u8],
|
||||
data: u128,
|
||||
) -> Result<(), io::Error> {
|
||||
let len = target.len();
|
||||
match endianness {
|
||||
layout::Endian::Little => target.write_uint128::<LittleEndian>(data, len),
|
||||
layout::Endian::Big => target.write_uint128::<BigEndian>(data, len),
|
||||
Endian::Little => target.write_uint128::<LittleEndian>(data, len),
|
||||
Endian::Big => target.write_uint128::<BigEndian>(data, len),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn read_target_uint(endianness: layout::Endian, mut source: &[u8]) -> Result<u128, io::Error> {
|
||||
pub fn read_target_uint(endianness: Endian, mut source: &[u8]) -> Result<u128, io::Error> {
|
||||
match endianness {
|
||||
layout::Endian::Little => source.read_uint128::<LittleEndian>(source.len()),
|
||||
layout::Endian::Big => source.read_uint128::<BigEndian>(source.len()),
|
||||
Endian::Little => source.read_uint128::<LittleEndian>(source.len()),
|
||||
Endian::Big => source.read_uint128::<BigEndian>(source.len()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
use super::{AllocId, InterpResult};
|
||||
|
||||
use crate::ty::layout::{self, HasDataLayout, Size};
|
||||
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_target::abi::{HasDataLayout, Size};
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::{self, Display};
|
||||
@ -37,7 +36,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// Pointer arithmetic
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub trait PointerArithmetic: layout::HasDataLayout {
|
||||
pub trait PointerArithmetic: HasDataLayout {
|
||||
// These are not supposed to be overridden.
|
||||
|
||||
#[inline(always)]
|
||||
@ -100,7 +99,7 @@ fn signed_offset<'tcx>(&self, val: u64, i: i64) -> InterpResult<'tcx, u64> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: layout::HasDataLayout> PointerArithmetic for T {}
|
||||
impl<T: HasDataLayout> PointerArithmetic for T {}
|
||||
|
||||
/// `Pointer` is generic over the type that represents a reference to `Allocation`s,
|
||||
/// thus making it possible for the most convenient representation to be used in
|
||||
|
@ -6,12 +6,9 @@
|
||||
Float,
|
||||
};
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_target::abi::TargetDataLayout;
|
||||
use rustc_target::abi::{HasDataLayout, Size, TargetDataLayout};
|
||||
|
||||
use crate::ty::{
|
||||
layout::{HasDataLayout, Size},
|
||||
ParamEnv, Ty, TyCtxt,
|
||||
};
|
||||
use crate::ty::{ParamEnv, Ty, TyCtxt};
|
||||
|
||||
use super::{sign_extend, truncate, AllocId, Allocation, InterpResult, Pointer, PointerArithmetic};
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
use crate::mir::visit::MirVisitable;
|
||||
use crate::ty::adjustment::PointerCast;
|
||||
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
||||
use crate::ty::layout::VariantIdx;
|
||||
use crate::ty::print::{FmtPrinter, Printer};
|
||||
use crate::ty::subst::{Subst, SubstsRef};
|
||||
use crate::ty::{
|
||||
@ -16,6 +15,7 @@
|
||||
use rustc_hir::def::{CtorKind, Namespace};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{self, GeneratorKind};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
|
||||
use polonius_engine::Atom;
|
||||
pub use rustc_ast::ast::Mutability;
|
||||
|
@ -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 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
|
||||
|
||||
query layout_raw(
|
||||
env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
|
||||
) -> Result<&'tcx ty::layout::Layout, ty::layout::LayoutError<'tcx>> {
|
||||
) -> Result<&'tcx rustc_target::abi::Layout, ty::layout::LayoutError<'tcx>> {
|
||||
desc { "computing layout of `{}`", env.value }
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@
|
||||
use crate::middle;
|
||||
use crate::middle::cstore::CrateStoreDyn;
|
||||
use crate::middle::cstore::EncodedMetadata;
|
||||
use crate::middle::lang_items;
|
||||
use crate::middle::lang_items::PanicLocationLangItem;
|
||||
use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
|
||||
use crate::middle::stability;
|
||||
use crate::mir::interpret::{Allocation, ConstValue, Scalar};
|
||||
@ -21,7 +19,6 @@
|
||||
};
|
||||
use crate::traits;
|
||||
use crate::traits::{Clause, Clauses, Goal, GoalKind, Goals};
|
||||
use crate::ty::layout::{Layout, TargetDataLayout, VariantIdx};
|
||||
use crate::ty::query;
|
||||
use crate::ty::steal::Steal;
|
||||
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
|
||||
@ -38,7 +35,6 @@
|
||||
use crate::ty::{ExistentialPredicate, InferTy, ParamTy, PolyFnSig, Predicate, ProjectionTy};
|
||||
use crate::ty::{InferConst, ParamConst};
|
||||
use crate::ty::{List, TyKind, TyS};
|
||||
use crate::util::common::ErrorReported;
|
||||
use rustc_ast::ast;
|
||||
use rustc_ast::expand::allocator::AllocatorKind;
|
||||
use rustc_ast::node_id::NodeMap;
|
||||
@ -50,10 +46,13 @@
|
||||
hash_stable_hashmap, HashStable, StableHasher, StableVec,
|
||||
};
|
||||
use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::{DefPathData, DefPathHash, Definitions};
|
||||
use rustc_hir::lang_items;
|
||||
use rustc_hir::lang_items::PanicLocationLangItem;
|
||||
use rustc_hir::{HirId, Node, TraitCandidate};
|
||||
use rustc_hir::{ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
@ -65,6 +64,7 @@
|
||||
use rustc_span::source_map::MultiSpan;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{Layout, TargetDataLayout, VariantIdx};
|
||||
use rustc_target::spec::abi;
|
||||
|
||||
use smallvec::SmallVec;
|
||||
@ -1203,7 +1203,7 @@ pub fn lib_features(self) -> &'tcx middle::lib_features::LibFeatures {
|
||||
}
|
||||
|
||||
/// Obtain all lang items of this crate and all dependencies (recursively)
|
||||
pub fn lang_items(self) -> &'tcx middle::lang_items::LanguageItems {
|
||||
pub fn lang_items(self) -> &'tcx rustc_hir::lang_items::LanguageItems {
|
||||
self.get_lang_items(LOCAL_CRATE)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::ty::subst::{GenericArgKind, SubstsRef};
|
||||
use crate::ty::subst::{GenericArg, GenericArgKind};
|
||||
use crate::ty::{self, InferConst, Ty, TypeFlags};
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -81,6 +81,7 @@ fn add_kind(&mut self, kind: &ty::TyKind<'_>) {
|
||||
|
||||
&ty::Param(_) => {
|
||||
self.add_flags(TypeFlags::HAS_TY_PARAM);
|
||||
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
|
||||
}
|
||||
|
||||
&ty::Generator(_, ref substs, _) => {
|
||||
@ -99,14 +100,17 @@ fn add_kind(&mut self, kind: &ty::TyKind<'_>) {
|
||||
|
||||
&ty::Bound(debruijn, _) => {
|
||||
self.add_binder(debruijn);
|
||||
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
|
||||
}
|
||||
|
||||
&ty::Placeholder(..) => {
|
||||
self.add_flags(TypeFlags::HAS_TY_PLACEHOLDER);
|
||||
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
|
||||
}
|
||||
|
||||
&ty::Infer(infer) => {
|
||||
self.add_flags(TypeFlags::HAS_TY_INFER);
|
||||
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
|
||||
match infer {
|
||||
ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => {}
|
||||
|
||||
@ -218,17 +222,23 @@ fn add_const(&mut self, c: &ty::Const<'_>) {
|
||||
}
|
||||
ty::ConstKind::Infer(infer) => {
|
||||
self.add_flags(TypeFlags::HAS_CT_INFER);
|
||||
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
|
||||
match infer {
|
||||
InferConst::Fresh(_) => {}
|
||||
InferConst::Var(_) => self.add_flags(TypeFlags::KEEP_IN_LOCAL_TCX),
|
||||
}
|
||||
}
|
||||
ty::ConstKind::Bound(debruijn, _) => self.add_binder(debruijn),
|
||||
ty::ConstKind::Bound(debruijn, _) => {
|
||||
self.add_binder(debruijn);
|
||||
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
|
||||
}
|
||||
ty::ConstKind::Param(_) => {
|
||||
self.add_flags(TypeFlags::HAS_CT_PARAM);
|
||||
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
|
||||
}
|
||||
ty::ConstKind::Placeholder(_) => {
|
||||
self.add_flags(TypeFlags::HAS_CT_PLACEHOLDER);
|
||||
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
|
||||
}
|
||||
ty::ConstKind::Value(_) => {}
|
||||
}
|
||||
@ -243,7 +253,7 @@ fn add_projection_ty(&mut self, projection_ty: &ty::ProjectionTy<'_>) {
|
||||
self.add_substs(projection_ty.substs);
|
||||
}
|
||||
|
||||
fn add_substs(&mut self, substs: SubstsRef<'_>) {
|
||||
fn add_substs(&mut self, substs: &[GenericArg<'_>]) {
|
||||
for kind in substs {
|
||||
match kind.unpack() {
|
||||
GenericArgKind::Type(ty) => self.add_ty(ty),
|
||||
|
@ -142,6 +142,13 @@ fn has_late_bound_regions(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_RE_LATE_BOUND)
|
||||
}
|
||||
|
||||
/// Indicates whether this value still has parameters/placeholders/inference variables
|
||||
/// which could be replaced later, in a way that would change the results of `impl`
|
||||
/// specialization.
|
||||
fn still_further_specializable(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE)
|
||||
}
|
||||
|
||||
/// A visitor that does not recurse into types, works like `fn walk_shallow` in `Ty`.
|
||||
fn visit_tys_shallow(&self, visit: impl FnMut(Ty<'tcx>) -> bool) -> bool {
|
||||
pub struct Visitor<F>(F);
|
||||
|
@ -1,10 +1,10 @@
|
||||
use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use crate::middle::lang_items::DropInPlaceFnLangItem;
|
||||
use crate::ty::print::{FmtPrinter, Printer};
|
||||
use crate::ty::{self, SubstsRef, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_data_structures::AtomicRef;
|
||||
use rustc_hir::def::Namespace;
|
||||
use rustc_hir::def_id::{CrateNum, DefId};
|
||||
use rustc_hir::lang_items::DropInPlaceFnLangItem;
|
||||
use rustc_macros::HashStable;
|
||||
|
||||
use std::fmt;
|
||||
|
@ -15,7 +15,7 @@
|
||||
use rustc_target::abi::call::{
|
||||
ArgAbi, ArgAttribute, ArgAttributes, Conv, FnAbi, PassMode, Reg, RegKind,
|
||||
};
|
||||
pub use rustc_target::abi::*;
|
||||
use rustc_target::abi::*;
|
||||
use rustc_target::spec::{abi::Abi as SpecAbi, HasTargetSpec, PanicStrategy};
|
||||
|
||||
use std::cmp;
|
||||
|
@ -11,14 +11,12 @@
|
||||
use crate::ich::StableHashingContext;
|
||||
use crate::infer::canonical::Canonical;
|
||||
use crate::middle::cstore::CrateStoreDyn;
|
||||
use crate::middle::lang_items::{FnMutTraitLangItem, FnOnceTraitLangItem, FnTraitLangItem};
|
||||
use crate::middle::resolve_lifetime::ObjectLifetimeDefault;
|
||||
use crate::mir::interpret::ErrorHandled;
|
||||
use crate::mir::GeneratorLayout;
|
||||
use crate::mir::ReadOnlyBodyAndCache;
|
||||
use crate::traits::{self, Reveal};
|
||||
use crate::ty;
|
||||
use crate::ty::layout::VariantIdx;
|
||||
use crate::ty::subst::{InternalSubsts, Subst, SubstsRef};
|
||||
use crate::ty::util::{Discr, IntTypeExt};
|
||||
use crate::ty::walk::TypeWalker;
|
||||
@ -35,6 +33,7 @@
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Namespace, Res};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX};
|
||||
use rustc_hir::lang_items::{FnMutTraitLangItem, FnOnceTraitLangItem, FnTraitLangItem};
|
||||
use rustc_hir::{Constness, GlobMap, Node, TraitMap};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_macros::HashStable;
|
||||
@ -43,7 +42,7 @@
|
||||
use rustc_span::hygiene::ExpnId;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::Align;
|
||||
use rustc_target::abi::{Align, VariantIdx};
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::{self, Ordering};
|
||||
@ -524,101 +523,106 @@ pub struct TypeFlags: u32 {
|
||||
// Does this have parameters? Used to determine whether substitution is
|
||||
// required.
|
||||
/// Does this have [Param]?
|
||||
const HAS_TY_PARAM = 1 << 0;
|
||||
const HAS_TY_PARAM = 1 << 0;
|
||||
/// Does this have [ReEarlyBound]?
|
||||
const HAS_RE_PARAM = 1 << 1;
|
||||
const HAS_RE_PARAM = 1 << 1;
|
||||
/// Does this have [ConstKind::Param]?
|
||||
const HAS_CT_PARAM = 1 << 2;
|
||||
const HAS_CT_PARAM = 1 << 2;
|
||||
|
||||
const NEEDS_SUBST = TypeFlags::HAS_TY_PARAM.bits
|
||||
| TypeFlags::HAS_RE_PARAM.bits
|
||||
| TypeFlags::HAS_CT_PARAM.bits;
|
||||
const NEEDS_SUBST = TypeFlags::HAS_TY_PARAM.bits
|
||||
| TypeFlags::HAS_RE_PARAM.bits
|
||||
| TypeFlags::HAS_CT_PARAM.bits;
|
||||
|
||||
/// Does this have [Infer]?
|
||||
const HAS_TY_INFER = 1 << 3;
|
||||
const HAS_TY_INFER = 1 << 3;
|
||||
/// Does this have [ReVar]?
|
||||
const HAS_RE_INFER = 1 << 4;
|
||||
const HAS_RE_INFER = 1 << 4;
|
||||
/// Does this have [ConstKind::Infer]?
|
||||
const HAS_CT_INFER = 1 << 5;
|
||||
const HAS_CT_INFER = 1 << 5;
|
||||
|
||||
/// Does this have inference variables? Used to determine whether
|
||||
/// inference is required.
|
||||
const NEEDS_INFER = TypeFlags::HAS_TY_INFER.bits
|
||||
| TypeFlags::HAS_RE_INFER.bits
|
||||
| TypeFlags::HAS_CT_INFER.bits;
|
||||
const NEEDS_INFER = TypeFlags::HAS_TY_INFER.bits
|
||||
| TypeFlags::HAS_RE_INFER.bits
|
||||
| TypeFlags::HAS_CT_INFER.bits;
|
||||
|
||||
/// Does this have [Placeholder]?
|
||||
const HAS_TY_PLACEHOLDER = 1 << 6;
|
||||
const HAS_TY_PLACEHOLDER = 1 << 6;
|
||||
/// Does this have [RePlaceholder]?
|
||||
const HAS_RE_PLACEHOLDER = 1 << 7;
|
||||
const HAS_RE_PLACEHOLDER = 1 << 7;
|
||||
/// Does this have [ConstKind::Placeholder]?
|
||||
const HAS_CT_PLACEHOLDER = 1 << 8;
|
||||
const HAS_CT_PLACEHOLDER = 1 << 8;
|
||||
|
||||
/// `true` if there are "names" of regions and so forth
|
||||
/// that are local to a particular fn/inferctxt
|
||||
const HAS_FREE_LOCAL_REGIONS = 1 << 9;
|
||||
const HAS_FREE_LOCAL_REGIONS = 1 << 9;
|
||||
|
||||
/// `true` if there are "names" of types and regions and so forth
|
||||
/// that are local to a particular fn
|
||||
const HAS_FREE_LOCAL_NAMES = TypeFlags::HAS_TY_PARAM.bits
|
||||
| TypeFlags::HAS_CT_PARAM.bits
|
||||
| TypeFlags::HAS_TY_INFER.bits
|
||||
| TypeFlags::HAS_CT_INFER.bits
|
||||
| TypeFlags::HAS_TY_PLACEHOLDER.bits
|
||||
| TypeFlags::HAS_CT_PLACEHOLDER.bits
|
||||
| TypeFlags::HAS_FREE_LOCAL_REGIONS.bits;
|
||||
const HAS_FREE_LOCAL_NAMES = TypeFlags::HAS_TY_PARAM.bits
|
||||
| TypeFlags::HAS_CT_PARAM.bits
|
||||
| TypeFlags::HAS_TY_INFER.bits
|
||||
| TypeFlags::HAS_CT_INFER.bits
|
||||
| TypeFlags::HAS_TY_PLACEHOLDER.bits
|
||||
| TypeFlags::HAS_CT_PLACEHOLDER.bits
|
||||
| TypeFlags::HAS_FREE_LOCAL_REGIONS.bits;
|
||||
|
||||
/// Does this have [Projection] or [UnnormalizedProjection]?
|
||||
const HAS_TY_PROJECTION = 1 << 10;
|
||||
const HAS_TY_PROJECTION = 1 << 10;
|
||||
/// Does this have [Opaque]?
|
||||
const HAS_TY_OPAQUE = 1 << 11;
|
||||
const HAS_TY_OPAQUE = 1 << 11;
|
||||
/// Does this have [ConstKind::Unevaluated]?
|
||||
const HAS_CT_PROJECTION = 1 << 12;
|
||||
const HAS_CT_PROJECTION = 1 << 12;
|
||||
|
||||
/// Could this type be normalized further?
|
||||
const HAS_PROJECTION = TypeFlags::HAS_TY_PROJECTION.bits
|
||||
| TypeFlags::HAS_TY_OPAQUE.bits
|
||||
| TypeFlags::HAS_CT_PROJECTION.bits;
|
||||
const HAS_PROJECTION = TypeFlags::HAS_TY_PROJECTION.bits
|
||||
| TypeFlags::HAS_TY_OPAQUE.bits
|
||||
| TypeFlags::HAS_CT_PROJECTION.bits;
|
||||
|
||||
/// Present if the type belongs in a local type context.
|
||||
/// Set for placeholders and inference variables that are not "Fresh".
|
||||
const KEEP_IN_LOCAL_TCX = 1 << 13;
|
||||
const KEEP_IN_LOCAL_TCX = 1 << 13;
|
||||
|
||||
/// Is an error type reachable?
|
||||
const HAS_TY_ERR = 1 << 14;
|
||||
const HAS_TY_ERR = 1 << 14;
|
||||
|
||||
/// Does this have any region that "appears free" in the type?
|
||||
/// Basically anything but [ReLateBound] and [ReErased].
|
||||
const HAS_FREE_REGIONS = 1 << 15;
|
||||
const HAS_FREE_REGIONS = 1 << 15;
|
||||
|
||||
/// Does this have any [ReLateBound] regions? Used to check
|
||||
/// if a global bound is safe to evaluate.
|
||||
const HAS_RE_LATE_BOUND = 1 << 16;
|
||||
const HAS_RE_LATE_BOUND = 1 << 16;
|
||||
|
||||
/// Does this have any [ReErased] regions?
|
||||
const HAS_RE_ERASED = 1 << 17;
|
||||
const HAS_RE_ERASED = 1 << 17;
|
||||
|
||||
/// Does this value have parameters/placeholders/inference variables which could be
|
||||
/// replaced later, in a way that would change the results of `impl` specialization?
|
||||
const STILL_FURTHER_SPECIALIZABLE = 1 << 18;
|
||||
|
||||
/// Flags representing the nominal content of a type,
|
||||
/// computed by FlagsComputation. If you add a new nominal
|
||||
/// flag, it should be added here too.
|
||||
const NOMINAL_FLAGS = TypeFlags::HAS_TY_PARAM.bits
|
||||
| TypeFlags::HAS_RE_PARAM.bits
|
||||
| TypeFlags::HAS_CT_PARAM.bits
|
||||
| TypeFlags::HAS_TY_INFER.bits
|
||||
| TypeFlags::HAS_RE_INFER.bits
|
||||
| TypeFlags::HAS_CT_INFER.bits
|
||||
| TypeFlags::HAS_TY_PLACEHOLDER.bits
|
||||
| TypeFlags::HAS_RE_PLACEHOLDER.bits
|
||||
| TypeFlags::HAS_CT_PLACEHOLDER.bits
|
||||
| TypeFlags::HAS_FREE_LOCAL_REGIONS.bits
|
||||
| TypeFlags::HAS_TY_PROJECTION.bits
|
||||
| TypeFlags::HAS_TY_OPAQUE.bits
|
||||
| TypeFlags::HAS_CT_PROJECTION.bits
|
||||
| TypeFlags::KEEP_IN_LOCAL_TCX.bits
|
||||
| TypeFlags::HAS_TY_ERR.bits
|
||||
| TypeFlags::HAS_FREE_REGIONS.bits
|
||||
| TypeFlags::HAS_RE_LATE_BOUND.bits
|
||||
| TypeFlags::HAS_RE_ERASED.bits;
|
||||
const NOMINAL_FLAGS = TypeFlags::HAS_TY_PARAM.bits
|
||||
| TypeFlags::HAS_RE_PARAM.bits
|
||||
| TypeFlags::HAS_CT_PARAM.bits
|
||||
| TypeFlags::HAS_TY_INFER.bits
|
||||
| TypeFlags::HAS_RE_INFER.bits
|
||||
| TypeFlags::HAS_CT_INFER.bits
|
||||
| TypeFlags::HAS_TY_PLACEHOLDER.bits
|
||||
| TypeFlags::HAS_RE_PLACEHOLDER.bits
|
||||
| TypeFlags::HAS_CT_PLACEHOLDER.bits
|
||||
| TypeFlags::HAS_FREE_LOCAL_REGIONS.bits
|
||||
| TypeFlags::HAS_TY_PROJECTION.bits
|
||||
| TypeFlags::HAS_TY_OPAQUE.bits
|
||||
| TypeFlags::HAS_CT_PROJECTION.bits
|
||||
| TypeFlags::KEEP_IN_LOCAL_TCX.bits
|
||||
| TypeFlags::HAS_TY_ERR.bits
|
||||
| TypeFlags::HAS_FREE_REGIONS.bits
|
||||
| TypeFlags::HAS_RE_LATE_BOUND.bits
|
||||
| TypeFlags::HAS_RE_ERASED.bits
|
||||
| TypeFlags::STILL_FURTHER_SPECIALIZABLE.bits;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2078,7 +2082,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_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;
|
||||
|
@ -7,7 +7,6 @@
|
||||
use crate::middle::cstore::{CrateSource, DepKind, NativeLibraryKind};
|
||||
use crate::middle::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLibrary};
|
||||
use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
|
||||
use crate::middle::lang_items::{LangItem, LanguageItems};
|
||||
use crate::middle::lib_features::LibFeatures;
|
||||
use crate::middle::privacy::AccessLevels;
|
||||
use crate::middle::region;
|
||||
@ -34,16 +33,17 @@
|
||||
use crate::ty::subst::{GenericArg, SubstsRef};
|
||||
use crate::ty::util::AlwaysRequiresDrop;
|
||||
use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
|
||||
use crate::util::common::ErrorReported;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_data_structures::profiling::ProfileCategory::*;
|
||||
use rustc_data_structures::stable_hasher::StableVec;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId};
|
||||
use rustc_hir::lang_items::{LangItem, LanguageItems};
|
||||
use rustc_hir::{Crate, HirIdSet, ItemLocalId, TraitCandidate};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
|
||||
|
@ -254,7 +254,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
(),
|
||||
bool,
|
||||
usize,
|
||||
crate::ty::layout::VariantIdx,
|
||||
::rustc_target::abi::VariantIdx,
|
||||
u64,
|
||||
String,
|
||||
crate::middle::region::Scope,
|
||||
|
@ -10,7 +10,6 @@
|
||||
use crate::mir::interpret::ConstValue;
|
||||
use crate::mir::interpret::{LitToConstInput, Scalar};
|
||||
use crate::mir::Promoted;
|
||||
use crate::ty::layout::VariantIdx;
|
||||
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
|
||||
use crate::ty::{
|
||||
self, AdtDef, DefIdTree, Discr, Ty, TyCtxt, TypeFlags, TypeFoldable, WithConstness,
|
||||
@ -24,6 +23,7 @@
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
use rustc_target::abi::{Size, VariantIdx};
|
||||
use rustc_target::spec::abi;
|
||||
use smallvec::SmallVec;
|
||||
use std::borrow::Cow;
|
||||
@ -1623,16 +1623,19 @@ pub fn type_flags(&self) -> TypeFlags {
|
||||
flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
|
||||
flags = flags | TypeFlags::HAS_RE_INFER;
|
||||
flags = flags | TypeFlags::KEEP_IN_LOCAL_TCX;
|
||||
flags = flags | TypeFlags::STILL_FURTHER_SPECIALIZABLE;
|
||||
}
|
||||
ty::RePlaceholder(..) => {
|
||||
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
||||
flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
|
||||
flags = flags | TypeFlags::HAS_RE_PLACEHOLDER;
|
||||
flags = flags | TypeFlags::STILL_FURTHER_SPECIALIZABLE;
|
||||
}
|
||||
ty::ReEarlyBound(..) => {
|
||||
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
||||
flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
|
||||
flags = flags | TypeFlags::HAS_RE_PARAM;
|
||||
flags = flags | TypeFlags::STILL_FURTHER_SPECIALIZABLE;
|
||||
}
|
||||
ty::ReFree { .. } | ty::ReScope { .. } => {
|
||||
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
||||
@ -2501,7 +2504,7 @@ pub fn try_to_scalar(&self) -> Option<Scalar> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn try_to_bits(&self, size: ty::layout::Size) -> Option<u128> {
|
||||
pub fn try_to_bits(&self, size: Size) -> Option<u128> {
|
||||
if let ConstKind::Value(val) = self { val.try_to_bits(size) } else { None }
|
||||
}
|
||||
}
|
||||
|
@ -2,24 +2,24 @@
|
||||
|
||||
use crate::ich::NodeIdHashingMode;
|
||||
use crate::mir::interpret::{sign_extend, truncate};
|
||||
use crate::ty::layout::{Integer, IntegerExt, Size};
|
||||
use crate::ty::layout::IntegerExt;
|
||||
use crate::ty::query::TyCtxtAt;
|
||||
use crate::ty::subst::{GenericArgKind, InternalSubsts, Subst, SubstsRef};
|
||||
use crate::ty::TyKind::*;
|
||||
use crate::ty::{self, DefIdTree, GenericParamDefKind, Ty, TyCtxt, TypeFoldable};
|
||||
use crate::util::common::ErrorReported;
|
||||
use rustc_apfloat::Float as _;
|
||||
use rustc_ast::ast;
|
||||
use rustc_attr::{self as attr, SignedInt, UnsignedInt};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::definitions::DefPathData;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::TargetDataLayout;
|
||||
use rustc_target::abi::{Integer, Size, TargetDataLayout};
|
||||
use smallvec::SmallVec;
|
||||
use std::{cmp, fmt};
|
||||
|
||||
|
@ -8,8 +8,6 @@
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub use rustc_errors::ErrorReported;
|
||||
|
||||
pub fn to_readable_str(mut val: usize) -> String {
|
||||
let mut groups = vec![];
|
||||
loop {
|
||||
|
@ -9,10 +9,10 @@
|
||||
AggregateKind, Constant, Field, Local, LocalInfo, LocalKind, Location, Operand, Place,
|
||||
PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind,
|
||||
};
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::print::Print;
|
||||
use rustc_middle::ty::{self, DefIdTree, Ty, TyCtxt};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::VariantIdx;
|
||||
|
||||
use super::borrow_set::BorrowData;
|
||||
use super::MirBorrowckCtxt;
|
||||
|
@ -24,13 +24,13 @@
|
||||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::cast::CastTy;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::subst::{GenericArgKind, Subst, SubstsRef, UserSubsts};
|
||||
use rustc_middle::ty::{
|
||||
self, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, RegionVid, ToPolyTraitRef, Ty,
|
||||
TyCtxt, UserType, UserTypeAnnotationIndex,
|
||||
};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use rustc_trait_selection::infer::InferCtxtExt as _;
|
||||
use rustc_trait_selection::opaque_types::{GenerateMemberConstraints, InferCtxtExt};
|
||||
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
|
||||
|
@ -17,10 +17,10 @@
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::lang_items;
|
||||
use rustc_hir::{BodyOwnerKind, HirId};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_infer::infer::{InferCtxt, NLLRegionVariableOrigin};
|
||||
use rustc_middle::middle::lang_items;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
|
||||
use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt};
|
||||
|
@ -9,8 +9,9 @@
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{ConstEvalErr, ErrorHandled};
|
||||
use rustc_middle::traits::Reveal;
|
||||
use rustc_middle::ty::{self, layout, layout::LayoutOf, subst::Subst, TyCtxt};
|
||||
use rustc_middle::ty::{self, subst::Subst, TyCtxt};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_target::abi::{Abi, LayoutOf};
|
||||
use std::convert::TryInto;
|
||||
|
||||
pub fn note_on_undefined_behavior_error() -> &'static str {
|
||||
@ -105,8 +106,8 @@ pub(super) fn op_to_const<'tcx>(
|
||||
// the usual cases of extracting e.g. a `usize`, without there being a real use case for the
|
||||
// `Undef` situation.
|
||||
let try_as_immediate = match op.layout.abi {
|
||||
layout::Abi::Scalar(..) => true,
|
||||
layout::Abi::ScalarPair(..) => match op.layout.ty.kind {
|
||||
Abi::Scalar(..) => true,
|
||||
Abi::ScalarPair(..) => match op.layout.ty.kind {
|
||||
ty::Ref(_, inner, _) => match inner.kind {
|
||||
ty::Slice(elem) => elem == ecx.tcx.types.u8,
|
||||
ty::Str => true,
|
||||
|
@ -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_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_middle::mir::interpret::{InterpResult, PointerArithmetic, Scalar};
|
||||
use rustc_middle::mir::CastKind;
|
||||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::layout::{self, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::{self, Ty, TypeAndMut, TypeFoldable};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_target::abi::LayoutOf;
|
||||
use rustc_target::abi::{LayoutOf, Size, Variants};
|
||||
|
||||
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
pub fn cast(
|
||||
@ -132,7 +132,7 @@ fn cast_immediate(
|
||||
|
||||
// Handle cast from a univariant (ZST) enum.
|
||||
match src.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
if let Some(discr) = src.layout.ty.discriminant_for_variant(*self.tcx, index) {
|
||||
assert!(src.layout.is_zst());
|
||||
let discr_layout = self.layout_of(discr.ty)?;
|
||||
@ -141,7 +141,7 @@ fn cast_immediate(
|
||||
.into());
|
||||
}
|
||||
}
|
||||
layout::Variants::Multiple { .. } => {}
|
||||
Variants::Multiple { .. } => {}
|
||||
}
|
||||
|
||||
// Handle casting the metadata away from a fat pointer.
|
||||
|
@ -13,11 +13,12 @@
|
||||
use rustc_middle::mir::interpret::{
|
||||
sign_extend, truncate, AllocId, FrameInfo, GlobalId, InterpResult, Pointer, Scalar,
|
||||
};
|
||||
use rustc_middle::ty::layout::{self, Align, HasDataLayout, LayoutOf, Size, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{self, TyAndLayout};
|
||||
use rustc_middle::ty::query::TyCtxtAt;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_span::source_map::DUMMY_SP;
|
||||
use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Size, TargetDataLayout};
|
||||
|
||||
use super::{
|
||||
Immediate, MPlaceTy, Machine, MemPlace, MemPlaceMeta, Memory, OpTy, Operand, Place, PlaceTy,
|
||||
@ -173,7 +174,7 @@ pub fn current_source_info(&self) -> Option<mir::SourceInfo> {
|
||||
|
||||
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout for InterpCx<'mir, 'tcx, M> {
|
||||
#[inline]
|
||||
fn data_layout(&self) -> &layout::TargetDataLayout {
|
||||
fn data_layout(&self) -> &TargetDataLayout {
|
||||
&self.tcx.data_layout
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,10 @@
|
||||
BinOp,
|
||||
};
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::layout::{LayoutOf, Primitive, Size};
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_target::abi::{Abi, LayoutOf as _, Primitive, Size};
|
||||
|
||||
use super::{ImmTy, InterpCx, Machine, OpTy, PlaceTy};
|
||||
|
||||
@ -134,7 +134,7 @@ pub fn emulate_intrinsic(
|
||||
let val = self.read_scalar(args[0])?.not_undef()?;
|
||||
let bits = self.force_bits(val, layout_of.size)?;
|
||||
let kind = match layout_of.abi {
|
||||
ty::layout::Abi::Scalar(ref scalar) => scalar.value,
|
||||
Abi::Scalar(ref scalar) => scalar.value,
|
||||
_ => bug!("{} called on invalid type {:?}", intrinsic_name, ty),
|
||||
};
|
||||
let (nonzero, intrinsic_name) = match intrinsic_name {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use rustc_middle::middle::lang_items::PanicLocationLangItem;
|
||||
use rustc_hir::lang_items::PanicLocationLangItem;
|
||||
use rustc_middle::ty::subst::Subst;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
@ -11,11 +11,10 @@
|
||||
use std::convert::TryFrom;
|
||||
use std::ptr;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_middle::ty::layout::{Align, HasDataLayout, Size, TargetDataLayout};
|
||||
use rustc_middle::ty::{self, query::TyCtxtAt, Instance, ParamEnv};
|
||||
|
||||
use rustc_ast::ast::Mutability;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_middle::ty::{self, query::TyCtxtAt, Instance, ParamEnv};
|
||||
use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout};
|
||||
|
||||
use super::{
|
||||
AllocId, AllocMap, Allocation, AllocationExtra, CheckInAllocMsg, ErrorHandled, GlobalAlloc,
|
||||
|
@ -10,12 +10,12 @@
|
||||
use rustc_middle::mir::interpret::{
|
||||
sign_extend, truncate, AllocId, ConstValue, GlobalId, InterpResult, Pointer, Scalar,
|
||||
};
|
||||
use rustc_middle::ty::layout::{
|
||||
self, HasDataLayout, IntegerExt, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc_middle::ty::layout::{IntegerExt, PrimitiveExt, TyAndLayout};
|
||||
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter, Printer};
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_middle::{mir, ty};
|
||||
use rustc_target::abi::{Abi, DiscriminantKind, HasDataLayout, Integer, LayoutOf, Size};
|
||||
use rustc_target::abi::{VariantIdx, Variants};
|
||||
use std::fmt::Write;
|
||||
|
||||
/// An `Immediate` represents a single immediate self-contained Rust value.
|
||||
@ -266,7 +266,7 @@ fn try_read_immediate_from_mplace(
|
||||
};
|
||||
|
||||
match mplace.layout.abi {
|
||||
layout::Abi::Scalar(..) => {
|
||||
Abi::Scalar(..) => {
|
||||
let scalar = self.memory.get_raw(ptr.alloc_id)?.read_scalar(
|
||||
self,
|
||||
ptr,
|
||||
@ -274,7 +274,7 @@ fn try_read_immediate_from_mplace(
|
||||
)?;
|
||||
Ok(Some(ImmTy { imm: scalar.into(), layout: mplace.layout }))
|
||||
}
|
||||
layout::Abi::ScalarPair(ref a, ref b) => {
|
||||
Abi::ScalarPair(ref a, ref b) => {
|
||||
// We checked `ptr_align` above, so all fields will have the alignment they need.
|
||||
// We would anyway check against `ptr_align.restrict_for_offset(b_offset)`,
|
||||
// which `ptr.offset(b_offset)` cannot possibly fail to satisfy.
|
||||
@ -587,7 +587,7 @@ pub fn read_discriminant(
|
||||
trace!("read_discriminant_value {:#?}", rval.layout);
|
||||
|
||||
let (discr_layout, discr_kind, discr_index) = match rval.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
let discr_val = rval
|
||||
.layout
|
||||
.ty
|
||||
@ -595,12 +595,9 @@ pub fn read_discriminant(
|
||||
.map_or(u128::from(index.as_u32()), |discr| discr.val);
|
||||
return Ok((discr_val, index));
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
discr: ref discr_layout,
|
||||
ref discr_kind,
|
||||
discr_index,
|
||||
..
|
||||
} => (discr_layout, discr_kind, discr_index),
|
||||
Variants::Multiple { discr: ref discr_layout, ref discr_kind, discr_index, .. } => {
|
||||
(discr_layout, discr_kind, discr_index)
|
||||
}
|
||||
};
|
||||
|
||||
// read raw discriminant value
|
||||
@ -610,7 +607,7 @@ pub fn read_discriminant(
|
||||
trace!("discr value: {:?}", raw_discr);
|
||||
// post-process
|
||||
Ok(match *discr_kind {
|
||||
layout::DiscriminantKind::Tag => {
|
||||
DiscriminantKind::Tag => {
|
||||
let bits_discr = raw_discr
|
||||
.not_undef()
|
||||
.and_then(|raw_discr| self.force_bits(raw_discr, discr_val.layout.size))
|
||||
@ -627,7 +624,7 @@ pub fn read_discriminant(
|
||||
.expect("tagged layout corresponds to adt")
|
||||
.repr
|
||||
.discr_type();
|
||||
let size = layout::Integer::from_attr(self, discr_ty).size();
|
||||
let size = Integer::from_attr(self, discr_ty).size();
|
||||
truncate(sexted, size)
|
||||
} else {
|
||||
bits_discr
|
||||
@ -648,11 +645,7 @@ pub fn read_discriminant(
|
||||
.ok_or_else(|| err_ub!(InvalidDiscriminant(raw_discr.erase_tag())))?;
|
||||
(real_discr, index.0)
|
||||
}
|
||||
layout::DiscriminantKind::Niche {
|
||||
dataful_variant,
|
||||
ref niche_variants,
|
||||
niche_start,
|
||||
} => {
|
||||
DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start } => {
|
||||
let variants_start = niche_variants.start().as_u32();
|
||||
let variants_end = niche_variants.end().as_u32();
|
||||
let raw_discr = raw_discr
|
||||
|
@ -4,11 +4,8 @@
|
||||
use rustc_ast::ast::FloatTy;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{InterpResult, Scalar};
|
||||
use rustc_middle::ty::{
|
||||
self,
|
||||
layout::{LayoutOf, TyAndLayout},
|
||||
Ty,
|
||||
};
|
||||
use rustc_middle::ty::{self, layout::TyAndLayout, Ty};
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
||||
use super::{ImmTy, Immediate, InterpCx, Machine, PlaceTy};
|
||||
|
||||
|
@ -8,10 +8,10 @@
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::truncate;
|
||||
use rustc_middle::ty::layout::{
|
||||
self, Align, HasDataLayout, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc_middle::ty::layout::{PrimitiveExt, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_target::abi::{Abi, Align, DiscriminantKind, FieldsShape};
|
||||
use rustc_target::abi::{HasDataLayout, LayoutOf, Size, VariantIdx, Variants};
|
||||
|
||||
use super::{
|
||||
AllocId, AllocMap, Allocation, AllocationExtra, ImmTy, Immediate, InterpCx, InterpResult,
|
||||
@ -219,7 +219,7 @@ pub(super) fn len(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> {
|
||||
// Go through the layout. There are lots of types that support a length,
|
||||
// e.g., SIMD types.
|
||||
match self.layout.fields {
|
||||
layout::FieldsShape::Array { count, .. } => Ok(count),
|
||||
FieldsShape::Array { count, .. } => Ok(count),
|
||||
_ => bug!("len not supported on sized type {:?}", self.layout.ty),
|
||||
}
|
||||
}
|
||||
@ -437,7 +437,7 @@ pub fn mplace_index(
|
||||
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
|
||||
// Not using the layout method because we want to compute on u64
|
||||
match base.layout.fields {
|
||||
layout::FieldsShape::Array { stride, .. } => {
|
||||
FieldsShape::Array { stride, .. } => {
|
||||
let len = base.len(self)?;
|
||||
if index >= len {
|
||||
// This can only be reached in ConstProp and non-rustc-MIR.
|
||||
@ -463,7 +463,7 @@ pub(super) fn mplace_array_fields(
|
||||
{
|
||||
let len = base.len(self)?; // also asserts that we have a type where this makes sense
|
||||
let stride = match base.layout.fields {
|
||||
layout::FieldsShape::Array { stride, .. } => stride,
|
||||
FieldsShape::Array { stride, .. } => stride,
|
||||
_ => bug!("mplace_array_fields: expected an array layout"),
|
||||
};
|
||||
let layout = base.layout.field(self, 0)?;
|
||||
@ -493,7 +493,7 @@ fn mplace_subslice(
|
||||
// Not using layout method because that works with usize, and does not work with slices
|
||||
// (that have count 0 in their layout).
|
||||
let from_offset = match base.layout.fields {
|
||||
layout::FieldsShape::Array { stride, .. } => stride * from, // `Size` multiplication is checked
|
||||
FieldsShape::Array { stride, .. } => stride * from, // `Size` multiplication is checked
|
||||
_ => bug!("Unexpected layout of index access: {:#?}", base.layout),
|
||||
};
|
||||
|
||||
@ -802,7 +802,7 @@ fn write_immediate_to_mplace_no_validate(
|
||||
match value {
|
||||
Immediate::Scalar(scalar) => {
|
||||
match dest.layout.abi {
|
||||
layout::Abi::Scalar(_) => {} // fine
|
||||
Abi::Scalar(_) => {} // fine
|
||||
_ => {
|
||||
bug!("write_immediate_to_mplace: invalid Scalar layout: {:#?}", dest.layout)
|
||||
}
|
||||
@ -819,7 +819,7 @@ fn write_immediate_to_mplace_no_validate(
|
||||
// We would anyway check against `ptr_align.restrict_for_offset(b_offset)`,
|
||||
// which `ptr.offset(b_offset)` cannot possibly fail to satisfy.
|
||||
let (a, b) = match dest.layout.abi {
|
||||
layout::Abi::ScalarPair(ref a, ref b) => (&a.value, &b.value),
|
||||
Abi::ScalarPair(ref a, ref b) => (&a.value, &b.value),
|
||||
_ => bug!(
|
||||
"write_immediate_to_mplace: invalid ScalarPair layout: {:#?}",
|
||||
dest.layout
|
||||
@ -1067,11 +1067,11 @@ pub fn write_discriminant_index(
|
||||
}
|
||||
|
||||
match dest.layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
assert_eq!(index, variant_index);
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
discr_kind: layout::DiscriminantKind::Tag,
|
||||
Variants::Multiple {
|
||||
discr_kind: DiscriminantKind::Tag,
|
||||
discr: ref discr_layout,
|
||||
discr_index,
|
||||
..
|
||||
@ -1091,9 +1091,9 @@ pub fn write_discriminant_index(
|
||||
let discr_dest = self.place_field(dest, discr_index)?;
|
||||
self.write_scalar(Scalar::from_uint(discr_val, size), discr_dest)?;
|
||||
}
|
||||
layout::Variants::Multiple {
|
||||
Variants::Multiple {
|
||||
discr_kind:
|
||||
layout::DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start },
|
||||
DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start },
|
||||
discr: ref discr_layout,
|
||||
discr_index,
|
||||
..
|
||||
|
@ -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 @@ fn check_argument_compat(
|
||||
// Different valid ranges are okay (once we enforce validity,
|
||||
// that will take care to make it UB to leave the range, just
|
||||
// like for transmute).
|
||||
(layout::Abi::Scalar(ref caller), layout::Abi::Scalar(ref callee)) => {
|
||||
(abi::Abi::Scalar(ref caller), abi::Abi::Scalar(ref callee)) => {
|
||||
caller.value == callee.value
|
||||
}
|
||||
(
|
||||
layout::Abi::ScalarPair(ref caller1, ref caller2),
|
||||
layout::Abi::ScalarPair(ref callee1, ref callee2),
|
||||
abi::Abi::ScalarPair(ref caller1, ref caller2),
|
||||
abi::Abi::ScalarPair(ref callee1, ref callee2),
|
||||
) => caller1.value == callee1.value && caller2.value == callee2.value,
|
||||
// Be conservative
|
||||
_ => false,
|
||||
|
@ -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 rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir as hir;
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::layout::{self, LayoutOf, TyAndLayout, VariantIdx};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_target::abi::{Abi, LayoutOf, Scalar, VariantIdx, Variants};
|
||||
|
||||
use std::hash::Hash;
|
||||
|
||||
@ -180,7 +181,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
|
||||
fn aggregate_field_path_elem(&mut self, layout: TyAndLayout<'tcx>, field: usize) -> PathElem {
|
||||
// First, check if we are projecting to a variant.
|
||||
match layout.variants {
|
||||
layout::Variants::Multiple { discr_index, .. } => {
|
||||
Variants::Multiple { discr_index, .. } => {
|
||||
if discr_index == field {
|
||||
return match layout.ty.kind {
|
||||
ty::Adt(def, ..) if def.is_enum() => PathElem::EnumTag,
|
||||
@ -189,7 +190,7 @@ fn aggregate_field_path_elem(&mut self, layout: TyAndLayout<'tcx>, field: usize)
|
||||
};
|
||||
}
|
||||
}
|
||||
layout::Variants::Single { .. } => {}
|
||||
Variants::Single { .. } => {}
|
||||
}
|
||||
|
||||
// Now we know we are projecting to a field, so figure out which one.
|
||||
@ -226,11 +227,11 @@ fn aggregate_field_path_elem(&mut self, layout: TyAndLayout<'tcx>, field: usize)
|
||||
ty::Adt(def, ..) if def.is_enum() => {
|
||||
// we might be projecting *to* a variant, or to a field *in* a variant.
|
||||
match layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
Variants::Single { index } => {
|
||||
// Inside a variant
|
||||
PathElem::Field(def.variants[index].fields[field].ident.name)
|
||||
}
|
||||
layout::Variants::Multiple { .. } => bug!("we handled variants above"),
|
||||
Variants::Multiple { .. } => bug!("we handled variants above"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -539,7 +540,7 @@ fn try_visit_primitive(
|
||||
fn visit_scalar(
|
||||
&mut self,
|
||||
op: OpTy<'tcx, M::PointerTag>,
|
||||
scalar_layout: &layout::Scalar,
|
||||
scalar_layout: &Scalar,
|
||||
) -> InterpResult<'tcx> {
|
||||
let value = self.ecx.read_scalar(op)?;
|
||||
let valid_range = &scalar_layout.valid_range;
|
||||
@ -685,22 +686,22 @@ fn visit_value(&mut self, op: OpTy<'tcx, M::PointerTag>) -> InterpResult<'tcx> {
|
||||
// scalars, we do the same check on every "level" (e.g., first we check
|
||||
// MyNewtype and then the scalar in there).
|
||||
match op.layout.abi {
|
||||
layout::Abi::Uninhabited => {
|
||||
Abi::Uninhabited => {
|
||||
throw_validation_failure!(
|
||||
format_args!("a value of uninhabited type {:?}", op.layout.ty),
|
||||
self.path
|
||||
);
|
||||
}
|
||||
layout::Abi::Scalar(ref scalar_layout) => {
|
||||
Abi::Scalar(ref scalar_layout) => {
|
||||
self.visit_scalar(op, scalar_layout)?;
|
||||
}
|
||||
layout::Abi::ScalarPair { .. } | layout::Abi::Vector { .. } => {
|
||||
Abi::ScalarPair { .. } | Abi::Vector { .. } => {
|
||||
// These have fields that we already visited above, so we already checked
|
||||
// all their scalar-level restrictions.
|
||||
// There is also no equivalent to `rustc_layout_scalar_valid_range_start`
|
||||
// that would make skipping them here an issue.
|
||||
}
|
||||
layout::Abi::Aggregate { .. } => {
|
||||
Abi::Aggregate { .. } => {
|
||||
// Nothing to do.
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
use rustc_middle::mir::interpret::InterpResult;
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::layout::{self, TyAndLayout, VariantIdx};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_target::abi::{FieldsShape, VariantIdx, Variants};
|
||||
|
||||
use super::{InterpCx, MPlaceTy, Machine, OpTy};
|
||||
|
||||
@ -207,10 +208,10 @@ fn walk_value(&mut self, v: Self::V) -> InterpResult<'tcx>
|
||||
|
||||
// Visit the fields of this value.
|
||||
match v.layout().fields {
|
||||
layout::FieldsShape::Union(fields) => {
|
||||
FieldsShape::Union(fields) => {
|
||||
self.visit_union(v, fields)?;
|
||||
},
|
||||
layout::FieldsShape::Arbitrary { ref offsets, .. } => {
|
||||
FieldsShape::Arbitrary { ref offsets, .. } => {
|
||||
// FIXME: We collect in a vec because otherwise there are lifetime
|
||||
// errors: Projecting to a field needs access to `ecx`.
|
||||
let fields: Vec<InterpResult<'tcx, Self::V>> =
|
||||
@ -220,7 +221,7 @@ fn walk_value(&mut self, v: Self::V) -> InterpResult<'tcx>
|
||||
.collect();
|
||||
self.visit_aggregate(v, fields.into_iter())?;
|
||||
},
|
||||
layout::FieldsShape::Array { .. } => {
|
||||
FieldsShape::Array { .. } => {
|
||||
// Let's get an mplace first.
|
||||
let mplace = v.to_op(self.ecx())?.assert_mem_place(self.ecx());
|
||||
// Now we can go over all the fields.
|
||||
@ -237,7 +238,7 @@ fn walk_value(&mut self, v: Self::V) -> InterpResult<'tcx>
|
||||
match v.layout().variants {
|
||||
// If this is a multi-variant layout, find the right variant and proceed
|
||||
// with *its* fields.
|
||||
layout::Variants::Multiple { .. } => {
|
||||
Variants::Multiple { .. } => {
|
||||
let op = v.to_op(self.ecx())?;
|
||||
let idx = self.ecx().read_discriminant(op)?.1;
|
||||
let inner = v.project_downcast(self.ecx(), idx)?;
|
||||
@ -246,7 +247,7 @@ fn walk_value(&mut self, v: Self::V) -> InterpResult<'tcx>
|
||||
self.visit_variant(v, idx, inner)
|
||||
}
|
||||
// For single-variant layouts, we already did anything there is to do.
|
||||
layout::Variants::Single { .. } => Ok(())
|
||||
Variants::Single { .. } => Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,9 +181,9 @@
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, DefIdMap, LOCAL_CRATE};
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem};
|
||||
use rustc_index::bit_set::GrowableBitSet;
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::middle::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem};
|
||||
use rustc_middle::mir::interpret::{AllocId, ConstValue};
|
||||
use rustc_middle::mir::interpret::{ErrorHandled, GlobalAlloc, Scalar};
|
||||
use rustc_middle::mir::mono::{InstantiationMode, MonoItem};
|
||||
|
@ -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};
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
//! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
|
||||
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir::lang_items;
|
||||
use rustc_hir::{def_id::DefId, HirId};
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_middle::middle::lang_items;
|
||||
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::cast::CastTy;
|
||||
|
@ -19,13 +19,12 @@
|
||||
SourceInfo, SourceScope, SourceScopeData, Statement, StatementKind, Terminator, TerminatorKind,
|
||||
UnOp, RETURN_PLACE,
|
||||
};
|
||||
use rustc_middle::ty::layout::{
|
||||
HasDataLayout, HasTyCtxt, LayoutError, LayoutOf, Size, TargetDataLayout, TyAndLayout,
|
||||
};
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutError, TyAndLayout};
|
||||
use rustc_middle::ty::subst::{InternalSubsts, Subst};
|
||||
use rustc_middle::ty::{self, ConstKind, Instance, ParamEnv, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::{def_id::DefId, Span};
|
||||
use rustc_target::abi::{HasDataLayout, LayoutOf, Size, TargetDataLayout};
|
||||
use rustc_trait_selection::traits;
|
||||
|
||||
use crate::const_eval::error_to_const_error;
|
||||
|
@ -13,9 +13,9 @@
|
||||
use rustc_hir as hir;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use std::fmt;
|
||||
|
||||
pub struct ElaborateDrops;
|
||||
|
@ -63,10 +63,10 @@
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::layout::VariantIdx;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::GeneratorSubsts;
|
||||
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use std::borrow::Cow;
|
||||
use std::iter;
|
||||
|
||||
|
@ -5,8 +5,9 @@
|
||||
BasicBlock, BasicBlockData, Body, BodyAndCache, Local, Operand, Rvalue, StatementKind,
|
||||
TerminatorKind,
|
||||
};
|
||||
use rustc_middle::ty::layout::{Abi, TyAndLayout, Variants};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use rustc_target::abi::{Abi, Variants};
|
||||
|
||||
pub struct UninhabitedEnumBranching;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user