diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2018-02-08 13:11:13 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2018-02-08 14:46:27 -0800 |
| commit | 7a20fc14ef255df1ce2c417943605015aba2b1ff (patch) | |
| tree | f0163032b60fc571fb380761379eb7534bb43401 /src/test/compile-fail | |
| parent | 35dca7edd3e5181459c8e410a59a1b6e3e97a360 (diff) | |
Disallow function pointers to #[rustc_args_required_const]
This commit disallows acquiring a function pointer to functions tagged as `#[rustc_args_required_const]`. This is intended to be used as future-proofing for the stdsimd crate to avoid taking a function pointer to any intrinsic which has a hard requirement that one of the arguments is a constant value.
Diffstat (limited to 'src/test/compile-fail')
| -rw-r--r-- | src/test/compile-fail/rustc-args-required-const2.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/compile-fail/rustc-args-required-const2.rs b/src/test/compile-fail/rustc-args-required-const2.rs new file mode 100644 index 00000000000..aa63019307b --- /dev/null +++ b/src/test/compile-fail/rustc-args-required-const2.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(attr_literals, rustc_attrs, const_fn)] + +#[rustc_args_required_const(0)] +fn foo(_a: i32) { +} + +fn main() { + let a = foo; //~ ERROR: this function can only be invoked directly + a(2); +} |
