Add test for issue-71381

This commit is contained in:
Yuki Okushi 2020-06-27 20:33:50 +09:00
parent 394e1b40d2
commit 88fe556db8
No known key found for this signature in database
GPG key ID: B0986C85C0E2DAA1
2 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1,33 @@
#![feature(const_generics)]
#![allow(incomplete_features)]
struct Test(*const usize);
type PassArg = ();
unsafe extern "C" fn pass(args: PassArg) {
println!("Hello, world!");
}
impl Test {
pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
//~^ ERROR: using function pointers as const generic parameters is forbidden
self.0 = Self::trampiline::<Args, IDX, FN> as _
}
unsafe extern "C" fn trampiline<
Args: Sized,
const IDX: usize,
const FN: unsafe extern "C" fn(Args),
//~^ ERROR: using function pointers as const generic parameters is forbidden
>(
args: Args,
) {
FN(args)
}
}
fn main() {
let x = Test();
x.call_me::<PassArg, 30, pass>()
}

View file

@ -0,0 +1,14 @@
error: using function pointers as const generic parameters is forbidden
--> $DIR/issue-71381.rs:13:61
|
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: using function pointers as const generic parameters is forbidden
--> $DIR/issue-71381.rs:21:19
|
LL | const FN: unsafe extern "C" fn(Args),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors