compiler: add Deref to AbiAlign to ease transition

We will want to remove many cases of `.abi`, including `.abi.thing`,
so this may simplify future PRs and certainly doesn't hurt.

We omit DerefMut because mutation is much rarer and localized.
This commit is contained in:
Jubilee Young 2025-06-04 14:02:09 -07:00
parent 2e19658315
commit ec13ae6475

View file

@ -43,7 +43,7 @@ use std::fmt;
#[cfg(feature = "nightly")]
use std::iter::Step;
use std::num::{NonZeroUsize, ParseIntError};
use std::ops::{Add, AddAssign, Mul, RangeInclusive, Sub};
use std::ops::{Add, AddAssign, Deref, Mul, RangeInclusive, Sub};
use std::str::FromStr;
use bitflags::bitflags;
@ -884,6 +884,14 @@ impl AbiAlign {
}
}
impl Deref for AbiAlign {
type Target = Align;
fn deref(&self) -> &Self::Target {
&self.abi
}
}
/// Integers, also used for enum discriminants.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[cfg_attr(