about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/non_zero_suggestions_unfixable.rs
blob: 1224356236c7114877e05a0b373a6bd57c952a73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#![warn(clippy::non_zero_suggestions)]
//@no-rustfix
use std::num::{NonZeroI8, NonZeroI16, NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize};

fn main() {
    let x: u64 = u64::from(NonZeroU32::new(5).unwrap().get());
    //~^ non_zero_suggestions

    let n = NonZeroU32::new(20).unwrap();
    let y = u64::from(n.get());
    //~^ non_zero_suggestions

    some_fn_that_only_takes_u64(y);

    let m = NonZeroU32::try_from(1).unwrap();
    let _z: NonZeroU64 = m.into();
}

fn return_non_zero(x: u64, y: NonZeroU32) -> u64 {
    u64::from(y.get())
    //~^ non_zero_suggestions
}

fn some_fn_that_only_takes_u64(_: u64) {}