about summary refs log tree commit diff
path: root/tests/ui/feature-gates/feature-gate-never_patterns.rs
blob: ca5ce3b9489436a095b998c6826c0268881b6c01 (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
25
26
27
// Check that never patterns require the feature gate.
use std::ptr::NonNull;

enum Void {}

fn main() {
    let res: Result<u32, Void> = Ok(0);
    let (Ok(_x) | Err(&!)) = res.as_ref();
    //~^ ERROR `!` patterns are experimental
    //~| ERROR: is not bound in all patterns

    unsafe {
        let ptr: *const Void = NonNull::dangling().as_ptr();
        match *ptr {
            ! //~ ERROR `!` patterns are experimental
        }
    }

    // Check that the gate operates even behind `cfg`.
    #[cfg(FALSE)]
    unsafe {
        let ptr: *const Void = NonNull::dangling().as_ptr();
        match *ptr {
            ! => {} //~ ERROR `!` patterns are experimental
        }
    }
}