about summary refs log tree commit diff
path: root/compiler/rustc_abi
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2025-07-29 08:43:10 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-07-29 14:17:48 +0000
commit219bad49461f5c9fc318732a73a05af5d198fed2 (patch)
tree1489e1b4745725606f0de94a19fc13cf6e6989b7 /compiler/rustc_abi
parent75bdbf25e39f073b35eadedcf575affac7762a86 (diff)
downloadrust-219bad49461f5c9fc318732a73a05af5d198fed2.tar.gz
rust-219bad49461f5c9fc318732a73a05af5d198fed2.zip
Reuse `sign_extend` helper
Diffstat (limited to 'compiler/rustc_abi')
-rw-r--r--compiler/rustc_abi/src/layout.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs
index 90c63bc9db3..c2405553756 100644
--- a/compiler/rustc_abi/src/layout.rs
+++ b/compiler/rustc_abi/src/layout.rs
@@ -769,7 +769,6 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
 
         let discr_type = repr.discr_type();
         let discr_int = Integer::from_attr(dl, discr_type);
-        let bits = discr_int.size().bits();
         // Because we can only represent one range of valid values, we'll look for the
         // largest range of invalid values and pick everything else as the range of valid
         // values.
@@ -780,7 +779,8 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
             .map(|(_, val)| {
                 if discr_type.is_signed() {
                     // sign extend the raw representation to be an i128
-                    (val << (128 - bits)) >> (128 - bits)
+                    // FIXME: do this at the discriminant iterator creation sites
+                    discr_int.size().sign_extend(val as u128)
                 } else {
                     val
                 }