Skip to content

Commit 699eea1

Browse files
committed
Only emit noundef for arrays, not unions or other types
1 parent 9367477 commit 699eea1

File tree

1 file changed

+11
-7
lines changed
  • compiler/rustc_ty_utils/src

1 file changed

+11
-7
lines changed

compiler/rustc_ty_utils/src/abi.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -785,13 +785,17 @@ fn fn_abi_adjust_for_abi<'tcx>(
785785
// so we pick an appropriately sized integer type instead.
786786
arg.cast_to(Reg { kind: RegKind::Integer, size });
787787

788-
// Fixup arg attribute with `noundef`.
789-
let PassMode::Cast { ref mut cast, .. } = &mut arg.mode else {
790-
bug!("this cannot fail because of the previous cast_to `Reg`");
791-
};
792-
793-
let box CastTarget { ref mut attrs, .. } = cast;
794-
attrs.set(ArgAttribute::NoUndef);
788+
// Let's see if we can add a `noundef`. This is only legal for arrays, definitely
789+
// not for unions.
790+
if arg.layout.ty.is_array() {
791+
// Fixup arg attribute with `noundef`.
792+
let PassMode::Cast { ref mut cast, .. } = &mut arg.mode else {
793+
bug!("this cannot fail because of the previous cast_to `Reg`");
794+
};
795+
796+
let box CastTarget { ref mut attrs, .. } = cast;
797+
attrs.set(ArgAttribute::NoUndef);
798+
}
795799
}
796800

797801
// If we deduced that this parameter was read-only, add that to the attribute list now.

0 commit comments

Comments
 (0)