1 // This test is a regression test for a bug where we only checked function calls in no-const
2 // functions for `rustc_args_required_const` arguments. This meant that even though `bar` needs its
3 // argument to be const, inside a const fn (callable at runtime), the value for it may come from a
4 // non-constant (namely an argument to the const fn).
6 #![feature(rustc_attrs)]
8 bar(a); //~ ERROR argument 1 is required to be a constant
11 #[rustc_args_required_const(0)]
12 const fn bar(_: i32) {}
15 // this function call will pass a runtime-value (number of program arguments) to `foo`, which
16 // will in turn forward it to `bar`, which expects a compile-time argument
17 foo(std::env::args().count() as i32);