Concerns were raised about Box's Unique / noalias requirements. Miri looks like it should be able to catch such bugs, but I haven't been able to convince my copy to catch any bugs in this test.
Testing
rustup toolchain install nightly -c miri
set RUSTFLAGS=--cfg xxx_borrowable_box
cargo +nightly miri test --all-features
set MIRIFLAGS=-Zmiri-unique-is-unique -Zmiri-tree-borrows
cargo +nightly miri test --all-features
References
|
#[cfg(xxx_borrowable_box)] |
|
#[cfg(feature = "alloc")] #[test] fn try_to_break_box_valrows() { |
|
let a = alloc::boxed::Box::new(core::cell::Cell::new(42)); |
|
let b = crate::Valrow::new(&a); |
|
let c = &a; |
|
a.set(1); |
|
b.set(2); // possibly a problem? |
|
c.set(3); |
|
a.set(4); |
|
b.set(5); // possibly a problem? |
|
c.set(6); |
|
let fmt = alloc::format!("{:?}", (&a, b, c)); |
|
#[cfg(feature = "std")] std::println!("{fmt}"); |
|
|
|
// Maybe the temp-Deref s aren't a problem, but would having a persistent pair of different-address `&Box<Cell<_>>`s trigger miri? |
|
let b : &alloc::boxed::Box<_> = &*b; |
|
a.set( 7); |
|
b.set( 8); // possibly a problem? |
|
c.set( 9); |
|
a.set(10); |
|
b.set(11); // possibly a problem? |
|
c.set(12); |
|
let fmt = alloc::format!("{:?}", (&a, b, c)); |
|
#[cfg(feature = "std")] std::println!("{fmt}"); |
|
} |
Concerns were raised about Box's Unique / noalias requirements. Miri looks like it should be able to catch such bugs, but I haven't been able to convince my copy to catch any bugs in this test.
Testing
References
valrow/src/borrowable.rs
Lines 143 to 167 in b38c862