about summary refs log tree commit diff
path: root/src/tools/miri/tests/pass/overlapping_assignment_aggregate_scalar.rs
blob: 0cb2f7642424e5791b4de4b5dd584fc2e100be07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#![feature(custom_mir, core_intrinsics)]
#![allow(internal_features)]

use std::intrinsics::mir::*;

#[custom_mir(dialect = "runtime")]
fn main() {
    mir! {
        let _1: (u8,);
        {
            _1.0 = 0_u8;
            // This is a scalar type, so overlap is (for now) not UB.
            // However, we used to treat such overlapping assignments incorrectly
            // (see <https://github.com/rust-lang/rust/issues/146383#issuecomment-3273224645>).
            _1 = (_1.0, );
            Return()
        }
    }
}