summary refs log tree commit diff
path: root/src/test/ui/consts/control-flow/assert.rs
blob: 2da42d5084bc1737473c533fb5e2057cb56a2c2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Test that `assert` works only when both `const_if_match` and `const_panic` are enabled.

// revisions: stock if_match panic both

#![cfg_attr(any(both, if_match), feature(const_if_match))]
#![cfg_attr(any(both, panic), feature(const_panic))]

const _: () = assert!(true);
//[stock,panic]~^ ERROR `if` is not allowed in a `const`
//[if_match]~^^ ERROR panicking in constants is unstable

const _: () = assert!(false);
//[stock,panic]~^ ERROR `if` is not allowed in a `const`
//[if_match]~^^ ERROR panicking in constants is unstable
//[both]~^^^ ERROR any use of this value will cause an error

fn main() {}