diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-10-21 18:11:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-21 18:11:21 +0200 |
| commit | d0c8d3eafee318a658d4a529295e2fb74a51100e (patch) | |
| tree | 502eb3ba320ee5d760a7da5f7371ed1eb7ac1f6a | |
| parent | a9da2be010af81990dfcd167e5671d407c843481 (diff) | |
| parent | c7e6f1c330957627b06d53cb3e5ddbe299d0ebe9 (diff) | |
| download | rust-d0c8d3eafee318a658d4a529295e2fb74a51100e.tar.gz rust-d0c8d3eafee318a658d4a529295e2fb74a51100e.zip | |
Rollup merge of #131997 - Veykril:veykril/push-upvqkyxmvkzw, r=jieyouxu
Make `rustc_abi` compile on stable again https://github.com/rust-lang/rust/pull/131473 accidentally broke this
| -rw-r--r-- | compiler/rustc_abi/src/callconv.rs | 20 | ||||
| -rw-r--r-- | compiler/rustc_abi/src/layout.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_abi/src/lib.rs | 16 | ||||
| -rw-r--r-- | tests/run-make/rustc-crates-on-stable/rmake.rs | 4 |
4 files changed, 27 insertions, 15 deletions
diff --git a/compiler/rustc_abi/src/callconv.rs b/compiler/rustc_abi/src/callconv.rs index 2ecac8a9df1..872cae59a4e 100644 --- a/compiler/rustc_abi/src/callconv.rs +++ b/compiler/rustc_abi/src/callconv.rs @@ -3,18 +3,23 @@ mod abi { pub(crate) use crate::Variants; } +#[cfg(feature = "nightly")] 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 { Integer, Float, 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 kind: RegKind, pub size: Size, @@ -108,15 +113,8 @@ impl HomogeneousAggregate { } } +#[cfg(feature = "nightly")] 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 /// only a single type (e.g., `(u32, u32)`). Such aggregates are often /// special-cased in ABIs. diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index 59f42425bb9..0340d1bd6bc 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -11,8 +11,10 @@ use crate::{ Variants, WrappingRange, }; +#[cfg(feature = "nightly")] mod ty; +#[cfg(feature = "nightly")] pub use ty::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx}; // A variant is absent if it's uninhabited and only has ZST fields. diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 84d756b6d51..8e90130da4c 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -29,14 +29,14 @@ mod layout; mod tests; pub use callconv::{Heterogeneous, HomogeneousAggregate, Reg, RegKind}; -pub use layout::{ - FIRST_VARIANT, FieldIdx, Layout, LayoutCalculator, LayoutCalculatorError, TyAbiInterface, - TyAndLayout, VariantIdx, -}; +#[cfg(feature = "nightly")] +pub use layout::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx}; +pub use layout::{LayoutCalculator, LayoutCalculatorError}; /// Requirements for a `StableHashingContext` to be used in this crate. /// This is a hack to allow using the `HashStable_Generic` derive macro /// instead of implementing everything in `rustc_middle`. +#[cfg(feature = "nightly")] pub trait HashStableContext {} #[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> { + /// 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 { let largest_niche = Niche::from_scalar(cx, Size::ZERO, scalar); let size = scalar.size(cx); diff --git a/tests/run-make/rustc-crates-on-stable/rmake.rs b/tests/run-make/rustc-crates-on-stable/rmake.rs index 81cc775c919..9fbc675cc9a 100644 --- a/tests/run-make/rustc-crates-on-stable/rmake.rs +++ b/tests/run-make/rustc-crates-on-stable/rmake.rs @@ -31,6 +31,10 @@ fn main() { "rustc_pattern_analysis", "-p", "rustc_lexer", + "-p", + "rustc_abi", + "-p", + "rustc_parse_format", ]) .run(); } |
