Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/rustc_abi/src/callconv/reg.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#[cfg(feature = "nightly")]
use rustc_macros::HashStable_Generic;
use rustc_macros::HashStable;

use crate::{Align, HasDataLayout, Size};

#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum RegKind {
Integer,
Float,
Vector,
}

#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub struct Reg {
pub kind: RegKind,
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_abi/src/canon_abi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt;

#[cfg(feature = "nightly")]
use rustc_macros::HashStable_Generic;
use rustc_macros::HashStable;

use crate::ExternAbi;

Expand All @@ -18,7 +18,7 @@ use crate::ExternAbi;
/// rather than picking the "actual" ABI.
#[derive(Copy, Clone, Debug)]
#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub enum CanonAbi {
// NOTE: the use of nested variants for some ABIs is for many targets they don't matter,
// and this pushes the complexity of their reasoning to target-specific code,
Expand Down Expand Up @@ -111,7 +111,7 @@ impl fmt::Display for CanonAbi {
/// These only affect callee codegen. making their categorization as distinct ABIs a bit peculiar.
#[derive(Copy, Clone, Debug)]
#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub enum InterruptKind {
Avr,
AvrNonBlocking,
Expand All @@ -126,7 +126,7 @@ pub enum InterruptKind {
/// One of SysV64 or Win64 may alias the C ABI, and arguably Win64 is cross-platform now?
#[derive(Clone, Copy, Debug)]
#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub enum X86Call {
/// "fastcall" has both GNU and Windows variants
Fastcall,
Expand All @@ -141,7 +141,7 @@ pub enum X86Call {
/// ABIs defined for 32-bit Arm
#[derive(Copy, Clone, Debug)]
#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub enum ArmCall {
Aapcs,
CCmseNonSecureCall,
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_abi/src/extern_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::fmt;
use std::hash::{Hash, Hasher};

#[cfg(feature = "nightly")]
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd};
use rustc_data_structures::stable_hasher::{
HashStable, HashStableContext, StableHasher, StableOrd,
};
#[cfg(feature = "nightly")]
use rustc_macros::{Decodable, Encodable};
#[cfg(feature = "nightly")]
Expand Down Expand Up @@ -217,9 +219,9 @@ impl Hash for ExternAbi {
}

#[cfg(feature = "nightly")]
impl<C> HashStable<C> for ExternAbi {
impl HashStable for ExternAbi {
#[inline]
fn hash_stable(&self, _: &mut C, hasher: &mut StableHasher) {
fn hash_stable<Hcx: HashStableContext>(&self, _: &mut Hcx, hasher: &mut StableHasher) {
Hash::hash(self, hasher);
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ rustc_index::newtype_index! {
/// `b` is `FieldIdx(1)` in `VariantIdx(0)`,
/// `d` is `FieldIdx(1)` in `VariantIdx(1)`, and
/// `f` is `FieldIdx(1)` in `VariantIdx(0)`.
#[stable_hash_generic]
#[stable_hash]
#[encodable]
#[orderable]
#[gate_rustc_only]
Expand All @@ -70,7 +70,7 @@ rustc_index::newtype_index! {
///
/// `struct`s, `tuples`, and `unions`s are considered to have a single variant
/// with variant index zero, aka [`FIRST_VARIANT`].
#[stable_hash_generic]
#[stable_hash]
#[encodable]
#[orderable]
#[gate_rustc_only]
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_abi/src/layout/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt;
use std::ops::Deref;

use rustc_data_structures::intern::Interned;
use rustc_macros::HashStable_Generic;
use rustc_macros::HashStable;

use crate::layout::{FieldIdx, VariantIdx};
use crate::{
Expand All @@ -12,7 +12,7 @@ use crate::{

// Explicitly import `Float` to avoid ambiguity with `Primitive::Float`.

#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable_Generic)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
#[rustc_pass_by_value]
pub struct Layout<'a>(pub Interned<'a, LayoutData<FieldIdx, VariantIdx>>);

Expand Down Expand Up @@ -71,7 +71,7 @@ impl<'a> Layout<'a> {
/// 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 wide pointers.
#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable_Generic)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
pub struct TyAndLayout<'a, Ty> {
pub ty: Ty,
pub layout: Layout<'a>,
Expand Down
63 changes: 21 additions & 42 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use rustc_data_structures::stable_hasher::StableOrd;
use rustc_hashes::Hash64;
use rustc_index::{Idx, IndexSlice, IndexVec};
#[cfg(feature = "nightly")]
use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_Generic};
use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable};

mod callconv;
mod canon_abi;
Expand All @@ -68,10 +68,7 @@ pub use layout::{FIRST_VARIANT, FieldIdx, LayoutCalculator, LayoutCalculatorErro
pub use layout::{Layout, TyAbiInterface, TyAndLayout};

#[derive(Clone, Copy, PartialEq, Eq, Default)]
#[cfg_attr(
feature = "nightly",
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
)]
#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
pub struct ReprFlags(u8);

bitflags! {
Expand Down Expand Up @@ -108,10 +105,7 @@ impl std::fmt::Debug for ReprFlags {
}

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(
feature = "nightly",
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
)]
#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
pub enum IntegerType {
/// Pointer-sized integer type, i.e. `isize` and `usize`. The field shows signedness, e.g.
/// `Pointer(true)` means `isize`.
Expand All @@ -131,10 +125,7 @@ impl IntegerType {
}

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(
feature = "nightly",
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
)]
#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
pub enum ScalableElt {
/// `N` in `rustc_scalable_vector(N)` - the element count of the scalable vector
ElementCount(u16),
Expand All @@ -145,10 +136,7 @@ pub enum ScalableElt {

/// Represents the repr options provided by the user.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
#[cfg_attr(
feature = "nightly",
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
)]
#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
pub struct ReprOptions {
pub int: Option<IntegerType>,
pub align: Option<Align>,
Expand Down Expand Up @@ -745,10 +733,7 @@ impl FromStr for Endian {

/// Size of a type in bytes.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(
feature = "nightly",
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
)]
#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
pub struct Size {
raw: u64,
}
Expand Down Expand Up @@ -973,10 +958,7 @@ impl Step for Size {

/// Alignment of a type in bytes (always a power of two).
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(
feature = "nightly",
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
)]
#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
pub struct Align {
pow2: u8,
}
Expand Down Expand Up @@ -1109,7 +1091,7 @@ impl Align {
/// An example of a rare thing actually affected by preferred alignment is aligning of statics.
/// It is of effectively no consequence for layout in structs and on the stack.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub struct AbiAlign {
pub abi: Align,
}
Expand Down Expand Up @@ -1141,10 +1123,7 @@ impl Deref for AbiAlign {

/// Integers, also used for enum discriminants.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[cfg_attr(
feature = "nightly",
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
)]
#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
pub enum Integer {
I8,
I16,
Expand Down Expand Up @@ -1304,7 +1283,7 @@ impl Integer {

/// Floating-point types.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub enum Float {
F16,
F32,
Expand Down Expand Up @@ -1339,7 +1318,7 @@ impl Float {

/// Fundamental unit of memory access and layout.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub enum Primitive {
/// The `bool` is the signedness of the `Integer` type.
///
Expand Down Expand Up @@ -1387,7 +1366,7 @@ impl Primitive {
///
/// This is intended specifically to mirror LLVM’s `!range` metadata semantics.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub struct WrappingRange {
pub start: u128,
pub end: u128,
Expand Down Expand Up @@ -1499,7 +1478,7 @@ impl fmt::Debug for WrappingRange {

/// Information about one scalar component of a Rust type.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub enum Scalar {
Initialized {
value: Primitive,
Expand Down Expand Up @@ -1603,7 +1582,7 @@ impl Scalar {
// NOTE: This struct is generic over the FieldIdx for rust-analyzer usage.
/// Describes how the fields of a type are located in memory.
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub enum FieldsShape<FieldIdx: Idx> {
/// Scalar primitives and `!`, which never have fields.
Primitive,
Expand Down Expand Up @@ -1688,7 +1667,7 @@ impl<FieldIdx: Idx> FieldsShape<FieldIdx> {
/// should operate on. Special address spaces have an effect on code generation,
/// depending on the target and the address spaces it implements.
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub struct AddressSpace(pub u32);

impl AddressSpace {
Expand All @@ -1698,7 +1677,7 @@ impl AddressSpace {

/// How many scalable vectors are in a `BackendRepr::ScalableVector`?
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub struct NumScalableVectors(pub u8);

impl NumScalableVectors {
Expand Down Expand Up @@ -1729,7 +1708,7 @@ impl NumScalableVectors {
/// Generally, a codegen backend will prefer to handle smaller values as a scalar or short vector,
/// and larger values will usually prefer to be represented as memory.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub enum BackendRepr {
Scalar(Scalar),
ScalarPair(Scalar, Scalar),
Expand Down Expand Up @@ -1873,7 +1852,7 @@ impl BackendRepr {

// NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage.
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub enum Variants<FieldIdx: Idx, VariantIdx: Idx> {
/// A type with no valid variants. Must be uninhabited.
Empty,
Expand All @@ -1900,7 +1879,7 @@ pub enum Variants<FieldIdx: Idx, VariantIdx: Idx> {

// NOTE: This struct is generic over the VariantIdx for rust-analyzer usage.
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub enum TagEncoding<VariantIdx: Idx> {
/// The tag directly stores the discriminant, but possibly with a smaller layout
/// (so converting the tag to the discriminant can require sign extension).
Expand Down Expand Up @@ -1941,7 +1920,7 @@ pub enum TagEncoding<VariantIdx: Idx> {
}

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub struct Niche {
pub offset: Size,
pub value: Primitive,
Expand Down Expand Up @@ -2028,7 +2007,7 @@ impl Niche {

// NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage.
#[derive(PartialEq, Eq, Hash, Clone)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
#[cfg_attr(feature = "nightly", derive(HashStable))]
pub struct LayoutData<FieldIdx: Idx, VariantIdx: Idx> {
/// Says where the fields are located within the layout.
pub fields: FieldsShape<FieldIdx>,
Expand Down
Loading
Loading