@@ -17,14 +17,15 @@ extern crate rustc_interface;
1717#[ macro_use]
1818extern crate rustc_public;
1919
20+ use std:: convert:: TryFrom ;
21+ use std:: io:: Write ;
22+ use std:: ops:: ControlFlow ;
23+
2024use rustc_public:: mir:: alloc:: GlobalAlloc ;
2125use rustc_public:: mir:: mono:: Instance ;
2226use rustc_public:: mir:: { Body , ConstOperand , Operand , Rvalue , StatementKind , TerminatorKind } ;
2327use rustc_public:: ty:: { ConstantKind , MirConst } ;
2428use rustc_public:: { CrateDef , CrateItems , ItemKind } ;
25- use std:: convert:: TryFrom ;
26- use std:: io:: Write ;
27- use std:: ops:: ControlFlow ;
2829
2930const CRATE_NAME : & str = "input" ;
3031
@@ -37,17 +38,17 @@ fn test_transform() -> ControlFlow<()> {
3738 let target_fn = * get_item ( & items, ( ItemKind :: Fn , "dummy" ) ) . unwrap ( ) ;
3839 let instance = Instance :: try_from ( target_fn) . unwrap ( ) ;
3940 let body = instance. body ( ) . unwrap ( ) ;
40- check_msg ( & body, "oops\0 " ) ;
41+ check_msg ( & body, b "oops\xff \0 ") ;
4142
4243 let new_msg = "new panic message" ;
4344 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 ( ) ) ;
4546
4647 ControlFlow :: Continue ( ( ) )
4748}
4849
4950/// 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 ] ) {
5152 let msg = body
5253 . blocks
5354 . iter ( )
@@ -80,7 +81,7 @@ fn check_msg(body: &Body, expected: &str) {
8081 unreachable ! ( )
8182 } ;
8283 let bytes = val. raw_bytes ( ) . unwrap ( ) ;
83- Some ( std :: str :: from_utf8 ( & bytes) . unwrap ( ) . to_string ( ) )
84+ Some ( bytes. to_owned ( ) )
8485 }
8586 _ => None ,
8687 } )
0 commit comments