From ec13ae6475275d82ec48e2ae32e27eaecdfa19cd Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Wed, 4 Jun 2025 14:02:09 -0700 Subject: [PATCH] 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. --- compiler/rustc_abi/src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 29e36c021edf..4268e68b2e42 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -43,7 +43,7 @@ #[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 @@ pub fn max(self, other: AbiAlign) -> 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(