File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
src/test/ui/const-generics/issues Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments