@@ -493,17 +493,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
493493 /// Helper function to read an OsString from a 0x0000-terminated sequence of u16,
494494 /// which is what the Windows APIs usually handle.
495495 fn read_os_str_from_wide_str ( & self , scalar : Scalar < Tag > ) -> InterpResult < ' tcx , OsString > {
496- #[ cfg( target_os = "windows" ) ]
497- fn u16vec_to_osstring < ' tcx > ( u16_vec : Vec < u16 > ) -> InterpResult < ' tcx , OsString > {
498- Ok ( std:: os:: windows:: ffi:: OsStringExt :: from_wide ( & u16_vec[ ..] ) )
499- }
500- #[ cfg( not( target_os = "windows" ) ) ]
501- fn u16vec_to_osstring < ' tcx > ( u16_vec : Vec < u16 > ) -> InterpResult < ' tcx , OsString > {
502- let s = String :: from_utf16 ( & u16_vec[ ..] )
503- . map_err ( |_| err_unsup_format ! ( "{:?} is not a valid utf-16 string" , u16_vec) ) ?;
504- Ok ( s. into ( ) )
505- }
506-
507496 let u16_vec = self . eval_context_ref ( ) . memory . read_wide_str ( scalar) ?;
508497 u16vec_to_osstring ( u16_vec)
509498 }
@@ -637,6 +626,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
637626 }
638627}
639628
629+ #[ cfg( target_os = "windows" ) ]
630+ pub fn u16vec_to_osstring < ' tcx > ( u16_vec : Vec < u16 > ) -> InterpResult < ' tcx , OsString > {
631+ Ok ( std:: os:: windows:: ffi:: OsStringExt :: from_wide ( & u16_vec[ ..] ) )
632+ }
633+ #[ cfg( not( target_os = "windows" ) ) ]
634+ pub fn u16vec_to_osstring < ' tcx > ( u16_vec : Vec < u16 > ) -> InterpResult < ' tcx , OsString > {
635+ let s = String :: from_utf16 ( & u16_vec[ ..] )
636+ . map_err ( |_| err_unsup_format ! ( "{:?} is not a valid utf-16 string" , u16_vec) ) ?;
637+ Ok ( s. into ( ) )
638+ }
639+
640640pub fn immty_from_int_checked < ' tcx > (
641641 int : impl Into < i128 > ,
642642 layout : TyLayout < ' tcx > ,
0 commit comments