]> git.proxmox.com Git - rustc.git/blob - src/test/ui/const-generics/issues/issue-71381.rs
New upstream version 1.49.0+dfsg1
[rustc.git] / src / test / ui / const-generics / issues / issue-71381.rs
1 // revisions: full min
2 #![cfg_attr(full, feature(const_generics))]
3 #![cfg_attr(full, allow(incomplete_features))]
4 #![cfg_attr(min, feature(min_const_generics))]
5
6 struct Test(*const usize);
7
8 type PassArg = ();
9
10 unsafe extern "C" fn pass(args: PassArg) {
11 println!("Hello, world!");
12 }
13
14 impl Test {
15 pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
16 //~^ ERROR: using function pointers as const generic parameters is forbidden
17 //~| ERROR: the type of const parameters must not depend on other generic parameters
18 self.0 = Self::trampiline::<Args, IDX, FN> as _
19 }
20
21 unsafe extern "C" fn trampiline<
22 Args: Sized,
23 const IDX: usize,
24 const FN: unsafe extern "C" fn(Args),
25 //~^ ERROR: using function pointers as const generic parameters is forbidden
26 //~| ERROR: the type of const parameters must not depend on other generic parameters
27 >(
28 args: Args,
29 ) {
30 FN(args)
31 }
32 }
33
34 fn main() {
35 let x = Test();
36 x.call_me::<PassArg, 30, pass>()
37 }