diff --git a/priroda/tests/ui/locals_pointer_rendering.stdout b/priroda/tests/ui/locals_pointer_rendering.stdout index b3d61198e8..a2aeab2cea 100644 --- a/priroda/tests/ui/locals_pointer_rendering.stdout +++ b/priroda/tests/ui/locals_pointer_rendering.stdout @@ -5,52 +5,47 @@ Name: target, Id: _1, Ty: [u8; 2], Value: [[0a], [14]] Name: pointer_at_offset0, Id: _2, Ty: PointerAtOffset0<'_>, Value: PointerAtOffset0 { ptr: [{ALLOC_PTR}] } Name: , Id: _3, Ty: &u8, Value: -Name: , Id: _4, Ty: &u8, Value: -Name: , Id: _5, Ty: usize, Value: -Name: , Id: _6, Ty: bool, Value: true -Name: pointer_after_bytes, Id: _7, Ty: PointerAfterBytes<'_>, Value: PointerAfterBytes { bytes: [[01], [02], [03]], ptr: [{ALLOC_PTR}] } -Name: , Id: _8, Ty: [u8; 3], Value: -Name: , Id: _9, Ty: &u8, Value: -Name: , Id: _10, Ty: &u8, Value: -Name: , Id: _11, Ty: usize, Value: -Name: , Id: _12, Ty: bool, Value: true -Name: pointer_at_end, Id: _13, Ty: PointerAtEnd<'_>, Value: PointerAtEnd { byte: [04], ptr: [{ALLOC_PTR}] } -Name: , Id: _14, Ty: &u8, Value: -Name: , Id: _15, Ty: &u8, Value: -Name: , Id: _16, Ty: usize, Value: -Name: , Id: _17, Ty: bool, Value: true -Name: uninit_around_pointer, Id: _18, Ty: UninitAroundPointer<'_>, Value: UninitAroundPointer { before: [__ __], ptr: [{ALLOC_PTR}], after: [__ __] } -Name: , Id: _19, Ty: std::mem::MaybeUninit<[u8; 2]>, Value: -Name: , Id: _20, Ty: &u8, Value: -Name: , Id: _21, Ty: &u8, Value: -Name: , Id: _22, Ty: usize, Value: -Name: , Id: _23, Ty: bool, Value: true -Name: , Id: _24, Ty: std::mem::MaybeUninit<[u8; 2]>, Value: -Name: integer_and_pointer, Id: _25, Ty: IntegerAndPointer<'_>, Value: IntegerAndPointer { integer: [11 22 33 44], ptr: [{ALLOC_PTR}] } -Name: , Id: _26, Ty: &u8, Value: -Name: , Id: _27, Ty: &u8, Value: -Name: , Id: _28, Ty: usize, Value: -Name: , Id: _29, Ty: bool, Value: true -Name: fixed_addr_ptr, Id: _30, Ty: *const u8, Value: [0x1234[wildcard]] -Name: short_pointer_bytes, Id: _31, Ty: [u8; 1], Value: [[34]] -Name: bytes, Id: _32, Ty: std::mem::MaybeUninit<[u8; 1]>, Value: -Name: , Id: _33, Ty: (), Value: -Name: , Id: _34, Ty: *const u8, Value: -Name: , Id: _35, Ty: *const *const u8, Value: -Name: , Id: _36, Ty: &*const u8, Value: -Name: , Id: _37, Ty: *mut u8, Value: -Name: , Id: _38, Ty: *mut [u8; 1], Value: -Name: , Id: _39, Ty: &mut std::mem::MaybeUninit<[u8; 1]>, Value: -Name: , Id: _40, Ty: usize, Value: -Name: , Id: _41, Ty: std::mem::MaybeUninit<[u8; 1]>, Value: -Name: , Id: _42, Ty: (&PointerAtOffset0<'_>, &PointerAfterBytes<'_>, &PointerAtEnd<'_>, &UninitAroundPointer<'_>, &IntegerAndPointer<'_>, &*const u8, &[u8; 1]), Value: -Name: , Id: _43, Ty: (&PointerAtOffset0<'_>, &PointerAfterBytes<'_>, &PointerAtEnd<'_>, &UninitAroundPointer<'_>, &IntegerAndPointer<'_>, &*const u8, &[u8; 1]), Value: -Name: , Id: _44, Ty: &PointerAtOffset0<'_>, Value: -Name: , Id: _45, Ty: &PointerAfterBytes<'_>, Value: -Name: , Id: _46, Ty: &PointerAtEnd<'_>, Value: -Name: , Id: _47, Ty: &UninitAroundPointer<'_>, Value: -Name: , Id: _48, Ty: &IntegerAndPointer<'_>, Value: -Name: , Id: _49, Ty: &*const u8, Value: -Name: , Id: _50, Ty: &[u8; 1], Value: +Name: , Id: _4, Ty: usize, Value: +Name: , Id: _5, Ty: bool, Value: true +Name: pointer_after_bytes, Id: _6, Ty: PointerAfterBytes<'_>, Value: PointerAfterBytes { bytes: [[01], [02], [03]], ptr: [{ALLOC_PTR}] } +Name: , Id: _7, Ty: [u8; 3], Value: +Name: , Id: _8, Ty: &u8, Value: +Name: , Id: _9, Ty: usize, Value: +Name: , Id: _10, Ty: bool, Value: true +Name: pointer_at_end, Id: _11, Ty: PointerAtEnd<'_>, Value: PointerAtEnd { byte: [04], ptr: [{ALLOC_PTR}] } +Name: , Id: _12, Ty: &u8, Value: +Name: , Id: _13, Ty: usize, Value: +Name: , Id: _14, Ty: bool, Value: true +Name: uninit_around_pointer, Id: _15, Ty: UninitAroundPointer<'_>, Value: UninitAroundPointer { before: [__ __], ptr: [{ALLOC_PTR}], after: [__ __] } +Name: , Id: _16, Ty: std::mem::MaybeUninit<[u8; 2]>, Value: +Name: , Id: _17, Ty: &u8, Value: +Name: , Id: _18, Ty: usize, Value: +Name: , Id: _19, Ty: bool, Value: true +Name: , Id: _20, Ty: std::mem::MaybeUninit<[u8; 2]>, Value: +Name: integer_and_pointer, Id: _21, Ty: IntegerAndPointer<'_>, Value: IntegerAndPointer { integer: [11 22 33 44], ptr: [{ALLOC_PTR}] } +Name: , Id: _22, Ty: &u8, Value: +Name: , Id: _23, Ty: usize, Value: +Name: , Id: _24, Ty: bool, Value: true +Name: fixed_addr_ptr, Id: _25, Ty: *const u8, Value: [0x1234[wildcard]] +Name: short_pointer_bytes, Id: _26, Ty: [u8; 1], Value: [[34]] +Name: bytes, Id: _27, Ty: std::mem::MaybeUninit<[u8; 1]>, Value: +Name: , Id: _28, Ty: (), Value: +Name: , Id: _29, Ty: *const u8, Value: +Name: , Id: _30, Ty: *const *const u8, Value: +Name: , Id: _31, Ty: &*const u8, Value: +Name: , Id: _32, Ty: *mut u8, Value: +Name: , Id: _33, Ty: *mut [u8; 1], Value: +Name: , Id: _34, Ty: &mut std::mem::MaybeUninit<[u8; 1]>, Value: +Name: , Id: _35, Ty: usize, Value: +Name: , Id: _36, Ty: std::mem::MaybeUninit<[u8; 1]>, Value: +Name: , Id: _37, Ty: (&PointerAtOffset0<'_>, &PointerAfterBytes<'_>, &PointerAtEnd<'_>, &UninitAroundPointer<'_>, &IntegerAndPointer<'_>, &*const u8, &[u8; 1]), Value: +Name: , Id: _38, Ty: (&PointerAtOffset0<'_>, &PointerAfterBytes<'_>, &PointerAtEnd<'_>, &UninitAroundPointer<'_>, &IntegerAndPointer<'_>, &*const u8, &[u8; 1]), Value: +Name: , Id: _39, Ty: &PointerAtOffset0<'_>, Value: +Name: , Id: _40, Ty: &PointerAfterBytes<'_>, Value: +Name: , Id: _41, Ty: &PointerAtEnd<'_>, Value: +Name: , Id: _42, Ty: &UninitAroundPointer<'_>, Value: +Name: , Id: _43, Ty: &IntegerAndPointer<'_>, Value: +Name: , Id: _44, Ty: &*const u8, Value: +Name: , Id: _45, Ty: &[u8; 1], Value: (priroda) Id: _2, Ty: PointerAtOffset0<'_>, Value: PointerAtOffset0 { ptr: [{ALLOC_PTR}] } (priroda) quitting diff --git a/rust-version b/rust-version index 467b29b8ef..a96e415ba0 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -ac8310ba643a3796cbe77d2e06944d7c8513999f +9c5648833e5ceb667a708d53c00b83ecc9e610d5 diff --git a/tests/fail/alloc/too_large.rs b/tests/fail/alloc/too_large.rs index 899fc30d9a..b3ab24eb68 100644 --- a/tests/fail/alloc/too_large.rs +++ b/tests/fail/alloc/too_large.rs @@ -1,5 +1,4 @@ #![feature(rustc_attrs)] -#![feature(ptr_alignment_type)] extern "Rust" { #[rustc_std_internal_symbol] @@ -9,6 +8,6 @@ extern "Rust" { fn main() { let bytes = isize::MAX as usize + 1; unsafe { - __rust_alloc(bytes, 1usize.try_into().unwrap()); //~ERROR: larger than half the address space + __rust_alloc(bytes, core::mem::Alignment::MIN); //~ERROR: larger than half the address space } } diff --git a/tests/fail/alloc/too_large.stderr b/tests/fail/alloc/too_large.stderr index 86c8aac242..2af43f2a06 100644 --- a/tests/fail/alloc/too_large.stderr +++ b/tests/fail/alloc/too_large.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: creating an allocation larger than half the address space --> tests/fail/alloc/too_large.rs:LL:CC | -LL | __rust_alloc(bytes, 1usize.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here +LL | __rust_alloc(bytes, core::mem::Alignment::MIN); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/tests/fail/alloc/unsupported_big_alignment.rs b/tests/fail/alloc/unsupported_big_alignment.rs index a60156982c..dd2941bde4 100644 --- a/tests/fail/alloc/unsupported_big_alignment.rs +++ b/tests/fail/alloc/unsupported_big_alignment.rs @@ -3,7 +3,6 @@ // https://github.com/rust-lang/miri/issues/3687 #![feature(rustc_attrs)] -#![feature(ptr_alignment_type)] extern "Rust" { #[rustc_std_internal_symbol] diff --git a/tests/fail/data_race/dealloc_read_race1.rs b/tests/fail/data_race/dealloc_read_race1.rs index 0b16d0616b..d924348e15 100644 --- a/tests/fail/data_race/dealloc_read_race1.rs +++ b/tests/fail/data_race/dealloc_read_race1.rs @@ -2,7 +2,6 @@ //@compile-flags: -Zmiri-deterministic-concurrency -Zmiri-disable-stacked-borrows #![feature(rustc_attrs)] -#![feature(ptr_alignment_type)] use std::thread::spawn; @@ -34,7 +33,7 @@ fn main() { //~^ ERROR: Data race detected between (1) non-atomic read on thread `unnamed-1` and (2) deallocation on thread `unnamed-2` ptr.0 as *mut _, std::mem::size_of::(), - std::mem::align_of::().try_into().unwrap(), + std::mem::Alignment::of::(), ); }); diff --git a/tests/fail/data_race/dealloc_read_race1.stderr b/tests/fail/data_race/dealloc_read_race1.stderr index a9353baa1b..41cba16a48 100644 --- a/tests/fail/data_race/dealloc_read_race1.stderr +++ b/tests/fail/data_race/dealloc_read_race1.stderr @@ -5,7 +5,7 @@ LL | / ... __rust_dealloc( LL | | ... LL | | ... ptr.0 as *mut _, LL | | ... std::mem::size_of::(), -LL | | ... std::mem::align_of::().try_into().unwrap(), +LL | | ... std::mem::Alignment::of::(), LL | | ... ); | |_______^ (2) just happened here | diff --git a/tests/fail/data_race/dealloc_read_race2.rs b/tests/fail/data_race/dealloc_read_race2.rs index 566c729c91..c6a5522284 100644 --- a/tests/fail/data_race/dealloc_read_race2.rs +++ b/tests/fail/data_race/dealloc_read_race2.rs @@ -2,7 +2,6 @@ //@compile-flags: -Zmiri-deterministic-concurrency -Zmiri-disable-stacked-borrows #![feature(rustc_attrs)] -#![feature(ptr_alignment_type)] use std::thread::spawn; @@ -28,7 +27,7 @@ fn main() { __rust_dealloc( ptr.0 as *mut _, std::mem::size_of::(), - std::mem::align_of::().try_into().unwrap(), + std::mem::Alignment::of::(), ) }); diff --git a/tests/fail/data_race/dealloc_read_race2.stderr b/tests/fail/data_race/dealloc_read_race2.stderr index 2452a5587d..6525d7ee10 100644 --- a/tests/fail/data_race/dealloc_read_race2.stderr +++ b/tests/fail/data_race/dealloc_read_race2.stderr @@ -17,7 +17,7 @@ help: ALLOC was deallocated here: LL | / __rust_dealloc( LL | | ptr.0 as *mut _, LL | | std::mem::size_of::(), -LL | | std::mem::align_of::().try_into().unwrap(), +LL | | std::mem::Alignment::of::(), LL | | ) | |_____________^ = note: this is on thread `unnamed-ID` diff --git a/tests/fail/data_race/dealloc_write_race1.rs b/tests/fail/data_race/dealloc_write_race1.rs index 7fa769e885..44b557fee3 100644 --- a/tests/fail/data_race/dealloc_write_race1.rs +++ b/tests/fail/data_race/dealloc_write_race1.rs @@ -2,7 +2,6 @@ //@compile-flags: -Zmiri-deterministic-concurrency -Zmiri-disable-stacked-borrows #![feature(rustc_attrs)] -#![feature(ptr_alignment_type)] use std::thread::spawn; @@ -33,7 +32,7 @@ fn main() { //~^ ERROR: Data race detected between (1) non-atomic write on thread `unnamed-1` and (2) deallocation on thread `unnamed-2` ptr.0 as *mut _, std::mem::size_of::(), - std::mem::align_of::().try_into().unwrap(), + std::mem::Alignment::of::(), ); }); diff --git a/tests/fail/data_race/dealloc_write_race1.stderr b/tests/fail/data_race/dealloc_write_race1.stderr index 3dbc3f3851..ff10c48cd8 100644 --- a/tests/fail/data_race/dealloc_write_race1.stderr +++ b/tests/fail/data_race/dealloc_write_race1.stderr @@ -5,7 +5,7 @@ LL | / ... __rust_dealloc( LL | | ... LL | | ... ptr.0 as *mut _, LL | | ... std::mem::size_of::(), -LL | | ... std::mem::align_of::().try_into().unwrap(), +LL | | ... std::mem::Alignment::of::(), LL | | ... ); | |_______^ (2) just happened here | diff --git a/tests/fail/data_race/dealloc_write_race2.rs b/tests/fail/data_race/dealloc_write_race2.rs index da452b0024..e23d15a794 100644 --- a/tests/fail/data_race/dealloc_write_race2.rs +++ b/tests/fail/data_race/dealloc_write_race2.rs @@ -2,7 +2,6 @@ //@compile-flags: -Zmiri-deterministic-concurrency -Zmiri-disable-stacked-borrows #![feature(rustc_attrs)] -#![feature(ptr_alignment_type)] use std::thread::spawn; @@ -27,7 +26,7 @@ fn main() { __rust_dealloc( ptr.0 as *mut _, std::mem::size_of::(), - std::mem::align_of::().try_into().unwrap(), + std::mem::Alignment::of::(), ); }); diff --git a/tests/fail/data_race/dealloc_write_race2.stderr b/tests/fail/data_race/dealloc_write_race2.stderr index dc0f8a30a0..800dd3ffa7 100644 --- a/tests/fail/data_race/dealloc_write_race2.stderr +++ b/tests/fail/data_race/dealloc_write_race2.stderr @@ -17,7 +17,7 @@ help: ALLOC was deallocated here: LL | / __rust_dealloc( LL | | ptr.0 as *mut _, LL | | std::mem::size_of::(), -LL | | std::mem::align_of::().try_into().unwrap(), +LL | | std::mem::Alignment::of::(), LL | | ); | |_____________^ = note: this is on thread `unnamed-ID` diff --git a/tests/fail/uninit/union-aggregate-init-padding.rs b/tests/fail/uninit/union-aggregate-init-padding.rs new file mode 100644 index 0000000000..2751e978e9 --- /dev/null +++ b/tests/fail/uninit/union-aggregate-init-padding.rs @@ -0,0 +1,34 @@ +//! Ensure that initalizing an aggregate resets padding to uninit. +//! Regression test for . +#![feature(custom_mir, core_intrinsics)] +#![allow(internal_features, unused)] + +use std::intrinsics::mir::*; + +#[derive(Clone, Copy)] +union U { + a: u8, + b: u32, +} + +#[custom_mir(dialect = "runtime", phase = "optimized")] +fn f() -> u32 { + mir! { + let u: U; + let x: u32; + { + x = 0x01020304_u32; + u = U { b: x }; + // This creates a new union value where `a` is initialized and the remaining bytes + // remain uninitialized. That then gets stored into `u`. As a result, this assignment + // should reset the padding bytes of `U::a` in `u` to uninit. + u = U { a: 9_u8 }; + RET = CastTransmute::(u); //~ERROR: uninitialized + Return() + } + } +} + +fn main() { + f(); +} diff --git a/tests/fail/uninit/union-aggregate-init-padding.stderr b/tests/fail/uninit/union-aggregate-init-padding.stderr new file mode 100644 index 0000000000..575bee4c36 --- /dev/null +++ b/tests/fail/uninit/union-aggregate-init-padding.stderr @@ -0,0 +1,18 @@ +error: Undefined Behavior: constructing invalid value of type u32: encountered uninitialized memory, but expected an integer + --> tests/fail/uninit/union-aggregate-init-padding.rs:LL:CC + | +LL | RET = CastTransmute::(u); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: stack backtrace: + 0: f + at tests/fail/uninit/union-aggregate-init-padding.rs:LL:CC + 1: main + at tests/fail/uninit/union-aggregate-init-padding.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + diff --git a/tests/pass/x87_f80.rs b/tests/pass/x87_f80.rs new file mode 100644 index 0000000000..211a480796 --- /dev/null +++ b/tests/pass/x87_f80.rs @@ -0,0 +1,32 @@ +//@only-target: x86_64 i686 +#![feature(x87_f80)] + +#[cfg(target_arch = "x86")] +use std::arch::x86::x87_f80; +#[cfg(target_arch = "x86_64")] +use std::arch::x86_64::x87_f80; + +static STATIC: x87_f80 = x87_f80::from_ne_bytes([0xAA; 10]); +static STATIC_AGGREGATE: (u8, x87_f80, i32) = (3, x87_f80::from_ne_bytes([0xBB; 10]), 4); +static STATIC_ARRAY: [x87_f80; 3] = [ + x87_f80::from_ne_bytes([0x11; 10]), + x87_f80::from_ne_bytes([0x22; 10]), + x87_f80::from_ne_bytes([0x33; 10]), +]; + +fn identity(x: x87_f80) -> x87_f80 { + x +} + +fn main() { + assert_eq!(STATIC.to_ne_bytes(), [0xAA; 10]); + assert_eq!(STATIC_AGGREGATE.1.to_ne_bytes(), [0xBB; 10]); + assert_eq!(STATIC_ARRAY[1].to_ne_bytes(), [0x22; 10]); + + let mut m = std::mem::MaybeUninit::::uninit(); + unsafe { m.as_mut_ptr().cast::<[u8; 10]>().write([0xCC; 10]) }; + let i = unsafe { m.assume_init() }; + assert_eq!(i.to_ne_bytes(), [0xCC; 10]); + + assert_eq!(identity(i).to_ne_bytes(), [0xCC; 10]); +}