2018-08-03 17:05:05 -05:00
|
|
|
#![feature(rustc_attrs, const_fn)]
|
2018-02-05 12:48:22 -06:00
|
|
|
|
|
|
|
#[rustc_args_required_const(0)]
|
|
|
|
fn foo(_a: i32) {
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rustc_args_required_const(1)]
|
|
|
|
fn bar(_a: i32, _b: i32) {
|
|
|
|
}
|
|
|
|
|
|
|
|
const A: i32 = 3;
|
|
|
|
|
|
|
|
const fn baz() -> i32 {
|
|
|
|
3
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
foo(2);
|
|
|
|
foo(2 + 3);
|
2018-08-31 06:50:14 -05:00
|
|
|
const BAZ: i32 = baz();
|
|
|
|
foo(BAZ);
|
2018-02-05 12:48:22 -06:00
|
|
|
let a = 4;
|
|
|
|
foo(A);
|
|
|
|
foo(a); //~ ERROR: argument 1 is required to be a constant
|
|
|
|
bar(a, 3);
|
|
|
|
bar(a, a); //~ ERROR: argument 2 is required to be a constant
|
|
|
|
}
|