File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
src/test/ui/consts/min_const_fn Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ fn main ( ) { }
2
+
3
+ const fn unsize ( x : & [ u8 ; 3 ] ) -> & [ u8 ] { x }
4
+ //~^ ERROR unsizing casts are not allowed in const fn
5
+ const fn closure ( ) -> fn ( ) { || { } }
6
+ //~^ ERROR function pointers in const fn are unstable
7
+ const fn closure2 ( ) {
8
+ ( || { } ) as fn ( ) ;
9
+ //~^ ERROR function pointers in const fn are unstable
10
+ }
11
+ const fn reify ( f : fn ( ) ) -> unsafe fn ( ) { f }
12
+ //~^ ERROR function pointers in const fn are unstable
13
+ const fn reify2 ( ) { main as unsafe fn ( ) ; }
14
+ //~^ ERROR function pointers in const fn are unstable
Original file line number Diff line number Diff line change
1
+ error: unsizing casts are not allowed in const fn
2
+ --> $DIR/cast_errors.rs:3:41
3
+ |
4
+ LL | const fn unsize(x: &[u8; 3]) -> &[u8] { x }
5
+ | ^
6
+
7
+ error: function pointers in const fn are unstable
8
+ --> $DIR/cast_errors.rs:5:23
9
+ |
10
+ LL | const fn closure() -> fn() { || {} }
11
+ | ^^^^
12
+
13
+ error: function pointers in const fn are unstable
14
+ --> $DIR/cast_errors.rs:8:5
15
+ |
16
+ LL | (|| {}) as fn();
17
+ | ^^^^^^^^^^^^^^^
18
+
19
+ error: function pointers in const fn are unstable
20
+ --> $DIR/cast_errors.rs:11:28
21
+ |
22
+ LL | const fn reify(f: fn()) -> unsafe fn() { f }
23
+ | ^^^^^^^^^^^
24
+
25
+ error: function pointers in const fn are unstable
26
+ --> $DIR/cast_errors.rs:13:21
27
+ |
28
+ LL | const fn reify2() { main as unsafe fn(); }
29
+ | ^^^^^^^^^^^^^^^^^^^
30
+
31
+ error: aborting due to 5 previous errors
32
+
You can’t perform that action at this time.
0 commit comments