about summary refs log tree commit diff
path: root/tests/ui/precondition-checks/nonzero-from_mut_unchecked.rs
blob: d55707fdd0be2fba9106825db9fd85f0a1438069 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
//@ run-crash
//@ 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);
    }
}