File tree Expand file tree Collapse file tree 5 files changed +19
-5
lines changed Expand file tree Collapse file tree 5 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 1
1
//ignore-test FIXME (do some basic validation of invariants for all values in flight)
2
+ //This does currently not get caught becuase it compiles to SwitchInt, which
3
+ //has no knowledge about data invariants.
2
4
3
5
fn main ( ) {
4
6
let b = unsafe { std:: mem:: transmute :: < u8 , bool > ( 2 ) } ;
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ let b = unsafe { std:: mem:: transmute :: < u8 , bool > ( 2 ) } ;
3
+ let _x = b == true ; //~ ERROR invalid boolean value read
4
+ }
Original file line number Diff line number Diff line change 1
1
// ignore-test FIXME: we are not checking these things on match any more?
2
+ //This does currently not get caught becuase it compiles to SwitchInt, which
3
+ //has no knowledge about data invariants.
2
4
3
5
fn main ( ) {
4
6
assert ! ( std:: char :: from_u32( -1_i32 as u32 ) . is_none( ) ) ;
5
- match unsafe { std:: mem:: transmute :: < i32 , char > ( -1 ) } { //~ ERROR constant evaluation error
7
+ let _ = match unsafe { std:: mem:: transmute :: < i32 , char > ( -1 ) } { //~ ERROR constant evaluation error
6
8
//~^ NOTE tried to interpret an invalid 32-bit value as a char: 4294967295
7
- 'a' => { } ,
8
- 'b' => { } ,
9
- _ => { } ,
10
- }
9
+ 'a' => { true } ,
10
+ 'b' => { false } ,
11
+ _ => { true } ,
12
+ } ;
11
13
}
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ assert ! ( std:: char :: from_u32( -1_i32 as u32 ) . is_none( ) ) ;
3
+ let c = unsafe { std:: mem:: transmute :: < i32 , char > ( -1 ) } ;
4
+ let _x = c == 'x' ; //~ ERROR tried to interpret an invalid 32-bit value as a char
5
+ }
Original file line number Diff line number Diff line change @@ -25,4 +25,5 @@ fn main() {
25
25
assert_eq ! ( if_false( ) , 0 ) ;
26
26
assert_eq ! ( if_true( ) , 1 ) ;
27
27
assert_eq ! ( match_bool( ) , 1 ) ;
28
+ assert_eq ! ( true == true , true ) ;
28
29
}
You can’t perform that action at this time.
0 commit comments