mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Make rustc_abi compile on stable again
This commit is contained in:
parent
7244af6ca3
commit
c7e6f1c330
@ -3,18 +3,23 @@ mod abi {
|
|||||||
pub(crate) use crate::Variants;
|
pub(crate) use crate::Variants;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "nightly")]
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
|
|
||||||
use crate::{Abi, Align, FieldsShape, HasDataLayout, Size, TyAbiInterface, TyAndLayout};
|
#[cfg(feature = "nightly")]
|
||||||
|
use crate::{Abi, FieldsShape, TyAbiInterface, TyAndLayout};
|
||||||
|
use crate::{Align, HasDataLayout, Size};
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
|
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
|
||||||
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||||
pub enum RegKind {
|
pub enum RegKind {
|
||||||
Integer,
|
Integer,
|
||||||
Float,
|
Float,
|
||||||
Vector,
|
Vector,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
|
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
|
||||||
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct Reg {
|
pub struct Reg {
|
||||||
pub kind: RegKind,
|
pub kind: RegKind,
|
||||||
pub size: Size,
|
pub size: Size,
|
||||||
@ -108,15 +113,8 @@ impl HomogeneousAggregate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "nightly")]
|
||||||
impl<'a, Ty> TyAndLayout<'a, Ty> {
|
impl<'a, Ty> TyAndLayout<'a, Ty> {
|
||||||
/// Returns `true` if this is an aggregate type (including a ScalarPair!)
|
|
||||||
pub fn is_aggregate(&self) -> bool {
|
|
||||||
match self.abi {
|
|
||||||
Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } => false,
|
|
||||||
Abi::ScalarPair(..) | Abi::Aggregate { .. } => true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns `Homogeneous` if this layout is an aggregate containing fields of
|
/// Returns `Homogeneous` if this layout is an aggregate containing fields of
|
||||||
/// only a single type (e.g., `(u32, u32)`). Such aggregates are often
|
/// only a single type (e.g., `(u32, u32)`). Such aggregates are often
|
||||||
/// special-cased in ABIs.
|
/// special-cased in ABIs.
|
||||||
|
@ -11,8 +11,10 @@ use crate::{
|
|||||||
Variants, WrappingRange,
|
Variants, WrappingRange,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "nightly")]
|
||||||
mod ty;
|
mod ty;
|
||||||
|
|
||||||
|
#[cfg(feature = "nightly")]
|
||||||
pub use ty::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx};
|
pub use ty::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx};
|
||||||
|
|
||||||
// A variant is absent if it's uninhabited and only has ZST fields.
|
// A variant is absent if it's uninhabited and only has ZST fields.
|
||||||
|
@ -29,14 +29,14 @@ mod layout;
|
|||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
pub use callconv::{Heterogeneous, HomogeneousAggregate, Reg, RegKind};
|
pub use callconv::{Heterogeneous, HomogeneousAggregate, Reg, RegKind};
|
||||||
pub use layout::{
|
#[cfg(feature = "nightly")]
|
||||||
FIRST_VARIANT, FieldIdx, Layout, LayoutCalculator, LayoutCalculatorError, TyAbiInterface,
|
pub use layout::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx};
|
||||||
TyAndLayout, VariantIdx,
|
pub use layout::{LayoutCalculator, LayoutCalculatorError};
|
||||||
};
|
|
||||||
|
|
||||||
/// Requirements for a `StableHashingContext` to be used in this crate.
|
/// Requirements for a `StableHashingContext` to be used in this crate.
|
||||||
/// This is a hack to allow using the `HashStable_Generic` derive macro
|
/// This is a hack to allow using the `HashStable_Generic` derive macro
|
||||||
/// instead of implementing everything in `rustc_middle`.
|
/// instead of implementing everything in `rustc_middle`.
|
||||||
|
#[cfg(feature = "nightly")]
|
||||||
pub trait HashStableContext {}
|
pub trait HashStableContext {}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, Default)]
|
||||||
@ -1644,6 +1644,14 @@ pub struct LayoutS<FieldIdx: Idx, VariantIdx: Idx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<FieldIdx: Idx, VariantIdx: Idx> LayoutS<FieldIdx, VariantIdx> {
|
impl<FieldIdx: Idx, VariantIdx: Idx> LayoutS<FieldIdx, VariantIdx> {
|
||||||
|
/// Returns `true` if this is an aggregate type (including a ScalarPair!)
|
||||||
|
pub fn is_aggregate(&self) -> bool {
|
||||||
|
match self.abi {
|
||||||
|
Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } => false,
|
||||||
|
Abi::ScalarPair(..) | Abi::Aggregate { .. } => true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn scalar<C: HasDataLayout>(cx: &C, scalar: Scalar) -> Self {
|
pub fn scalar<C: HasDataLayout>(cx: &C, scalar: Scalar) -> Self {
|
||||||
let largest_niche = Niche::from_scalar(cx, Size::ZERO, scalar);
|
let largest_niche = Niche::from_scalar(cx, Size::ZERO, scalar);
|
||||||
let size = scalar.size(cx);
|
let size = scalar.size(cx);
|
||||||
|
Loading…
Reference in New Issue
Block a user