Skip to content

Commit c7e6f1c

Browse files
committed
Make rustc_abi compile on stable again
1 parent 7244af6 commit c7e6f1c

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

Diff for: compiler/rustc_abi/src/callconv.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@ mod abi {
33
pub(crate) use crate::Variants;
44
}
55

6+
#[cfg(feature = "nightly")]
67
use rustc_macros::HashStable_Generic;
78

8-
use crate::{Abi, Align, FieldsShape, HasDataLayout, Size, TyAbiInterface, TyAndLayout};
9+
#[cfg(feature = "nightly")]
10+
use crate::{Abi, FieldsShape, TyAbiInterface, TyAndLayout};
11+
use crate::{Align, HasDataLayout, Size};
912

10-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
13+
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
14+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
1115
pub enum RegKind {
1216
Integer,
1317
Float,
1418
Vector,
1519
}
1620

17-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
21+
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
22+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
1823
pub struct Reg {
1924
pub kind: RegKind,
2025
pub size: Size,
@@ -108,15 +113,8 @@ impl HomogeneousAggregate {
108113
}
109114
}
110115

116+
#[cfg(feature = "nightly")]
111117
impl<'a, Ty> TyAndLayout<'a, Ty> {
112-
/// Returns `true` if this is an aggregate type (including a ScalarPair!)
113-
pub fn is_aggregate(&self) -> bool {
114-
match self.abi {
115-
Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } => false,
116-
Abi::ScalarPair(..) | Abi::Aggregate { .. } => true,
117-
}
118-
}
119-
120118
/// Returns `Homogeneous` if this layout is an aggregate containing fields of
121119
/// only a single type (e.g., `(u32, u32)`). Such aggregates are often
122120
/// special-cased in ABIs.

Diff for: compiler/rustc_abi/src/layout.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ use crate::{
1111
Variants, WrappingRange,
1212
};
1313

14+
#[cfg(feature = "nightly")]
1415
mod ty;
1516

17+
#[cfg(feature = "nightly")]
1618
pub use ty::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx};
1719

1820
// A variant is absent if it's uninhabited and only has ZST fields.

Diff for: compiler/rustc_abi/src/lib.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ mod layout;
2929
mod tests;
3030

3131
pub use callconv::{Heterogeneous, HomogeneousAggregate, Reg, RegKind};
32-
pub use layout::{
33-
FIRST_VARIANT, FieldIdx, Layout, LayoutCalculator, LayoutCalculatorError, TyAbiInterface,
34-
TyAndLayout, VariantIdx,
35-
};
32+
#[cfg(feature = "nightly")]
33+
pub use layout::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx};
34+
pub use layout::{LayoutCalculator, LayoutCalculatorError};
3635

3736
/// Requirements for a `StableHashingContext` to be used in this crate.
3837
/// This is a hack to allow using the `HashStable_Generic` derive macro
3938
/// instead of implementing everything in `rustc_middle`.
39+
#[cfg(feature = "nightly")]
4040
pub trait HashStableContext {}
4141

4242
#[derive(Clone, Copy, PartialEq, Eq, Default)]
@@ -1644,6 +1644,14 @@ pub struct LayoutS<FieldIdx: Idx, VariantIdx: Idx> {
16441644
}
16451645

16461646
impl<FieldIdx: Idx, VariantIdx: Idx> LayoutS<FieldIdx, VariantIdx> {
1647+
/// Returns `true` if this is an aggregate type (including a ScalarPair!)
1648+
pub fn is_aggregate(&self) -> bool {
1649+
match self.abi {
1650+
Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } => false,
1651+
Abi::ScalarPair(..) | Abi::Aggregate { .. } => true,
1652+
}
1653+
}
1654+
16471655
pub fn scalar<C: HasDataLayout>(cx: &C, scalar: Scalar) -> Self {
16481656
let largest_niche = Niche::from_scalar(cx, Size::ZERO, scalar);
16491657
let size = scalar.size(cx);

0 commit comments

Comments
 (0)