File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ // Make sure match uses the usual pointer comparison code path -- i.e., it should complain
3
+ // that pointer comparison is disallowed, not that parts of a pointer are accessed as raw
4
+ // bytes.
5
+ let _: [ u8 ; 0 ] = [ 4 ; { //~ ERROR could not evaluate repeat length
6
+ match & 1 as * const i32 as usize { //~ ERROR raw pointers cannot be cast to integers
7
+ 0 => 42 , //~ ERROR constant contains unimplemented expression type
8
+ //~^ NOTE "pointer arithmetic or comparison" needs an rfc before being allowed
9
+ n => n,
10
+ }
11
+ } ] ;
12
+ }
Original file line number Diff line number Diff line change
1
+ error[E0018]: raw pointers cannot be cast to integers in constants
2
+ --> $DIR/match-test-ptr-null.rs:6:15
3
+ |
4
+ LL | match &1 as *const i32 as usize { //~ ERROR raw pointers cannot be cast to integers
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
6
+
7
+ error[E0019]: constant contains unimplemented expression type
8
+ --> $DIR/match-test-ptr-null.rs:7:13
9
+ |
10
+ LL | 0 => 42, //~ ERROR constant contains unimplemented expression type
11
+ | ^
12
+
13
+ error[E0080]: could not evaluate repeat length
14
+ --> $DIR/match-test-ptr-null.rs:5:26
15
+ |
16
+ LL | let _: [u8; 0] = [4; { //~ ERROR could not evaluate repeat length
17
+ | __________________________^
18
+ LL | | match &1 as *const i32 as usize { //~ ERROR raw pointers cannot be cast to integers
19
+ LL | | 0 => 42, //~ ERROR constant contains unimplemented expression type
20
+ | | - "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
21
+ LL | | //~^ NOTE "pointer arithmetic or comparison" needs an rfc before being allowed
22
+ LL | | n => n,
23
+ LL | | }
24
+ LL | | }];
25
+ | |_____^
26
+
27
+ error: aborting due to 3 previous errors
28
+
29
+ Some errors occurred: E0018, E0019, E0080.
30
+ For more information about an error, try `rustc --explain E0018`.
You can’t perform that action at this time.
0 commit comments