Skip to content

Commit 88fe556

Browse files
committed
Add test for issue-71381
1 parent 394e1b4 commit 88fe556

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#![feature(const_generics)]
2+
#![allow(incomplete_features)]
3+
4+
struct Test(*const usize);
5+
6+
type PassArg = ();
7+
8+
unsafe extern "C" fn pass(args: PassArg) {
9+
println!("Hello, world!");
10+
}
11+
12+
impl Test {
13+
pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
14+
//~^ ERROR: using function pointers as const generic parameters is forbidden
15+
self.0 = Self::trampiline::<Args, IDX, FN> as _
16+
}
17+
18+
unsafe extern "C" fn trampiline<
19+
Args: Sized,
20+
const IDX: usize,
21+
const FN: unsafe extern "C" fn(Args),
22+
//~^ ERROR: using function pointers as const generic parameters is forbidden
23+
>(
24+
args: Args,
25+
) {
26+
FN(args)
27+
}
28+
}
29+
30+
fn main() {
31+
let x = Test();
32+
x.call_me::<PassArg, 30, pass>()
33+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: using function pointers as const generic parameters is forbidden
2+
--> $DIR/issue-71381.rs:13:61
3+
|
4+
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: using function pointers as const generic parameters is forbidden
8+
--> $DIR/issue-71381.rs:21:19
9+
|
10+
LL | const FN: unsafe extern "C" fn(Args),
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+

0 commit comments

Comments
 (0)