@@ -17,14 +17,15 @@ extern crate rustc_interface;
17
17
#[ macro_use]
18
18
extern crate rustc_public;
19
19
20
+ use std:: convert:: TryFrom ;
21
+ use std:: io:: Write ;
22
+ use std:: ops:: ControlFlow ;
23
+
20
24
use rustc_public:: mir:: alloc:: GlobalAlloc ;
21
25
use rustc_public:: mir:: mono:: Instance ;
22
26
use rustc_public:: mir:: { Body , ConstOperand , Operand , Rvalue , StatementKind , TerminatorKind } ;
23
27
use rustc_public:: ty:: { ConstantKind , MirConst } ;
24
28
use rustc_public:: { CrateDef , CrateItems , ItemKind } ;
25
- use std:: convert:: TryFrom ;
26
- use std:: io:: Write ;
27
- use std:: ops:: ControlFlow ;
28
29
29
30
const CRATE_NAME : & str = "input" ;
30
31
@@ -37,17 +38,17 @@ fn test_transform() -> ControlFlow<()> {
37
38
let target_fn = * get_item ( & items, ( ItemKind :: Fn , "dummy" ) ) . unwrap ( ) ;
38
39
let instance = Instance :: try_from ( target_fn) . unwrap ( ) ;
39
40
let body = instance. body ( ) . unwrap ( ) ;
40
- check_msg ( & body, "oops\0 " ) ;
41
+ check_msg ( & body, b "oops\xff \0 ") ;
41
42
42
43
let new_msg = "new panic message" ;
43
44
let new_body = change_panic_msg ( body, new_msg) ;
44
- check_msg ( & new_body, new_msg) ;
45
+ check_msg ( & new_body, new_msg. as_bytes ( ) ) ;
45
46
46
47
ControlFlow :: Continue ( ( ) )
47
48
}
48
49
49
50
/// Check that the body panic message matches the given message.
50
- fn check_msg ( body : & Body , expected : & str ) {
51
+ fn check_msg ( body : & Body , expected : & [ u8 ] ) {
51
52
let msg = body
52
53
. blocks
53
54
. iter ( )
@@ -80,7 +81,7 @@ fn check_msg(body: &Body, expected: &str) {
80
81
unreachable ! ( )
81
82
} ;
82
83
let bytes = val. raw_bytes ( ) . unwrap ( ) ;
83
- Some ( std :: str :: from_utf8 ( & bytes) . unwrap ( ) . to_string ( ) )
84
+ Some ( bytes. to_owned ( ) )
84
85
}
85
86
_ => None ,
86
87
} )
0 commit comments