File tree 2 files changed +37
-0
lines changed
tests/ui/type/pattern_types
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( pattern_types) ]
2
+ #![ feature( pattern_type_macro) ]
3
+
4
+ use std:: pat:: pattern_type;
5
+
6
+ fn create < const S : u32 , const E : u32 > ( x : u32 ) -> pattern_type ! ( u32 is S ..=E ) {
7
+ unsafe { std:: mem:: transmute ( x) }
8
+ //~^ ERROR types of different sizes
9
+ }
10
+
11
+ fn unwrap < const S : u32 , const E : u32 > ( x : pattern_type ! ( u32 is S ..=E ) ) -> u32 {
12
+ unsafe { std:: mem:: transmute ( x) }
13
+ //~^ ERROR types of different sizes
14
+ }
15
+
16
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
2
+ --> $DIR/transmute.rs:7:14
3
+ |
4
+ LL | unsafe { std::mem::transmute(x) }
5
+ | ^^^^^^^^^^^^^^^^^^^
6
+ |
7
+ = note: source type: `u32` (32 bits)
8
+ = note: target type: `(u32) is S..=E` (size can vary because of u32)
9
+
10
+ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
11
+ --> $DIR/transmute.rs:12:14
12
+ |
13
+ LL | unsafe { std::mem::transmute(x) }
14
+ | ^^^^^^^^^^^^^^^^^^^
15
+ |
16
+ = note: source type: `(u32) is S..=E` (size can vary because of u32)
17
+ = note: target type: `u32` (32 bits)
18
+
19
+ error: aborting due to 2 previous errors
20
+
21
+ For more information about this error, try `rustc --explain E0512`.
You can’t perform that action at this time.
0 commit comments