2020-06-27 06:33:50 -05:00
|
|
|
#![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
|
2020-07-08 15:16:18 -05:00
|
|
|
//~| ERROR: the type of const parameters must not depend on other generic parameters
|
2020-06-27 06:33:50 -05:00
|
|
|
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
|
2020-07-08 15:16:18 -05:00
|
|
|
//~| ERROR: the type of const parameters must not depend on other generic parameters
|
2020-06-27 06:33:50 -05:00
|
|
|
>(
|
|
|
|
args: Args,
|
|
|
|
) {
|
|
|
|
FN(args)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = Test();
|
|
|
|
x.call_me::<PassArg, 30, pass>()
|
|
|
|
}
|