]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rustc-args-required-const.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / rustc-args-required-const.rs
1 #![feature(rustc_attrs, const_fn)]
2
3 #[rustc_args_required_const(0)]
4 fn foo(_a: i32) {
5 }
6
7 #[rustc_args_required_const(1)]
8 fn bar(_a: i32, _b: i32) {
9 }
10
11 const A: i32 = 3;
12
13 const fn baz() -> i32 {
14     3
15 }
16
17 fn main() {
18     foo(2);
19     foo(2 + 3);
20     const BAZ: i32 = baz();
21     foo(BAZ);
22     let a = 4;
23     foo(A);
24     foo(a); //~ ERROR: argument 1 is required to be a constant
25     bar(a, 3);
26     bar(a, a); //~ ERROR: argument 2 is required to be a constant
27 }