@@ -493,17 +493,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
493
493
/// Helper function to read an OsString from a 0x0000-terminated sequence of u16,
494
494
/// which is what the Windows APIs usually handle.
495
495
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
-
507
496
let u16_vec = self . eval_context_ref ( ) . memory . read_wide_str ( scalar) ?;
508
497
u16vec_to_osstring ( u16_vec)
509
498
}
@@ -637,6 +626,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
637
626
}
638
627
}
639
628
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
+
640
640
pub fn immty_from_int_checked < ' tcx > (
641
641
int : impl Into < i128 > ,
642
642
layout : TyLayout < ' tcx > ,
0 commit comments