Add test for issue-71381
This commit is contained in:
parent
394e1b40d2
commit
88fe556db8
2 changed files with 47 additions and 0 deletions
33
src/test/ui/const-generics/issues/issue-71381.rs
Normal file
33
src/test/ui/const-generics/issues/issue-71381.rs
Normal 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>()
|
||||
}
|
||||
14
src/test/ui/const-generics/issues/issue-71381.stderr
Normal file
14
src/test/ui/const-generics/issues/issue-71381.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue