Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c3eb8f2

Browse files
committed
rustc_layout_scalar_valid_range can be applied to scalar pairs and affects teh first scalar
1 parent 2b8963a commit c3eb8f2

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -785,15 +785,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
785785
}
786786
}
787787
Abi::ScalarPair(a_layout, b_layout) => {
788-
// There is no `rustc_layout_scalar_valid_range_start` for pairs, so
789-
// we would validate these things as we descend into the fields,
790-
// but that can miss bugs in layout computation. Layout computation
791-
// is subtle due to enums having ScalarPair layout, where one field
792-
// is the discriminant.
793-
if cfg!(debug_assertions)
794-
&& !a_layout.is_uninit_valid()
795-
&& !b_layout.is_uninit_valid()
796-
{
788+
if !a_layout.is_uninit_valid() && !b_layout.is_uninit_valid() {
797789
// We can only proceed if *both* scalars need to be initialized.
798790
// FIXME: find a way to also check ScalarPair when one side can be uninit but
799791
// the other must be init.

0 commit comments

Comments
 (0)