rust/tests/ui/precondition-checks/nonzero-from_mut_unchecked.rs
2024-10-09 19:34:27 -04:00

13 lines
324 B
Rust

//@ run-fail
//@ compile-flags: -Copt-level=3 -Cdebug-assertions=no -Zub-checks=yes
//@ error-pattern: unsafe precondition(s) violated: NonZero::from_mut_unchecked requires
#![feature(nonzero_from_mut)]
fn main() {
unsafe {
let mut num = 0u8;
std::num::NonZeroU8::from_mut_unchecked(&mut num);
}
}