1
Fork 0
rust/tests/ui/feature-gates/feature-gate-never_patterns.rs

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

28 lines
691 B
Rust
Raw Normal View History

2023-11-22 02:30:43 +01:00
// 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 {
2023-11-27 04:08:09 +01:00
! //~ ERROR `!` patterns are experimental
2023-11-22 02:30:43 +01:00
}
}
// 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
}
}
}