summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/uninhabited_references.rs
blob: cd07b590a616a282fdbad87635d4c3344ff754af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#![warn(clippy::uninhabited_references)]
#![feature(never_type)]

fn ret_uninh_ref() -> &'static std::convert::Infallible {
    unsafe { std::mem::transmute(&()) }
}

macro_rules! ret_something {
    ($name:ident, $ty:ty) => {
        fn $name(x: &$ty) -> &$ty {
            &*x
        }
    };
}

ret_something!(id_u32, u32);
ret_something!(id_never, !);

fn main() {
    let x = ret_uninh_ref();
    let _ = *x;
}