rust/tests/ui/precondition-checks/nonzero-from_mut_unchecked.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

13 lines
324 B
Rust
Raw Permalink Normal View History

2024-10-07 18:34:25 -05:00
//@ 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);
}
}