mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-20 02:43:45 +00:00
Auto merge of #70544 - Dylan-DPC:rollup-pj86j17, r=Dylan-DPC
Rollup of 4 pull requests Successful merges: - #69702 (Rename TyLayout to TyAndLayout.) - #70539 (add test for 62220) - #70540 (#[link]: mention wasm_import_module instead of cfg) - #70541 (prohibit_generics: update has_err for consts) Failed merges: r? @ghost
This commit is contained in:
commit
699f83f525
@ -270,7 +270,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
fn univariant_uninterned(
|
||||
&self,
|
||||
ty: Ty<'tcx>,
|
||||
fields: &[TyLayout<'_>],
|
||||
fields: &[TyAndLayout<'_>],
|
||||
repr: &ReprOptions,
|
||||
kind: StructKind,
|
||||
) -> Result<Layout, LayoutError<'tcx>> {
|
||||
@ -293,7 +293,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
let end =
|
||||
if let StructKind::MaybeUnsized = kind { fields.len() - 1 } else { fields.len() };
|
||||
let optimizing = &mut inverse_memory_index[..end];
|
||||
let field_align = |f: &TyLayout<'_>| {
|
||||
let field_align = |f: &TyAndLayout<'_>| {
|
||||
if let Some(pack) = pack { f.align.abi.min(pack) } else { f.align.abi }
|
||||
};
|
||||
match kind {
|
||||
@ -422,11 +422,15 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
(
|
||||
Some((
|
||||
i,
|
||||
&TyLayout { layout: &Layout { abi: Abi::Scalar(ref a), .. }, .. },
|
||||
&TyAndLayout {
|
||||
layout: &Layout { abi: Abi::Scalar(ref a), .. }, ..
|
||||
},
|
||||
)),
|
||||
Some((
|
||||
j,
|
||||
&TyLayout { layout: &Layout { abi: Abi::Scalar(ref b), .. }, .. },
|
||||
&TyAndLayout {
|
||||
layout: &Layout { abi: Abi::Scalar(ref b), .. }, ..
|
||||
},
|
||||
)),
|
||||
None,
|
||||
) => {
|
||||
@ -485,7 +489,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
};
|
||||
let scalar = |value: Primitive| tcx.intern_layout(Layout::scalar(self, scalar_unit(value)));
|
||||
|
||||
let univariant = |fields: &[TyLayout<'_>], repr: &ReprOptions, kind| {
|
||||
let univariant = |fields: &[TyAndLayout<'_>], repr: &ReprOptions, kind| {
|
||||
Ok(tcx.intern_layout(self.univariant_uninterned(ty, fields, repr, kind)?))
|
||||
};
|
||||
debug_assert!(!ty.has_infer_types_or_consts());
|
||||
@ -754,7 +758,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
// but *not* an encoding of the discriminant (e.g., a tag value).
|
||||
// See issue #49298 for more details on the need to leave space
|
||||
// for non-ZST uninhabited data (mostly partial initialization).
|
||||
let absent = |fields: &[TyLayout<'_>]| {
|
||||
let absent = |fields: &[TyAndLayout<'_>]| {
|
||||
let uninhabited = fields.iter().any(|f| f.abi.is_uninhabited());
|
||||
let is_zst = fields.iter().all(|f| f.is_zst());
|
||||
uninhabited && is_zst
|
||||
@ -1404,7 +1408,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
let discr_int_ty = discr_int.to_ty(tcx, false);
|
||||
let discr = Scalar { value: Primitive::Int(discr_int, false), valid_range: 0..=max_discr };
|
||||
let discr_layout = self.tcx.intern_layout(Layout::scalar(self, discr.clone()));
|
||||
let discr_layout = TyLayout { ty: discr_int_ty, layout: discr_layout };
|
||||
let discr_layout = TyAndLayout { ty: discr_int_ty, layout: discr_layout };
|
||||
|
||||
let promoted_layouts = ineligible_locals
|
||||
.iter()
|
||||
@ -1573,7 +1577,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
/// This is invoked by the `layout_raw` query to record the final
|
||||
/// layout of each type.
|
||||
#[inline(always)]
|
||||
fn record_layout_for_printing(&self, layout: TyLayout<'tcx>) {
|
||||
fn record_layout_for_printing(&self, layout: TyAndLayout<'tcx>) {
|
||||
// If we are running with `-Zprint-type-sizes`, maybe record layouts
|
||||
// for dumping later.
|
||||
if self.tcx.sess.opts.debugging_opts.print_type_sizes {
|
||||
@ -1581,7 +1585,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
}
|
||||
}
|
||||
|
||||
fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) {
|
||||
fn record_layout_for_printing_outlined(&self, layout: TyAndLayout<'tcx>) {
|
||||
// Ignore layouts that are done with non-empty environments or
|
||||
// non-monomorphic layouts, as the user only wants to see the stuff
|
||||
// resulting from the final codegen session.
|
||||
@ -1624,7 +1628,9 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
let adt_kind = adt_def.adt_kind();
|
||||
let adt_packed = adt_def.repr.pack.is_some();
|
||||
|
||||
let build_variant_info = |n: Option<Ident>, flds: &[ast::Name], layout: TyLayout<'tcx>| {
|
||||
let build_variant_info = |n: Option<Ident>,
|
||||
flds: &[ast::Name],
|
||||
layout: TyAndLayout<'tcx>| {
|
||||
let mut min_size = Size::ZERO;
|
||||
let field_info: Vec<_> = flds
|
||||
.iter()
|
||||
@ -1891,19 +1897,19 @@ impl<'tcx, T: HasTyCtxt<'tcx>> HasTyCtxt<'tcx> for LayoutCx<'tcx, T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub type TyLayout<'tcx> = ::rustc_target::abi::TyLayout<'tcx, Ty<'tcx>>;
|
||||
pub type TyAndLayout<'tcx> = ::rustc_target::abi::TyAndLayout<'tcx, Ty<'tcx>>;
|
||||
|
||||
impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
|
||||
type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>;
|
||||
|
||||
/// Computes the layout of a type. Note that this implicitly
|
||||
/// executes in "reveal all" mode.
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
|
||||
let param_env = self.param_env.with_reveal_all();
|
||||
let ty = self.tcx.normalize_erasing_regions(param_env, ty);
|
||||
let layout = self.tcx.layout_raw(param_env.and(ty))?;
|
||||
let layout = TyLayout { ty, layout };
|
||||
let layout = TyAndLayout { ty, layout };
|
||||
|
||||
// N.B., this recording is normally disabled; when enabled, it
|
||||
// can however trigger recursive invocations of `layout_of`.
|
||||
@ -1919,15 +1925,15 @@ impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
|
||||
impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
|
||||
type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>;
|
||||
|
||||
/// Computes the layout of a type. Note that this implicitly
|
||||
/// executes in "reveal all" mode.
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
|
||||
let param_env = self.param_env.with_reveal_all();
|
||||
let ty = self.tcx.normalize_erasing_regions(param_env, ty);
|
||||
let layout = self.tcx.layout_raw(param_env.and(ty))?;
|
||||
let layout = TyLayout { ty, layout };
|
||||
let layout = TyAndLayout { ty, layout };
|
||||
|
||||
// N.B., this recording is normally disabled; when enabled, it
|
||||
// can however trigger recursive invocations of `layout_of`.
|
||||
@ -1950,7 +1956,7 @@ impl TyCtxt<'tcx> {
|
||||
pub fn layout_of(
|
||||
self,
|
||||
param_env_and_ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
|
||||
) -> Result<TyLayout<'tcx>, LayoutError<'tcx>> {
|
||||
) -> Result<TyAndLayout<'tcx>, LayoutError<'tcx>> {
|
||||
let cx = LayoutCx { tcx: self, param_env: param_env_and_ty.param_env };
|
||||
cx.layout_of(param_env_and_ty.value)
|
||||
}
|
||||
@ -1963,19 +1969,23 @@ impl ty::query::TyCtxtAt<'tcx> {
|
||||
pub fn layout_of(
|
||||
self,
|
||||
param_env_and_ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
|
||||
) -> Result<TyLayout<'tcx>, LayoutError<'tcx>> {
|
||||
) -> Result<TyAndLayout<'tcx>, LayoutError<'tcx>> {
|
||||
let cx = LayoutCx { tcx: self.at(self.span), param_env: param_env_and_ty.param_env };
|
||||
cx.layout_of(param_env_and_ty.value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
||||
impl<'tcx, C> TyAndLayoutMethods<'tcx, C> for Ty<'tcx>
|
||||
where
|
||||
C: LayoutOf<Ty = Ty<'tcx>, TyLayout: MaybeResult<TyLayout<'tcx>>>
|
||||
C: LayoutOf<Ty = Ty<'tcx>, TyAndLayout: MaybeResult<TyAndLayout<'tcx>>>
|
||||
+ HasTyCtxt<'tcx>
|
||||
+ HasParamEnv<'tcx>,
|
||||
{
|
||||
fn for_variant(this: TyLayout<'tcx>, cx: &C, variant_index: VariantIdx) -> TyLayout<'tcx> {
|
||||
fn for_variant(
|
||||
this: TyAndLayout<'tcx>,
|
||||
cx: &C,
|
||||
variant_index: VariantIdx,
|
||||
) -> TyAndLayout<'tcx> {
|
||||
let layout = match this.variants {
|
||||
Variants::Single { index }
|
||||
// If all variants but one are uninhabited, the variant layout is the enum layout.
|
||||
@ -2013,14 +2023,14 @@ where
|
||||
|
||||
assert_eq!(layout.variants, Variants::Single { index: variant_index });
|
||||
|
||||
TyLayout { ty: this.ty, layout }
|
||||
TyAndLayout { ty: this.ty, layout }
|
||||
}
|
||||
|
||||
fn field(this: TyLayout<'tcx>, cx: &C, i: usize) -> C::TyLayout {
|
||||
fn field(this: TyAndLayout<'tcx>, cx: &C, i: usize) -> C::TyAndLayout {
|
||||
let tcx = cx.tcx();
|
||||
let discr_layout = |discr: &Scalar| -> C::TyLayout {
|
||||
let discr_layout = |discr: &Scalar| -> C::TyAndLayout {
|
||||
let layout = Layout::scalar(cx, discr.clone());
|
||||
MaybeResult::from(Ok(TyLayout {
|
||||
MaybeResult::from(Ok(TyAndLayout {
|
||||
layout: tcx.intern_layout(layout),
|
||||
ty: discr.value.to_ty(tcx),
|
||||
}))
|
||||
@ -2037,7 +2047,7 @@ where
|
||||
| ty::FnDef(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Foreign(..)
|
||||
| ty::Dynamic(..) => bug!("TyLayout::field_type({:?}): not applicable", this),
|
||||
| ty::Dynamic(..) => bug!("TyAndLayout::field_type({:?}): not applicable", this),
|
||||
|
||||
// Potentially-fat pointers.
|
||||
ty::Ref(_, pointee, _) | ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
|
||||
@ -2080,7 +2090,7 @@ where
|
||||
])
|
||||
*/
|
||||
}
|
||||
_ => bug!("TyLayout::field_type({:?}): not applicable", this),
|
||||
_ => bug!("TyAndLayout::field_type({:?}): not applicable", this),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2132,11 +2142,11 @@ where
|
||||
| ty::Opaque(..)
|
||||
| ty::Param(_)
|
||||
| ty::Infer(_)
|
||||
| ty::Error => bug!("TyLayout::field_type: unexpected type `{}`", this.ty),
|
||||
| ty::Error => bug!("TyAndLayout::field_type: unexpected type `{}`", this.ty),
|
||||
})
|
||||
}
|
||||
|
||||
fn pointee_info_at(this: TyLayout<'tcx>, cx: &C, offset: Size) -> Option<PointeeInfo> {
|
||||
fn pointee_info_at(this: TyAndLayout<'tcx>, cx: &C, offset: Size) -> Option<PointeeInfo> {
|
||||
match this.ty.kind {
|
||||
ty::RawPtr(mt) if offset.bytes() == 0 => {
|
||||
cx.layout_of(mt.ty).to_result().ok().map(|layout| PointeeInfo {
|
||||
@ -2337,7 +2347,7 @@ impl<'tcx> ty::Instance<'tcx> {
|
||||
|
||||
pub trait FnAbiExt<'tcx, C>
|
||||
where
|
||||
C: LayoutOf<Ty = Ty<'tcx>, TyLayout = TyLayout<'tcx>>
|
||||
C: LayoutOf<Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
|
||||
+ HasDataLayout
|
||||
+ HasTargetSpec
|
||||
+ HasTyCtxt<'tcx>
|
||||
@ -2368,7 +2378,7 @@ where
|
||||
|
||||
impl<'tcx, C> FnAbiExt<'tcx, C> for call::FnAbi<'tcx, Ty<'tcx>>
|
||||
where
|
||||
C: LayoutOf<Ty = Ty<'tcx>, TyLayout = TyLayout<'tcx>>
|
||||
C: LayoutOf<Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
|
||||
+ HasDataLayout
|
||||
+ HasTargetSpec
|
||||
+ HasTyCtxt<'tcx>
|
||||
@ -2518,7 +2528,7 @@ where
|
||||
// Handle safe Rust thin and fat pointers.
|
||||
let adjust_for_rust_scalar = |attrs: &mut ArgAttributes,
|
||||
scalar: &Scalar,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
offset: Size,
|
||||
is_return: bool| {
|
||||
// Booleans are always an i1 that needs to be zero-extended.
|
||||
|
@ -7,7 +7,7 @@ use crate::type_of::LayoutLlvmExt;
|
||||
use crate::value::Value;
|
||||
use libc::{c_char, c_uint};
|
||||
use log::debug;
|
||||
use rustc::ty::layout::{self, Align, Size, TyLayout};
|
||||
use rustc::ty::layout::{self, Align, Size, TyAndLayout};
|
||||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
use rustc_codegen_ssa::base::to_immediate;
|
||||
use rustc_codegen_ssa::common::{IntPredicate, RealPredicate, TypeKind};
|
||||
@ -86,9 +86,9 @@ impl HasTargetSpec for Builder<'_, '_, 'tcx> {
|
||||
|
||||
impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyLayout = TyLayout<'tcx>;
|
||||
type TyAndLayout = TyAndLayout<'tcx>;
|
||||
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
|
||||
self.cx.layout_of(ty)
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ use rustc_codegen_ssa::traits::*;
|
||||
|
||||
use crate::consts::const_alloc_to_llvm;
|
||||
use rustc::mir::interpret::{Allocation, GlobalAlloc, Scalar};
|
||||
use rustc::ty::layout::{self, HasDataLayout, LayoutOf, Size, TyLayout};
|
||||
use rustc::ty::layout::{self, HasDataLayout, LayoutOf, Size, TyAndLayout};
|
||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||
|
||||
use libc::{c_char, c_uint};
|
||||
@ -289,7 +289,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
|
||||
fn from_const_alloc(
|
||||
&self,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
alloc: &Allocation,
|
||||
offset: Size,
|
||||
) -> PlaceRef<'tcx, &'ll Value> {
|
||||
|
@ -9,7 +9,7 @@ use crate::value::Value;
|
||||
use rustc::bug;
|
||||
use rustc::mir::mono::CodegenUnit;
|
||||
use rustc::ty::layout::{
|
||||
HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx,
|
||||
HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc::ty::{self, Instance, Ty, TyCtxt};
|
||||
use rustc_codegen_ssa::base::wants_msvc_seh;
|
||||
@ -837,13 +837,13 @@ impl ty::layout::HasTyCtxt<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
|
||||
impl LayoutOf for CodegenCx<'ll, 'tcx> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyLayout = TyLayout<'tcx>;
|
||||
type TyAndLayout = TyAndLayout<'tcx>;
|
||||
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
|
||||
self.spanned_layout_of(ty, DUMMY_SP)
|
||||
}
|
||||
|
||||
fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Span) -> Self::TyLayout {
|
||||
fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Span) -> Self::TyAndLayout {
|
||||
self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)).unwrap_or_else(|e| {
|
||||
if let LayoutError::SizeOverflow(_) = e {
|
||||
self.sess().span_fatal(span, &e.to_string())
|
||||
|
@ -25,7 +25,7 @@ use rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc::mir::interpret::truncate;
|
||||
use rustc::mir::{self, Field, GeneratorLayout};
|
||||
use rustc::ty::layout::{
|
||||
self, Align, Integer, IntegerExt, LayoutOf, PrimitiveExt, Size, TyLayout, VariantIdx,
|
||||
self, Align, Integer, IntegerExt, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc::ty::subst::{GenericArgKind, SubstsRef};
|
||||
use rustc::ty::Instance;
|
||||
@ -1203,7 +1203,7 @@ fn prepare_tuple_metadata(
|
||||
//=-----------------------------------------------------------------------------
|
||||
|
||||
struct UnionMemberDescriptionFactory<'tcx> {
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
variant: &'tcx ty::VariantDef,
|
||||
span: Span,
|
||||
}
|
||||
@ -1325,7 +1325,7 @@ fn generator_layout_and_saved_local_names(
|
||||
/// offset of zero bytes).
|
||||
struct EnumMemberDescriptionFactory<'ll, 'tcx> {
|
||||
enum_type: Ty<'tcx>,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
discriminant_type_metadata: Option<&'ll DIType>,
|
||||
containing_scope: &'ll DIScope,
|
||||
span: Span,
|
||||
@ -1494,7 +1494,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
|
||||
fn compute_field_path<'a, 'tcx>(
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
name: &mut String,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
offset: Size,
|
||||
size: Size,
|
||||
) {
|
||||
@ -1695,7 +1695,7 @@ impl<'tcx> VariantInfo<'_, 'tcx> {
|
||||
/// `RecursiveTypeDescription`.
|
||||
fn describe_enum_variant(
|
||||
cx: &CodegenCx<'ll, 'tcx>,
|
||||
layout: layout::TyLayout<'tcx>,
|
||||
layout: layout::TyAndLayout<'tcx>,
|
||||
variant: VariantInfo<'_, 'tcx>,
|
||||
discriminant_info: EnumDiscriminantInfo<'ll>,
|
||||
containing_scope: &'ll DIScope,
|
||||
|
@ -10,7 +10,7 @@ use rustc_codegen_ssa::traits::*;
|
||||
use crate::abi::{FnAbiLlvmExt, LlvmType};
|
||||
use crate::common;
|
||||
use crate::type_of::LayoutLlvmExt;
|
||||
use rustc::ty::layout::{self, Align, Size, TyLayout};
|
||||
use rustc::ty::layout::{self, Align, Size, TyAndLayout};
|
||||
use rustc::ty::Ty;
|
||||
use rustc_ast::ast;
|
||||
use rustc_codegen_ssa::common::TypeKind;
|
||||
@ -250,24 +250,24 @@ impl Type {
|
||||
}
|
||||
|
||||
impl LayoutTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
fn backend_type(&self, layout: TyLayout<'tcx>) -> &'ll Type {
|
||||
fn backend_type(&self, layout: TyAndLayout<'tcx>) -> &'ll Type {
|
||||
layout.llvm_type(self)
|
||||
}
|
||||
fn immediate_backend_type(&self, layout: TyLayout<'tcx>) -> &'ll Type {
|
||||
fn immediate_backend_type(&self, layout: TyAndLayout<'tcx>) -> &'ll Type {
|
||||
layout.immediate_llvm_type(self)
|
||||
}
|
||||
fn is_backend_immediate(&self, layout: TyLayout<'tcx>) -> bool {
|
||||
fn is_backend_immediate(&self, layout: TyAndLayout<'tcx>) -> bool {
|
||||
layout.is_llvm_immediate()
|
||||
}
|
||||
fn is_backend_scalar_pair(&self, layout: TyLayout<'tcx>) -> bool {
|
||||
fn is_backend_scalar_pair(&self, layout: TyAndLayout<'tcx>) -> bool {
|
||||
layout.is_llvm_scalar_pair()
|
||||
}
|
||||
fn backend_field_index(&self, layout: TyLayout<'tcx>, index: usize) -> u64 {
|
||||
fn backend_field_index(&self, layout: TyAndLayout<'tcx>, index: usize) -> u64 {
|
||||
layout.llvm_field_index(index)
|
||||
}
|
||||
fn scalar_pair_element_backend_type(
|
||||
&self,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
index: usize,
|
||||
immediate: bool,
|
||||
) -> &'ll Type {
|
||||
|
@ -3,18 +3,18 @@ use crate::common::*;
|
||||
use crate::type_::Type;
|
||||
use log::debug;
|
||||
use rustc::bug;
|
||||
use rustc::ty::layout::{self, Align, FnAbiExt, LayoutOf, PointeeInfo, Size, TyLayout};
|
||||
use rustc::ty::layout::{self, Align, FnAbiExt, LayoutOf, PointeeInfo, Size, TyAndLayout};
|
||||
use rustc::ty::print::obsolete::DefPathBasedNames;
|
||||
use rustc::ty::{self, Ty, TypeFoldable};
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_target::abi::TyLayoutMethods;
|
||||
use rustc_target::abi::TyAndLayoutMethods;
|
||||
|
||||
use std::fmt::Write;
|
||||
|
||||
fn uncached_llvm_type<'a, 'tcx>(
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
layout: TyLayout<'tcx>,
|
||||
defer: &mut Option<(&'a Type, TyLayout<'tcx>)>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
defer: &mut Option<(&'a Type, TyAndLayout<'tcx>)>,
|
||||
) -> &'a Type {
|
||||
match layout.abi {
|
||||
layout::Abi::Scalar(_) => bug!("handled elsewhere"),
|
||||
@ -110,7 +110,7 @@ fn uncached_llvm_type<'a, 'tcx>(
|
||||
|
||||
fn struct_llfields<'a, 'tcx>(
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> (Vec<&'a Type>, bool) {
|
||||
debug!("struct_llfields: {:#?}", layout);
|
||||
let field_count = layout.fields.count();
|
||||
@ -202,7 +202,7 @@ pub trait LayoutLlvmExt<'tcx> {
|
||||
fn pointee_info_at<'a>(&self, cx: &CodegenCx<'a, 'tcx>, offset: Size) -> Option<PointeeInfo>;
|
||||
}
|
||||
|
||||
impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
||||
impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
||||
fn is_llvm_immediate(&self) -> bool {
|
||||
match self.abi {
|
||||
layout::Abi::Scalar(_) | layout::Abi::Vector { .. } => true,
|
||||
@ -344,7 +344,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
||||
|
||||
let (a, b) = match self.abi {
|
||||
layout::Abi::ScalarPair(ref a, ref b) => (a, b),
|
||||
_ => bug!("TyLayout::scalar_pair_element_llty({:?}): not applicable", self),
|
||||
_ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self),
|
||||
};
|
||||
let scalar = [a, b][index];
|
||||
|
||||
@ -366,13 +366,13 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
||||
fn llvm_field_index(&self, index: usize) -> u64 {
|
||||
match self.abi {
|
||||
layout::Abi::Scalar(_) | layout::Abi::ScalarPair(..) => {
|
||||
bug!("TyLayout::llvm_field_index({:?}): not applicable", self)
|
||||
bug!("TyAndLayout::llvm_field_index({:?}): not applicable", self)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
match self.fields {
|
||||
layout::FieldPlacement::Union(_) => {
|
||||
bug!("TyLayout::llvm_field_index({:?}): not applicable", self)
|
||||
bug!("TyAndLayout::llvm_field_index({:?}): not applicable", self)
|
||||
}
|
||||
|
||||
layout::FieldPlacement::Array { .. } => index as u64,
|
||||
|
@ -31,7 +31,7 @@ use rustc::middle::cstore::{self, LinkagePreference};
|
||||
use rustc::middle::lang_items;
|
||||
use rustc::middle::lang_items::StartFnLangItem;
|
||||
use rustc::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem};
|
||||
use rustc::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyLayout, VariantIdx};
|
||||
use rustc::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyAndLayout, VariantIdx};
|
||||
use rustc::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::{self, Instance, Ty, TyCtxt};
|
||||
@ -341,7 +341,7 @@ pub fn from_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub fn to_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
bx: &mut Bx,
|
||||
val: Bx::Value,
|
||||
layout: layout::TyLayout<'_>,
|
||||
layout: layout::TyAndLayout<'_>,
|
||||
) -> Bx::Value {
|
||||
if let layout::Abi::Scalar(ref scalar) = layout.abi {
|
||||
return to_immediate_scalar(bx, val, scalar);
|
||||
@ -366,7 +366,7 @@ pub fn memcpy_ty<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
dst_align: Align,
|
||||
src: Bx::Value,
|
||||
src_align: Align,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
flags: MemFlags,
|
||||
) {
|
||||
let size = layout.size.bytes();
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::base;
|
||||
use crate::traits::*;
|
||||
use rustc::mir;
|
||||
use rustc::ty::layout::{FnAbiExt, HasTyCtxt, TyLayout};
|
||||
use rustc::ty::layout::{FnAbiExt, HasTyCtxt, TyAndLayout};
|
||||
use rustc::ty::{self, Instance, Ty, TypeFoldable};
|
||||
use rustc_target::abi::call::{FnAbi, PassMode};
|
||||
|
||||
@ -114,7 +114,7 @@ enum LocalRef<'tcx, V> {
|
||||
impl<'a, 'tcx, V: CodegenObject> LocalRef<'tcx, V> {
|
||||
fn new_operand<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
bx: &mut Bx,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> LocalRef<'tcx, V> {
|
||||
if layout.is_zst() {
|
||||
// Zero-size temporaries aren't always initialized, which
|
||||
|
@ -8,7 +8,7 @@ use crate::MemFlags;
|
||||
|
||||
use rustc::mir;
|
||||
use rustc::mir::interpret::{ConstValue, ErrorHandled, Pointer, Scalar};
|
||||
use rustc::ty::layout::{self, Align, LayoutOf, Size, TyLayout};
|
||||
use rustc::ty::layout::{self, Align, LayoutOf, Size, TyAndLayout};
|
||||
use rustc::ty::Ty;
|
||||
|
||||
use std::fmt;
|
||||
@ -43,7 +43,7 @@ pub struct OperandRef<'tcx, V> {
|
||||
pub val: OperandValue<V>,
|
||||
|
||||
// The layout of value, based on its Rust type.
|
||||
pub layout: TyLayout<'tcx>,
|
||||
pub layout: TyAndLayout<'tcx>,
|
||||
}
|
||||
|
||||
impl<V: CodegenObject> fmt::Debug for OperandRef<'tcx, V> {
|
||||
@ -55,7 +55,7 @@ impl<V: CodegenObject> fmt::Debug for OperandRef<'tcx, V> {
|
||||
impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
||||
pub fn new_zst<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
bx: &mut Bx,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> OperandRef<'tcx, V> {
|
||||
assert!(layout.is_zst());
|
||||
OperandRef {
|
||||
@ -159,7 +159,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
||||
pub fn from_immediate_or_packed_pair<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
bx: &mut Bx,
|
||||
llval: V,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> Self {
|
||||
let val = if let layout::Abi::ScalarPair(ref a, ref b) = layout.abi {
|
||||
debug!("Operand::from_immediate_or_packed_pair: unpacking {:?} @ {:?}", llval, layout);
|
||||
|
@ -8,7 +8,7 @@ use crate::MemFlags;
|
||||
|
||||
use rustc::mir;
|
||||
use rustc::mir::tcx::PlaceTy;
|
||||
use rustc::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyLayout, VariantIdx};
|
||||
use rustc::ty::layout::{self, Align, HasTyCtxt, LayoutOf, TyAndLayout, VariantIdx};
|
||||
use rustc::ty::{self, Ty};
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
@ -20,19 +20,23 @@ pub struct PlaceRef<'tcx, V> {
|
||||
pub llextra: Option<V>,
|
||||
|
||||
/// The monomorphized type of this place, including variant information.
|
||||
pub layout: TyLayout<'tcx>,
|
||||
pub layout: TyAndLayout<'tcx>,
|
||||
|
||||
/// The alignment we know for this place.
|
||||
pub align: Align,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
||||
pub fn new_sized(llval: V, layout: TyLayout<'tcx>) -> PlaceRef<'tcx, V> {
|
||||
pub fn new_sized(llval: V, layout: TyAndLayout<'tcx>) -> PlaceRef<'tcx, V> {
|
||||
assert!(!layout.is_unsized());
|
||||
PlaceRef { llval, llextra: None, layout, align: layout.align.abi }
|
||||
}
|
||||
|
||||
pub fn new_sized_aligned(llval: V, layout: TyLayout<'tcx>, align: Align) -> PlaceRef<'tcx, V> {
|
||||
pub fn new_sized_aligned(
|
||||
llval: V,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
align: Align,
|
||||
) -> PlaceRef<'tcx, V> {
|
||||
assert!(!layout.is_unsized());
|
||||
PlaceRef { llval, llextra: None, layout, align }
|
||||
}
|
||||
@ -41,7 +45,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
||||
// unless LLVM IR names are turned on (e.g. for `--emit=llvm-ir`).
|
||||
pub fn alloca<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
bx: &mut Bx,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> Self {
|
||||
assert!(!layout.is_unsized(), "tried to statically allocate unsized place");
|
||||
let tmp = bx.alloca(bx.cx().backend_type(layout), layout.align.abi);
|
||||
@ -53,7 +57,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
||||
// unless LLVM IR names are turned on (e.g. for `--emit=llvm-ir`).
|
||||
pub fn alloca_unsized_indirect<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
bx: &mut Bx,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> Self {
|
||||
assert!(layout.is_unsized(), "tried to allocate indirect place for sized values");
|
||||
let ptr_ty = bx.cx().tcx().mk_mut_ptr(layout.ty);
|
||||
|
@ -4,7 +4,7 @@ use crate::ModuleCodegen;
|
||||
|
||||
use rustc::dep_graph::DepGraph;
|
||||
use rustc::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
|
||||
use rustc::ty::layout::{HasTyCtxt, LayoutOf, TyLayout};
|
||||
use rustc::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::{Ty, TyCtxt};
|
||||
use rustc::util::common::ErrorReported;
|
||||
@ -35,12 +35,12 @@ pub trait BackendTypes {
|
||||
}
|
||||
|
||||
pub trait Backend<'tcx>:
|
||||
Sized + BackendTypes + HasTyCtxt<'tcx> + LayoutOf<Ty = Ty<'tcx>, TyLayout = TyLayout<'tcx>>
|
||||
Sized + BackendTypes + HasTyCtxt<'tcx> + LayoutOf<Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
|
||||
{
|
||||
}
|
||||
|
||||
impl<'tcx, T> Backend<'tcx> for T where
|
||||
Self: BackendTypes + HasTyCtxt<'tcx> + LayoutOf<Ty = Ty<'tcx>, TyLayout = TyLayout<'tcx>>
|
||||
Self: BackendTypes + HasTyCtxt<'tcx> + LayoutOf<Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ pub trait ConstMethods<'tcx>: BackendTypes {
|
||||
) -> Self::Value;
|
||||
fn from_const_alloc(
|
||||
&self,
|
||||
layout: layout::TyLayout<'tcx>,
|
||||
layout: layout::TyAndLayout<'tcx>,
|
||||
alloc: &Allocation,
|
||||
offset: layout::Size,
|
||||
) -> PlaceRef<'tcx, Self::Value>;
|
||||
|
@ -3,7 +3,7 @@ use super::Backend;
|
||||
use super::HasCodegen;
|
||||
use crate::common::TypeKind;
|
||||
use crate::mir::place::PlaceRef;
|
||||
use rustc::ty::layout::{self, TyLayout};
|
||||
use rustc::ty::layout::{self, TyAndLayout};
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg};
|
||||
@ -94,17 +94,17 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
|
||||
impl<T> DerivedTypeMethods<'tcx> for T where Self: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {}
|
||||
|
||||
pub trait LayoutTypeMethods<'tcx>: Backend<'tcx> {
|
||||
fn backend_type(&self, layout: TyLayout<'tcx>) -> Self::Type;
|
||||
fn backend_type(&self, layout: TyAndLayout<'tcx>) -> Self::Type;
|
||||
fn cast_backend_type(&self, ty: &CastTarget) -> Self::Type;
|
||||
fn fn_ptr_backend_type(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> Self::Type;
|
||||
fn reg_backend_type(&self, ty: &Reg) -> Self::Type;
|
||||
fn immediate_backend_type(&self, layout: TyLayout<'tcx>) -> Self::Type;
|
||||
fn is_backend_immediate(&self, layout: TyLayout<'tcx>) -> bool;
|
||||
fn is_backend_scalar_pair(&self, layout: TyLayout<'tcx>) -> bool;
|
||||
fn backend_field_index(&self, layout: TyLayout<'tcx>, index: usize) -> u64;
|
||||
fn immediate_backend_type(&self, layout: TyAndLayout<'tcx>) -> Self::Type;
|
||||
fn is_backend_immediate(&self, layout: TyAndLayout<'tcx>) -> bool;
|
||||
fn is_backend_scalar_pair(&self, layout: TyAndLayout<'tcx>) -> bool;
|
||||
fn backend_field_index(&self, layout: TyAndLayout<'tcx>, index: usize) -> u64;
|
||||
fn scalar_pair_element_backend_type(
|
||||
&self,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
index: usize,
|
||||
immediate: bool,
|
||||
) -> Self::Type;
|
||||
|
@ -220,7 +220,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
||||
// ABI, linking, symbols, and FFI
|
||||
ungated!(
|
||||
link, Whitelisted,
|
||||
template!(List: r#"name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...""#),
|
||||
template!(List: r#"name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...""#),
|
||||
),
|
||||
ungated!(link_name, Whitelisted, template!(NameValueStr: "name")),
|
||||
ungated!(no_link, Normal, template!(Word)),
|
||||
|
@ -21,7 +21,7 @@ use crate::passes::{EarlyLintPassObject, LateLintPassObject};
|
||||
use rustc::lint::LintDiagnosticBuilder;
|
||||
use rustc::middle::privacy::AccessLevels;
|
||||
use rustc::middle::stability;
|
||||
use rustc::ty::layout::{LayoutError, LayoutOf, TyLayout};
|
||||
use rustc::ty::layout::{LayoutError, LayoutOf, TyAndLayout};
|
||||
use rustc::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt};
|
||||
use rustc_ast::ast;
|
||||
use rustc_ast::util::lev_distance::find_best_match_for_name;
|
||||
@ -811,9 +811,9 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
|
||||
|
||||
impl<'a, 'tcx> LayoutOf for LateContext<'a, 'tcx> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
|
||||
type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>;
|
||||
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
|
||||
self.tcx.layout_of(self.param_env.and(ty))
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use rustc::ty::adjustment::PointerCast;
|
||||
use rustc::ty::layout::{self, Size, TyLayout};
|
||||
use rustc::ty::layout::{self, Size, TyAndLayout};
|
||||
use rustc::ty::{self, Ty, TypeAndMut, TypeFoldable};
|
||||
use rustc_ast::ast::FloatTy;
|
||||
use rustc_span::symbol::sym;
|
||||
@ -102,7 +102,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
fn cast_immediate(
|
||||
&self,
|
||||
src: ImmTy<'tcx, M::PointerTag>,
|
||||
dest_layout: TyLayout<'tcx>,
|
||||
dest_layout: TyAndLayout<'tcx>,
|
||||
) -> InterpResult<'tcx, Immediate<M::PointerTag>> {
|
||||
use rustc::ty::TyKind::*;
|
||||
trace!("Casting {:?}: {:?} to {:?}", *src, src.layout.ty, dest_layout.ty);
|
||||
@ -183,8 +183,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
fn cast_from_int_like(
|
||||
&self,
|
||||
v: u128, // raw bits
|
||||
src_layout: TyLayout<'tcx>,
|
||||
dest_layout: TyLayout<'tcx>,
|
||||
src_layout: TyAndLayout<'tcx>,
|
||||
dest_layout: TyAndLayout<'tcx>,
|
||||
) -> InterpResult<'tcx, Scalar<M::PointerTag>> {
|
||||
// Let's make sure v is sign-extended *if* it has a signed type.
|
||||
let signed = src_layout.abi.is_signed();
|
||||
|
@ -7,7 +7,7 @@ use rustc::mir;
|
||||
use rustc::mir::interpret::{
|
||||
sign_extend, truncate, AllocId, FrameInfo, GlobalId, InterpResult, Pointer, Scalar,
|
||||
};
|
||||
use rustc::ty::layout::{self, Align, HasDataLayout, LayoutOf, Size, TyLayout};
|
||||
use rustc::ty::layout::{self, Align, HasDataLayout, LayoutOf, Size, TyAndLayout};
|
||||
use rustc::ty::query::TyCtxtAt;
|
||||
use rustc::ty::subst::SubstsRef;
|
||||
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||
@ -114,7 +114,7 @@ pub struct LocalState<'tcx, Tag = (), Id = AllocId> {
|
||||
pub value: LocalValue<Tag, Id>,
|
||||
/// Don't modify if `Some`, this is only used to prevent computing the layout twice
|
||||
#[stable_hasher(ignore)]
|
||||
pub layout: Cell<Option<TyLayout<'tcx>>>,
|
||||
pub layout: Cell<Option<TyAndLayout<'tcx>>>,
|
||||
}
|
||||
|
||||
/// Current value of a local variable
|
||||
@ -202,10 +202,10 @@ where
|
||||
|
||||
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for InterpCx<'mir, 'tcx, M> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyLayout = InterpResult<'tcx, TyLayout<'tcx>>;
|
||||
type TyAndLayout = InterpResult<'tcx, TyAndLayout<'tcx>>;
|
||||
|
||||
#[inline]
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
|
||||
self.tcx
|
||||
.layout_of(self.param_env.and(ty))
|
||||
.map_err(|layout| err_inval!(Layout(layout)).into())
|
||||
@ -284,13 +284,13 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn sign_extend(&self, value: u128, ty: TyLayout<'_>) -> u128 {
|
||||
pub fn sign_extend(&self, value: u128, ty: TyAndLayout<'_>) -> u128 {
|
||||
assert!(ty.abi.is_signed());
|
||||
sign_extend(value, ty.size)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn truncate(&self, value: u128, ty: TyLayout<'_>) -> u128 {
|
||||
pub fn truncate(&self, value: u128, ty: TyAndLayout<'_>) -> u128 {
|
||||
truncate(value, ty.size)
|
||||
}
|
||||
|
||||
@ -373,8 +373,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
&self,
|
||||
frame: &Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra>,
|
||||
local: mir::Local,
|
||||
layout: Option<TyLayout<'tcx>>,
|
||||
) -> InterpResult<'tcx, TyLayout<'tcx>> {
|
||||
layout: Option<TyAndLayout<'tcx>>,
|
||||
) -> InterpResult<'tcx, TyAndLayout<'tcx>> {
|
||||
// `const_prop` runs into this with an invalid (empty) frame, so we
|
||||
// have to support that case (mostly by skipping all caching).
|
||||
match frame.locals.get(local).and_then(|state| state.layout.get()) {
|
||||
@ -401,7 +401,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
pub(super) fn size_and_align_of(
|
||||
&self,
|
||||
metadata: MemPlaceMeta<M::PointerTag>,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> InterpResult<'tcx, Option<(Size, Align)>> {
|
||||
if !layout.is_unsized() {
|
||||
return Ok(Some((layout.size, layout.align.abi)));
|
||||
|
@ -9,7 +9,7 @@ use rustc::mir::interpret::{
|
||||
sign_extend, truncate, AllocId, ConstValue, GlobalId, InterpResult, Pointer, Scalar,
|
||||
};
|
||||
use rustc::ty::layout::{
|
||||
self, HasDataLayout, IntegerExt, LayoutOf, PrimitiveExt, Size, TyLayout, VariantIdx,
|
||||
self, HasDataLayout, IntegerExt, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc::ty::print::{FmtPrinter, PrettyPrinter, Printer};
|
||||
use rustc::ty::Ty;
|
||||
@ -88,7 +88,7 @@ impl<'tcx, Tag> Immediate<Tag> {
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct ImmTy<'tcx, Tag = ()> {
|
||||
pub(crate) imm: Immediate<Tag>,
|
||||
pub layout: TyLayout<'tcx>,
|
||||
pub layout: TyAndLayout<'tcx>,
|
||||
}
|
||||
|
||||
impl<Tag: Copy> std::fmt::Display for ImmTy<'tcx, Tag> {
|
||||
@ -152,7 +152,7 @@ pub enum Operand<Tag = (), Id = AllocId> {
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct OpTy<'tcx, Tag = ()> {
|
||||
op: Operand<Tag>, // Keep this private; it helps enforce invariants.
|
||||
pub layout: TyLayout<'tcx>,
|
||||
pub layout: TyAndLayout<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx, Tag> ::std::ops::Deref for OpTy<'tcx, Tag> {
|
||||
@ -179,26 +179,26 @@ impl<'tcx, Tag> From<ImmTy<'tcx, Tag>> for OpTy<'tcx, Tag> {
|
||||
|
||||
impl<'tcx, Tag: Copy> ImmTy<'tcx, Tag> {
|
||||
#[inline]
|
||||
pub fn from_scalar(val: Scalar<Tag>, layout: TyLayout<'tcx>) -> Self {
|
||||
pub fn from_scalar(val: Scalar<Tag>, layout: TyAndLayout<'tcx>) -> Self {
|
||||
ImmTy { imm: val.into(), layout }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn try_from_uint(i: impl Into<u128>, layout: TyLayout<'tcx>) -> Option<Self> {
|
||||
pub fn try_from_uint(i: impl Into<u128>, layout: TyAndLayout<'tcx>) -> Option<Self> {
|
||||
Some(Self::from_scalar(Scalar::try_from_uint(i, layout.size)?, layout))
|
||||
}
|
||||
#[inline]
|
||||
pub fn from_uint(i: impl Into<u128>, layout: TyLayout<'tcx>) -> Self {
|
||||
pub fn from_uint(i: impl Into<u128>, layout: TyAndLayout<'tcx>) -> Self {
|
||||
Self::from_scalar(Scalar::from_uint(i, layout.size), layout)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn try_from_int(i: impl Into<i128>, layout: TyLayout<'tcx>) -> Option<Self> {
|
||||
pub fn try_from_int(i: impl Into<i128>, layout: TyAndLayout<'tcx>) -> Option<Self> {
|
||||
Some(Self::from_scalar(Scalar::try_from_int(i, layout.size)?, layout))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_int(i: impl Into<i128>, layout: TyLayout<'tcx>) -> Self {
|
||||
pub fn from_int(i: impl Into<i128>, layout: TyAndLayout<'tcx>) -> Self {
|
||||
Self::from_scalar(Scalar::from_int(i, layout.size), layout)
|
||||
}
|
||||
}
|
||||
@ -207,9 +207,9 @@ impl<'tcx, Tag: Copy> ImmTy<'tcx, Tag> {
|
||||
// or compute the layout.
|
||||
#[inline(always)]
|
||||
pub(super) fn from_known_layout<'tcx>(
|
||||
layout: Option<TyLayout<'tcx>>,
|
||||
compute: impl FnOnce() -> InterpResult<'tcx, TyLayout<'tcx>>,
|
||||
) -> InterpResult<'tcx, TyLayout<'tcx>> {
|
||||
layout: Option<TyAndLayout<'tcx>>,
|
||||
compute: impl FnOnce() -> InterpResult<'tcx, TyAndLayout<'tcx>>,
|
||||
) -> InterpResult<'tcx, TyAndLayout<'tcx>> {
|
||||
match layout {
|
||||
None => compute(),
|
||||
Some(layout) => {
|
||||
@ -434,7 +434,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
&self,
|
||||
frame: &super::Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra>,
|
||||
local: mir::Local,
|
||||
layout: Option<TyLayout<'tcx>>,
|
||||
layout: Option<TyAndLayout<'tcx>>,
|
||||
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
|
||||
assert_ne!(local, mir::RETURN_PLACE);
|
||||
let layout = self.layout_of_local(frame, local, layout)?;
|
||||
@ -465,7 +465,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
pub fn eval_place_to_op(
|
||||
&self,
|
||||
place: &mir::Place<'tcx>,
|
||||
layout: Option<TyLayout<'tcx>>,
|
||||
layout: Option<TyAndLayout<'tcx>>,
|
||||
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
|
||||
let base_op = match place.local {
|
||||
mir::RETURN_PLACE => throw_ub!(ReadFromReturnPlace),
|
||||
@ -493,7 +493,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
pub fn eval_operand(
|
||||
&self,
|
||||
mir_op: &mir::Operand<'tcx>,
|
||||
layout: Option<TyLayout<'tcx>>,
|
||||
layout: Option<TyAndLayout<'tcx>>,
|
||||
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
|
||||
use rustc::mir::Operand::*;
|
||||
let op = match *mir_op {
|
||||
@ -525,7 +525,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
crate fn eval_const_to_op(
|
||||
&self,
|
||||
val: &ty::Const<'tcx>,
|
||||
layout: Option<TyLayout<'tcx>>,
|
||||
layout: Option<TyAndLayout<'tcx>>,
|
||||
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
|
||||
let tag_scalar = |scalar| match scalar {
|
||||
Scalar::Ptr(ptr) => Scalar::Ptr(self.tag_global_base_pointer(ptr)),
|
||||
|
@ -4,7 +4,7 @@ use rustc::mir;
|
||||
use rustc::mir::interpret::{InterpResult, Scalar};
|
||||
use rustc::ty::{
|
||||
self,
|
||||
layout::{LayoutOf, TyLayout},
|
||||
layout::{LayoutOf, TyAndLayout},
|
||||
Ty,
|
||||
};
|
||||
use rustc_apfloat::Float;
|
||||
@ -123,9 +123,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
bin_op: mir::BinOp,
|
||||
// passing in raw bits
|
||||
l: u128,
|
||||
left_layout: TyLayout<'tcx>,
|
||||
left_layout: TyAndLayout<'tcx>,
|
||||
r: u128,
|
||||
right_layout: TyLayout<'tcx>,
|
||||
right_layout: TyAndLayout<'tcx>,
|
||||
) -> InterpResult<'tcx, (Scalar<M::PointerTag>, bool, Ty<'tcx>)> {
|
||||
use rustc::mir::BinOp::*;
|
||||
|
||||
|
@ -8,7 +8,7 @@ use std::hash::Hash;
|
||||
use rustc::mir;
|
||||
use rustc::mir::interpret::truncate;
|
||||
use rustc::ty::layout::{
|
||||
self, Align, HasDataLayout, LayoutOf, PrimitiveExt, Size, TyLayout, VariantIdx,
|
||||
self, Align, HasDataLayout, LayoutOf, PrimitiveExt, Size, TyAndLayout, VariantIdx,
|
||||
};
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc_macros::HashStable;
|
||||
@ -86,7 +86,7 @@ pub enum Place<Tag = (), Id = AllocId> {
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct PlaceTy<'tcx, Tag = ()> {
|
||||
place: Place<Tag>, // Keep this private; it helps enforce invariants.
|
||||
pub layout: TyLayout<'tcx>,
|
||||
pub layout: TyAndLayout<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx, Tag> ::std::ops::Deref for PlaceTy<'tcx, Tag> {
|
||||
@ -101,7 +101,7 @@ impl<'tcx, Tag> ::std::ops::Deref for PlaceTy<'tcx, Tag> {
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub struct MPlaceTy<'tcx, Tag = ()> {
|
||||
mplace: MemPlace<Tag>,
|
||||
pub layout: TyLayout<'tcx>,
|
||||
pub layout: TyAndLayout<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx, Tag> ::std::ops::Deref for MPlaceTy<'tcx, Tag> {
|
||||
@ -178,7 +178,7 @@ impl<Tag> MemPlace<Tag> {
|
||||
impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
|
||||
/// Produces a MemPlace that works for ZST but nothing else
|
||||
#[inline]
|
||||
pub fn dangling(layout: TyLayout<'tcx>, cx: &impl HasDataLayout) -> Self {
|
||||
pub fn dangling(layout: TyAndLayout<'tcx>, cx: &impl HasDataLayout) -> Self {
|
||||
let align = layout.align.abi;
|
||||
let ptr = Scalar::from_machine_usize(align.bytes(), cx);
|
||||
// `Poison` this to make sure that the pointer value `ptr` is never observable by the program.
|
||||
@ -196,14 +196,14 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
|
||||
self,
|
||||
offset: Size,
|
||||
meta: MemPlaceMeta<Tag>,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
cx: &impl HasDataLayout,
|
||||
) -> InterpResult<'tcx, Self> {
|
||||
Ok(MPlaceTy { mplace: self.mplace.offset(offset, meta, cx)?, layout })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_aligned_ptr(ptr: Pointer<Tag>, layout: TyLayout<'tcx>) -> Self {
|
||||
fn from_aligned_ptr(ptr: Pointer<Tag>, layout: TyAndLayout<'tcx>) -> Self {
|
||||
MPlaceTy { mplace: MemPlace::from_ptr(ptr, layout.align.abi), layout }
|
||||
}
|
||||
|
||||
@ -1030,7 +1030,7 @@ where
|
||||
|
||||
pub fn allocate(
|
||||
&mut self,
|
||||
layout: TyLayout<'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
kind: MemoryKind<M::MemoryKind>,
|
||||
) -> MPlaceTy<'tcx, M::PointerTag> {
|
||||
let ptr = self.memory.allocate(layout.size, layout.align.abi, kind);
|
||||
@ -1077,7 +1077,7 @@ where
|
||||
..
|
||||
} => {
|
||||
// No need to validate that the discriminant here because the
|
||||
// `TyLayout::for_variant()` call earlier already checks the variant is valid.
|
||||
// `TyAndLayout::for_variant()` call earlier already checks the variant is valid.
|
||||
|
||||
let discr_val =
|
||||
dest.layout.ty.discriminant_for_variant(*self.tcx, variant_index).unwrap().val;
|
||||
@ -1099,7 +1099,7 @@ where
|
||||
..
|
||||
} => {
|
||||
// No need to validate that the discriminant here because the
|
||||
// `TyLayout::for_variant()` call earlier already checks the variant is valid.
|
||||
// `TyAndLayout::for_variant()` call earlier already checks the variant is valid.
|
||||
|
||||
if variant_index != dataful_variant {
|
||||
let variants_start = niche_variants.start().as_u32();
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::borrow::Cow;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use rustc::ty::layout::{self, LayoutOf, TyLayout};
|
||||
use rustc::ty::layout::{self, LayoutOf, TyAndLayout};
|
||||
use rustc::ty::Instance;
|
||||
use rustc::{mir, ty};
|
||||
use rustc_span::source_map::Span;
|
||||
@ -134,8 +134,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
|
||||
fn check_argument_compat(
|
||||
rust_abi: bool,
|
||||
caller: TyLayout<'tcx>,
|
||||
callee: TyLayout<'tcx>,
|
||||
caller: TyAndLayout<'tcx>,
|
||||
callee: TyAndLayout<'tcx>,
|
||||
) -> bool {
|
||||
if caller.ty == callee.ty {
|
||||
// No question
|
||||
|
@ -9,7 +9,7 @@ use std::fmt::Write;
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
use rustc::ty;
|
||||
use rustc::ty::layout::{self, LayoutOf, TyLayout, VariantIdx};
|
||||
use rustc::ty::layout::{self, LayoutOf, TyAndLayout, VariantIdx};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir as hir;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
@ -177,7 +177,7 @@ struct ValidityVisitor<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> {
|
||||
}
|
||||
|
||||
impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M> {
|
||||
fn aggregate_field_path_elem(&mut self, layout: TyLayout<'tcx>, field: usize) -> PathElem {
|
||||
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, .. } => {
|
||||
@ -266,7 +266,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
|
||||
fn check_wide_ptr_meta(
|
||||
&mut self,
|
||||
meta: MemPlaceMeta<M::PointerTag>,
|
||||
pointee: TyLayout<'tcx>,
|
||||
pointee: TyAndLayout<'tcx>,
|
||||
) -> InterpResult<'tcx> {
|
||||
let tail = self.ecx.tcx.struct_tail_erasing_lifetimes(pointee.ty, self.ecx.param_env);
|
||||
match tail.kind {
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
use rustc::mir::interpret::InterpResult;
|
||||
use rustc::ty;
|
||||
use rustc::ty::layout::{self, TyLayout, VariantIdx};
|
||||
use rustc::ty::layout::{self, TyAndLayout, VariantIdx};
|
||||
|
||||
use super::{InterpCx, MPlaceTy, Machine, OpTy};
|
||||
|
||||
@ -12,7 +12,7 @@ use super::{InterpCx, MPlaceTy, Machine, OpTy};
|
||||
// that's just more convenient to work with (avoids repeating all the `Machine` bounds).
|
||||
pub trait Value<'mir, 'tcx, M: Machine<'mir, 'tcx>>: Copy {
|
||||
/// Gets this value's layout.
|
||||
fn layout(&self) -> TyLayout<'tcx>;
|
||||
fn layout(&self) -> TyAndLayout<'tcx>;
|
||||
|
||||
/// Makes this into an `OpTy`.
|
||||
fn to_op(self, ecx: &InterpCx<'mir, 'tcx, M>) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>>;
|
||||
@ -36,7 +36,7 @@ pub trait Value<'mir, 'tcx, M: Machine<'mir, 'tcx>>: Copy {
|
||||
// Places in general are not due to `place_field` having to do `force_allocation`.
|
||||
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Value<'mir, 'tcx, M> for OpTy<'tcx, M::PointerTag> {
|
||||
#[inline(always)]
|
||||
fn layout(&self) -> TyLayout<'tcx> {
|
||||
fn layout(&self) -> TyAndLayout<'tcx> {
|
||||
self.layout
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Value<'mir, 'tcx, M> for OpTy<'tcx, M::
|
||||
|
||||
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Value<'mir, 'tcx, M> for MPlaceTy<'tcx, M::PointerTag> {
|
||||
#[inline(always)]
|
||||
fn layout(&self) -> TyLayout<'tcx> {
|
||||
fn layout(&self) -> TyAndLayout<'tcx> {
|
||||
self.layout
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ use rustc::mir::{
|
||||
UnOp, RETURN_PLACE,
|
||||
};
|
||||
use rustc::ty::layout::{
|
||||
HasDataLayout, HasTyCtxt, LayoutError, LayoutOf, Size, TargetDataLayout, TyLayout,
|
||||
HasDataLayout, HasTyCtxt, LayoutError, LayoutOf, Size, TargetDataLayout, TyAndLayout,
|
||||
};
|
||||
use rustc::ty::subst::{InternalSubsts, Subst};
|
||||
use rustc::ty::{self, ConstKind, Instance, ParamEnv, Ty, TyCtxt, TypeFoldable};
|
||||
@ -316,9 +316,9 @@ struct ConstPropagator<'mir, 'tcx> {
|
||||
|
||||
impl<'mir, 'tcx> LayoutOf for ConstPropagator<'mir, 'tcx> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
|
||||
type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>;
|
||||
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
|
||||
self.tcx.layout_of(self.param_env.and(ty))
|
||||
}
|
||||
}
|
||||
@ -573,7 +573,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
fn const_prop(
|
||||
&mut self,
|
||||
rvalue: &Rvalue<'tcx>,
|
||||
place_layout: TyLayout<'tcx>,
|
||||
place_layout: TyAndLayout<'tcx>,
|
||||
source_info: SourceInfo,
|
||||
place: &Place<'tcx>,
|
||||
) -> Option<()> {
|
||||
|
@ -5,7 +5,7 @@ use rustc::mir::{
|
||||
BasicBlock, BasicBlockData, Body, BodyAndCache, Local, Operand, Rvalue, StatementKind,
|
||||
TerminatorKind,
|
||||
};
|
||||
use rustc::ty::layout::{Abi, TyLayout, Variants};
|
||||
use rustc::ty::layout::{Abi, TyAndLayout, Variants};
|
||||
use rustc::ty::{Ty, TyCtxt};
|
||||
|
||||
pub struct UninhabitedEnumBranching;
|
||||
@ -49,7 +49,7 @@ fn get_switched_on_type<'tcx>(
|
||||
}
|
||||
|
||||
fn variant_discriminants<'tcx>(
|
||||
layout: &TyLayout<'tcx>,
|
||||
layout: &TyAndLayout<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> Vec<u128> {
|
||||
|
@ -3,7 +3,7 @@ use rustc::ty::layout::HasParamEnv;
|
||||
use rustc::ty::layout::HasTyCtxt;
|
||||
use rustc::ty::layout::LayoutOf;
|
||||
use rustc::ty::layout::TargetDataLayout;
|
||||
use rustc::ty::layout::TyLayout;
|
||||
use rustc::ty::layout::TyAndLayout;
|
||||
use rustc::ty::ParamEnv;
|
||||
use rustc::ty::Ty;
|
||||
use rustc::ty::TyCtxt;
|
||||
@ -118,9 +118,9 @@ struct UnwrapLayoutCx<'tcx> {
|
||||
|
||||
impl LayoutOf for UnwrapLayoutCx<'tcx> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyLayout = TyLayout<'tcx>;
|
||||
type TyAndLayout = TyAndLayout<'tcx>;
|
||||
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
|
||||
self.tcx.layout_of(self.param_env.and(ty)).unwrap()
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
use crate::abi::call::{ArgAbi, FnAbi, Reg, RegKind, Uniform};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
|
||||
|
||||
fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Option<Uniform>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()).and_then(|unit| {
|
||||
let size = arg.layout.size;
|
||||
@ -26,8 +26,8 @@ where
|
||||
|
||||
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !ret.layout.is_aggregate() {
|
||||
ret.extend_integer_width_to(32);
|
||||
@ -58,8 +58,8 @@ where
|
||||
|
||||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !arg.layout.is_aggregate() {
|
||||
arg.extend_integer_width_to(32);
|
||||
@ -90,8 +90,8 @@ where
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
classify_ret(cx, &mut fn_abi.ret);
|
||||
|
@ -1,26 +1,26 @@
|
||||
use crate::abi::call::{ArgAbi, FnAbi};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
|
||||
|
||||
fn classify_ret<'a, Ty, C>(_cx: &C, ret: &mut ArgAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
ret.extend_integer_width_to(32);
|
||||
}
|
||||
|
||||
fn classify_arg<'a, Ty, C>(_cx: &C, arg: &mut ArgAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
arg.extend_integer_width_to(32);
|
||||
}
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
classify_ret(cx, &mut fn_abi.ret);
|
||||
|
@ -1,11 +1,11 @@
|
||||
use crate::abi::call::{ArgAbi, Conv, FnAbi, Reg, RegKind, Uniform};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
|
||||
use crate::spec::HasTargetSpec;
|
||||
|
||||
fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Option<Uniform>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()).and_then(|unit| {
|
||||
let size = arg.layout.size;
|
||||
@ -27,8 +27,8 @@ where
|
||||
|
||||
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, vfp: bool)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !ret.layout.is_aggregate() {
|
||||
ret.extend_integer_width_to(32);
|
||||
@ -60,8 +60,8 @@ where
|
||||
|
||||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, vfp: bool)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !arg.layout.is_aggregate() {
|
||||
arg.extend_integer_width_to(32);
|
||||
@ -82,8 +82,8 @@ where
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||
{
|
||||
// If this is a target with a hard-float ABI, and the function is not explicitly
|
||||
// `extern "aapcs"`, then we must use the VFP registers for homogeneous aggregates.
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, Size, TyAndLayoutMethods};
|
||||
|
||||
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty> + HasDataLayout,
|
||||
{
|
||||
if !ret.layout.is_aggregate() {
|
||||
@ -16,7 +16,7 @@ where
|
||||
|
||||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'_, Ty>, offset: &mut Size)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty> + HasDataLayout,
|
||||
{
|
||||
let dl = cx.data_layout();
|
||||
@ -37,7 +37,7 @@ where
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'_, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty> + HasDataLayout,
|
||||
{
|
||||
let mut offset = Size::ZERO;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::abi::call::{ArgAbi, ArgAttribute, CastTarget, FnAbi, PassMode, Reg, RegKind, Uniform};
|
||||
use crate::abi::{self, HasDataLayout, LayoutOf, Size, TyLayout, TyLayoutMethods};
|
||||
use crate::abi::{self, HasDataLayout, LayoutOf, Size, TyAndLayout, TyAndLayoutMethods};
|
||||
|
||||
fn extend_integer_width_mips<Ty>(arg: &mut ArgAbi<'_, Ty>, bits: u64) {
|
||||
// Always sign extend u32 values on 64-bit mips
|
||||
@ -19,8 +19,8 @@ fn extend_integer_width_mips<Ty>(arg: &mut ArgAbi<'_, Ty>, bits: u64) {
|
||||
|
||||
fn float_reg<'a, Ty, C>(cx: &C, ret: &ArgAbi<'a, Ty>, i: usize) -> Option<Reg>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
match ret.layout.field(cx, i).abi {
|
||||
abi::Abi::Scalar(ref scalar) => match scalar.value {
|
||||
@ -34,8 +34,8 @@ where
|
||||
|
||||
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !ret.layout.is_aggregate() {
|
||||
extend_integer_width_mips(ret, 64);
|
||||
@ -74,8 +74,8 @@ where
|
||||
|
||||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !arg.layout.is_aggregate() {
|
||||
extend_integer_width_mips(arg, 64);
|
||||
@ -143,8 +143,8 @@ where
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
classify_ret(cx, &mut fn_abi.ret);
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::abi::{self, Abi, Align, FieldPlacement, Size};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
|
||||
use crate::spec::{self, HasTargetSpec};
|
||||
|
||||
mod aarch64;
|
||||
@ -264,7 +264,7 @@ impl HomogeneousAggregate {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
impl<'a, Ty> TyAndLayout<'a, Ty> {
|
||||
fn is_aggregate(&self) -> bool {
|
||||
match self.abi {
|
||||
Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } => false,
|
||||
@ -284,8 +284,8 @@ impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
/// specific targets.
|
||||
pub fn homogeneous_aggregate<C>(&self, cx: &C) -> Result<HomogeneousAggregate, Heterogeneous>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = Self>,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = Self>,
|
||||
{
|
||||
match self.abi {
|
||||
Abi::Uninhabited => Err(Heterogeneous),
|
||||
@ -404,7 +404,7 @@ impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
/// or return a value from, a function, under some ABI.
|
||||
#[derive(Debug)]
|
||||
pub struct ArgAbi<'a, Ty> {
|
||||
pub layout: TyLayout<'a, Ty>,
|
||||
pub layout: TyAndLayout<'a, Ty>,
|
||||
|
||||
/// Dummy argument, which is emitted before the real argument.
|
||||
pub pad: Option<Reg>,
|
||||
@ -413,7 +413,7 @@ pub struct ArgAbi<'a, Ty> {
|
||||
}
|
||||
|
||||
impl<'a, Ty> ArgAbi<'a, Ty> {
|
||||
pub fn new(layout: TyLayout<'a, Ty>) -> Self {
|
||||
pub fn new(layout: TyAndLayout<'a, Ty>) -> Self {
|
||||
ArgAbi { layout, pad: None, mode: PassMode::Direct(ArgAttributes::new()) }
|
||||
}
|
||||
|
||||
@ -551,8 +551,8 @@ pub struct FnAbi<'a, Ty> {
|
||||
impl<'a, Ty> FnAbi<'a, Ty> {
|
||||
pub fn adjust_for_cabi<C>(&mut self, cx: &C, abi: spec::abi::Abi) -> Result<(), String>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||
{
|
||||
match &cx.target_spec().arch[..] {
|
||||
"x86" => {
|
||||
|
@ -3,7 +3,7 @@
|
||||
// need to be fixed when PowerPC vector support is added.
|
||||
|
||||
use crate::abi::call::{ArgAbi, FnAbi, Reg, RegKind, Uniform};
|
||||
use crate::abi::{Endian, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
|
||||
use crate::abi::{Endian, HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
|
||||
use crate::spec::HasTargetSpec;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
@ -19,8 +19,8 @@ fn is_homogeneous_aggregate<'a, Ty, C>(
|
||||
abi: ABI,
|
||||
) -> Option<Uniform>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()).and_then(|unit| {
|
||||
// ELFv1 only passes one-member aggregates transparently.
|
||||
@ -43,8 +43,8 @@ where
|
||||
|
||||
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, abi: ABI)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !ret.layout.is_aggregate() {
|
||||
ret.extend_integer_width_to(64);
|
||||
@ -86,8 +86,8 @@ where
|
||||
|
||||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, abi: ABI)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !arg.layout.is_aggregate() {
|
||||
arg.extend_integer_width_to(64);
|
||||
@ -116,8 +116,8 @@ where
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||
{
|
||||
let abi = if cx.target_spec().target_env == "musl" {
|
||||
ELFv2
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
use crate::abi::call::{ArgAbi, ArgAttribute, CastTarget, FnAbi, PassMode, Reg, RegKind, Uniform};
|
||||
use crate::abi::{
|
||||
self, Abi, FieldPlacement, HasDataLayout, LayoutOf, Size, TyLayout, TyLayoutMethods,
|
||||
self, Abi, FieldPlacement, HasDataLayout, LayoutOf, Size, TyAndLayout, TyAndLayoutMethods,
|
||||
};
|
||||
use crate::spec::HasTargetSpec;
|
||||
|
||||
@ -36,15 +36,15 @@ fn is_riscv_aggregate<'a, Ty>(arg: &ArgAbi<'a, Ty>) -> bool {
|
||||
|
||||
fn should_use_fp_conv_helper<'a, Ty, C>(
|
||||
cx: &C,
|
||||
arg_layout: &TyLayout<'a, Ty>,
|
||||
arg_layout: &TyAndLayout<'a, Ty>,
|
||||
xlen: u64,
|
||||
flen: u64,
|
||||
field1_kind: &mut RegPassKind,
|
||||
field2_kind: &mut RegPassKind,
|
||||
) -> Result<(), CannotUseFpConv>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>>,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>>,
|
||||
{
|
||||
match arg_layout.abi {
|
||||
Abi::Scalar(ref scalar) => match scalar.value {
|
||||
@ -122,13 +122,13 @@ where
|
||||
|
||||
fn should_use_fp_conv<'a, Ty, C>(
|
||||
cx: &C,
|
||||
arg: &TyLayout<'a, Ty>,
|
||||
arg: &TyAndLayout<'a, Ty>,
|
||||
xlen: u64,
|
||||
flen: u64,
|
||||
) -> Option<FloatConv>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>>,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>>,
|
||||
{
|
||||
let mut field1_kind = RegPassKind::Unknown;
|
||||
let mut field2_kind = RegPassKind::Unknown;
|
||||
@ -146,8 +146,8 @@ where
|
||||
|
||||
fn classify_ret<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, xlen: u64, flen: u64) -> bool
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>>,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>>,
|
||||
{
|
||||
if let Some(conv) = should_use_fp_conv(cx, &arg.layout, xlen, flen) {
|
||||
match conv {
|
||||
@ -209,8 +209,8 @@ fn classify_arg<'a, Ty, C>(
|
||||
avail_gprs: &mut u64,
|
||||
avail_fprs: &mut u64,
|
||||
) where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>>,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>>,
|
||||
{
|
||||
if !is_vararg {
|
||||
match should_use_fp_conv(cx, &arg.layout, xlen, flen) {
|
||||
@ -322,8 +322,8 @@ fn extend_integer_width<'a, Ty>(arg: &mut ArgAbi<'a, Ty>, xlen: u64) {
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||
{
|
||||
let flen = match &cx.target_spec().options.llvm_abiname[..] {
|
||||
"ilp32f" | "lp64f" => 32,
|
||||
|
@ -2,11 +2,11 @@
|
||||
// for a pre-z13 machine or using -mno-vx.
|
||||
|
||||
use crate::abi::call::{ArgAbi, FnAbi, Reg};
|
||||
use crate::abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
|
||||
use crate::abi::{self, HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
|
||||
|
||||
fn classify_ret<'a, Ty, C>(ret: &mut ArgAbi<'_, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty> + HasDataLayout,
|
||||
{
|
||||
if !ret.layout.is_aggregate() && ret.layout.size.bits() <= 64 {
|
||||
@ -16,10 +16,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn is_single_fp_element<'a, Ty, C>(cx: &C, layout: TyLayout<'a, Ty>) -> bool
|
||||
fn is_single_fp_element<'a, Ty, C>(cx: &C, layout: TyAndLayout<'a, Ty>) -> bool
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
match layout.abi {
|
||||
abi::Abi::Scalar(ref scalar) => scalar.value.is_float(),
|
||||
@ -36,8 +36,8 @@ where
|
||||
|
||||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !arg.layout.is_aggregate() && arg.layout.size.bits() <= 64 {
|
||||
arg.extend_integer_width_to(64);
|
||||
@ -63,8 +63,8 @@ where
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
classify_ret(&mut fn_abi.ret);
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, Size, TyAndLayoutMethods};
|
||||
|
||||
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty> + HasDataLayout,
|
||||
{
|
||||
if !ret.layout.is_aggregate() {
|
||||
@ -16,7 +16,7 @@ where
|
||||
|
||||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'_, Ty>, offset: &mut Size)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty> + HasDataLayout,
|
||||
{
|
||||
let dl = cx.data_layout();
|
||||
@ -37,7 +37,7 @@ where
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'_, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty> + HasDataLayout,
|
||||
{
|
||||
let mut offset = Size::ZERO;
|
||||
|
@ -1,12 +1,12 @@
|
||||
// FIXME: This needs an audit for correctness and completeness.
|
||||
|
||||
use crate::abi::call::{ArgAbi, FnAbi, Reg, RegKind, Uniform};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
|
||||
|
||||
fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Option<Uniform>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()).and_then(|unit| {
|
||||
// Ensure we have at most eight uniquely addressable members.
|
||||
@ -26,8 +26,8 @@ where
|
||||
|
||||
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !ret.layout.is_aggregate() {
|
||||
ret.extend_integer_width_to(64);
|
||||
@ -52,8 +52,8 @@ where
|
||||
|
||||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !arg.layout.is_aggregate() {
|
||||
arg.extend_integer_width_to(64);
|
||||
@ -76,8 +76,8 @@ where
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
classify_ret(cx, &mut fn_abi.ret);
|
||||
|
@ -1,10 +1,10 @@
|
||||
use crate::abi::call::{ArgAbi, FnAbi, Uniform};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
|
||||
use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
|
||||
|
||||
fn unwrap_trivial_aggregate<'a, Ty, C>(cx: &C, val: &mut ArgAbi<'a, Ty>) -> bool
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if val.layout.is_aggregate() {
|
||||
if let Some(unit) = val.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()) {
|
||||
@ -20,8 +20,8 @@ where
|
||||
|
||||
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
ret.extend_integer_width_to(32);
|
||||
if ret.layout.is_aggregate() {
|
||||
@ -33,8 +33,8 @@ where
|
||||
|
||||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
arg.extend_integer_width_to(32);
|
||||
if arg.layout.is_aggregate() {
|
||||
@ -46,8 +46,8 @@ where
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
classify_ret(cx, &mut fn_abi.ret);
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::abi::call::{ArgAttribute, FnAbi, PassMode, Reg, RegKind};
|
||||
use crate::abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
|
||||
use crate::abi::{self, HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
|
||||
use crate::spec::HasTargetSpec;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
@ -8,10 +8,10 @@ pub enum Flavor {
|
||||
Fastcall,
|
||||
}
|
||||
|
||||
fn is_single_fp_element<'a, Ty, C>(cx: &C, layout: TyLayout<'a, Ty>) -> bool
|
||||
fn is_single_fp_element<'a, Ty, C>(cx: &C, layout: TyAndLayout<'a, Ty>) -> bool
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
match layout.abi {
|
||||
abi::Abi::Scalar(ref scalar) => scalar.value.is_float(),
|
||||
@ -28,8 +28,8 @@ where
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>, flavor: Flavor)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||
{
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
if fn_abi.ret.layout.is_aggregate() {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// https://github.com/jckarter/clay/blob/master/compiler/src/externals.cpp
|
||||
|
||||
use crate::abi::call::{ArgAbi, CastTarget, FnAbi, Reg, RegKind};
|
||||
use crate::abi::{self, Abi, HasDataLayout, LayoutOf, Size, TyLayout, TyLayoutMethods};
|
||||
use crate::abi::{self, Abi, HasDataLayout, LayoutOf, Size, TyAndLayout, TyAndLayoutMethods};
|
||||
|
||||
/// Classification of "eightbyte" components.
|
||||
// N.B., the order of the variants is from general to specific,
|
||||
@ -26,18 +26,18 @@ fn classify_arg<'a, Ty, C>(
|
||||
arg: &ArgAbi<'a, Ty>,
|
||||
) -> Result<[Option<Class>; MAX_EIGHTBYTES], Memory>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
fn classify<'a, Ty, C>(
|
||||
cx: &C,
|
||||
layout: TyLayout<'a, Ty>,
|
||||
layout: TyAndLayout<'a, Ty>,
|
||||
cls: &mut [Option<Class>],
|
||||
off: Size,
|
||||
) -> Result<(), Memory>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
if !off.is_aligned(layout.align.abi) {
|
||||
if !layout.is_zst() {
|
||||
@ -172,8 +172,8 @@ const MAX_SSE_REGS: usize = 8; // XMM0-7
|
||||
|
||||
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
||||
{
|
||||
let mut int_regs = MAX_INT_REGS;
|
||||
let mut sse_regs = MAX_SSE_REGS;
|
||||
|
@ -939,14 +939,13 @@ impl Layout {
|
||||
/// to that obtained from `layout_of(ty)`, as we need to produce
|
||||
/// layouts for which Rust types do not exist, such as enum variants
|
||||
/// or synthetic fields of enums (i.e., discriminants) and fat pointers.
|
||||
// FIXME: rename to TyAndLayout.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct TyLayout<'a, Ty> {
|
||||
pub struct TyAndLayout<'a, Ty> {
|
||||
pub ty: Ty,
|
||||
pub layout: &'a Layout,
|
||||
}
|
||||
|
||||
impl<'a, Ty> Deref for TyLayout<'a, Ty> {
|
||||
impl<'a, Ty> Deref for TyAndLayout<'a, Ty> {
|
||||
type Target = &'a Layout;
|
||||
fn deref(&self) -> &&'a Layout {
|
||||
&self.layout
|
||||
@ -956,15 +955,15 @@ impl<'a, Ty> Deref for TyLayout<'a, Ty> {
|
||||
/// Trait for context types that can compute layouts of things.
|
||||
pub trait LayoutOf {
|
||||
type Ty;
|
||||
type TyLayout;
|
||||
type TyAndLayout;
|
||||
|
||||
fn layout_of(&self, ty: Self::Ty) -> Self::TyLayout;
|
||||
fn spanned_layout_of(&self, ty: Self::Ty, _span: Span) -> Self::TyLayout {
|
||||
fn layout_of(&self, ty: Self::Ty) -> Self::TyAndLayout;
|
||||
fn spanned_layout_of(&self, ty: Self::Ty, _span: Span) -> Self::TyAndLayout {
|
||||
self.layout_of(ty)
|
||||
}
|
||||
}
|
||||
|
||||
/// The `TyLayout` above will always be a `MaybeResult<TyLayout<'_, Self>>`.
|
||||
/// The `TyAndLayout` above will always be a `MaybeResult<TyAndLayout<'_, Self>>`.
|
||||
/// We can't add the bound due to the lifetime, but this trait is still useful when
|
||||
/// writing code that's generic over the `LayoutOf` impl.
|
||||
pub trait MaybeResult<T> {
|
||||
@ -1018,30 +1017,30 @@ pub struct PointeeInfo {
|
||||
pub safe: Option<PointerKind>,
|
||||
}
|
||||
|
||||
pub trait TyLayoutMethods<'a, C: LayoutOf<Ty = Self>>: Sized {
|
||||
pub trait TyAndLayoutMethods<'a, C: LayoutOf<Ty = Self>>: Sized {
|
||||
fn for_variant(
|
||||
this: TyLayout<'a, Self>,
|
||||
this: TyAndLayout<'a, Self>,
|
||||
cx: &C,
|
||||
variant_index: VariantIdx,
|
||||
) -> TyLayout<'a, Self>;
|
||||
fn field(this: TyLayout<'a, Self>, cx: &C, i: usize) -> C::TyLayout;
|
||||
fn pointee_info_at(this: TyLayout<'a, Self>, cx: &C, offset: Size) -> Option<PointeeInfo>;
|
||||
) -> TyAndLayout<'a, Self>;
|
||||
fn field(this: TyAndLayout<'a, Self>, cx: &C, i: usize) -> C::TyAndLayout;
|
||||
fn pointee_info_at(this: TyAndLayout<'a, Self>, cx: &C, offset: Size) -> Option<PointeeInfo>;
|
||||
}
|
||||
|
||||
impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
impl<'a, Ty> TyAndLayout<'a, Ty> {
|
||||
pub fn for_variant<C>(self, cx: &C, variant_index: VariantIdx) -> Self
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty>,
|
||||
{
|
||||
Ty::for_variant(self, cx, variant_index)
|
||||
}
|
||||
|
||||
/// Callers might want to use `C: LayoutOf<Ty=Ty, TyLayout: MaybeResult<Self>>`
|
||||
/// Callers might want to use `C: LayoutOf<Ty=Ty, TyAndLayout: MaybeResult<Self>>`
|
||||
/// to allow recursion (see `might_permit_zero_init` below for an example).
|
||||
pub fn field<C>(self, cx: &C, i: usize) -> C::TyLayout
|
||||
pub fn field<C>(self, cx: &C, i: usize) -> C::TyAndLayout
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty>,
|
||||
{
|
||||
Ty::field(self, cx, i)
|
||||
@ -1049,14 +1048,14 @@ impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
|
||||
pub fn pointee_info_at<C>(self, cx: &C, offset: Size) -> Option<PointeeInfo>
|
||||
where
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty>,
|
||||
{
|
||||
Ty::pointee_info_at(self, cx, offset)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
impl<'a, Ty> TyAndLayout<'a, Ty> {
|
||||
/// Returns `true` if the layout corresponds to an unsized type.
|
||||
pub fn is_unsized(&self) -> bool {
|
||||
self.abi.is_unsized()
|
||||
@ -1083,8 +1082,8 @@ impl<'a, Ty> TyLayout<'a, Ty> {
|
||||
pub fn might_permit_raw_init<C, E>(self, cx: &C, zero: bool) -> Result<bool, E>
|
||||
where
|
||||
Self: Copy,
|
||||
Ty: TyLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty, TyLayout: MaybeResult<Self, Error = E>> + HasDataLayout,
|
||||
Ty: TyAndLayoutMethods<'a, C>,
|
||||
C: LayoutOf<Ty = Ty, TyAndLayout: MaybeResult<Self, Error = E>> + HasDataLayout,
|
||||
{
|
||||
let scalar_allows_raw_init = move |s: &Scalar| -> bool {
|
||||
if zero {
|
||||
|
@ -2440,6 +2440,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
continue;
|
||||
}
|
||||
err_for_ct = true;
|
||||
has_err = true;
|
||||
(ct.span, "const")
|
||||
}
|
||||
};
|
||||
|
22
src/test/ui/const-generics/issues/issue-62220.rs
Normal file
22
src/test/ui/const-generics/issues/issue-62220.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// build-pass
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
#![feature(const_generics)]
|
||||
pub struct Vector<T, const N: usize>([T; N]);
|
||||
|
||||
pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
|
||||
|
||||
impl<T, const N: usize> Vector<T, { N }> {
|
||||
/// Drop the last component and return the vector with one fewer dimension.
|
||||
pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
fn vec4<T>(a: T, b: T, c: T, d: T) -> Vector<T, 4> {
|
||||
Vector([a, b, c, d])
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (_xyz, _w): (TruncatedVector<u32, 4>, u32) = vec4(0u32, 1, 2, 3).trunc();
|
||||
}
|
@ -26,7 +26,7 @@ LL | #[inline = ""]
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
|
||||
error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]`
|
||||
error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...")]`
|
||||
--> $DIR/malformed-regressions.rs:7:1
|
||||
|
|
||||
LL | #[link]
|
||||
@ -35,7 +35,7 @@ LL | #[link]
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
|
||||
error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]`
|
||||
error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...")]`
|
||||
--> $DIR/malformed-regressions.rs:9:1
|
||||
|
|
||||
LL | #[link = ""]
|
||||
|
Loading…
Reference in New Issue
Block a user