about summary refs log tree commit diff
path: root/tests/ui/consts/const-unwrap.rs
blob: 38ebd5dd23080f3cf9a919df4e440d331aabc817 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//@ check-fail
// Verify that panicking `const_option` methods do the correct thing

const FOO: i32 = Some(42i32).unwrap();

const BAR: i32 = Option::<i32>::None.unwrap();
//~^ ERROR: called `Option::unwrap()` on a `None` value

const BAZ: i32 = Option::<i32>::None.expect("absolutely not!");
//~^ ERROR: absolutely not!

fn main() {
    println!("{}", FOO);
    println!("{}", BAR);
}