@@ -19,6 +19,7 @@ use rustc_middle::ty::{self, IntTy, Ty, TyCtxt, UintTy};
1919use rustc_session:: config:: CrateType ;
2020use rustc_span:: { Span , Symbol } ;
2121use rustc_symbol_mangling:: mangle_internal_symbol;
22+ use rustc_target:: spec:: Os ;
2223
2324use crate :: * ;
2425
@@ -234,7 +235,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
234235
235236 /// Helper function to get a `libc` constant as a `Scalar`.
236237 fn eval_libc ( & self , name : & str ) -> Scalar {
237- if self . eval_context_ref ( ) . tcx . sess . target . os == "windows" {
238+ if self . eval_context_ref ( ) . tcx . sess . target . os == Os :: Windows {
238239 panic ! (
239240 "`libc` crate is not reliably available on Windows targets; Miri should not use it there"
240241 ) ;
@@ -290,7 +291,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
290291 /// Helper function to get the `TyAndLayout` of a `libc` type
291292 fn libc_ty_layout ( & self , name : & str ) -> TyAndLayout < ' tcx > {
292293 let this = self . eval_context_ref ( ) ;
293- if this. tcx . sess . target . os == "windows" {
294+ if this. tcx . sess . target . os == Os :: Windows {
294295 panic ! (
295296 "`libc` crate is not reliably available on Windows targets; Miri should not use it there"
296297 ) ;
@@ -669,7 +670,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
669670 /// Helper function used inside the shims of foreign functions to assert that the target OS
670671 /// is `target_os`. It panics showing a message with the `name` of the foreign function
671672 /// if this is not the case.
672- fn assert_target_os ( & self , target_os : & str , name : & str ) {
673+ fn assert_target_os ( & self , target_os : Os , name : & str ) {
673674 assert_eq ! (
674675 self . eval_context_ref( ) . tcx. sess. target. os,
675676 target_os,
@@ -680,9 +681,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
680681 /// Helper function used inside shims of foreign functions to check that the target OS
681682 /// is one of `target_oses`. It returns an error containing the `name` of the foreign function
682683 /// in a message if this is not the case.
683- fn check_target_os ( & self , target_oses : & [ & str ] , name : Symbol ) -> InterpResult < ' tcx > {
684- let target_os = self . eval_context_ref ( ) . tcx . sess . target . os . as_ref ( ) ;
685- if !target_oses. contains ( & target_os) {
684+ fn check_target_os ( & self , target_oses : & [ Os ] , name : Symbol ) -> InterpResult < ' tcx > {
685+ let target_os = & self . eval_context_ref ( ) . tcx . sess . target . os ;
686+ if !target_oses. contains ( target_os) {
686687 throw_unsup_format ! ( "`{name}` is not supported on {target_os}" ) ;
687688 }
688689 interp_ok ( ( ) )
@@ -918,7 +919,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
918919 /// Always returns a `Vec<u32>` no matter the size of `wchar_t`.
919920 fn read_wchar_t_str ( & self , ptr : Pointer ) -> InterpResult < ' tcx , Vec < u32 > > {
920921 let this = self . eval_context_ref ( ) ;
921- let wchar_t = if this. tcx . sess . target . os == "windows" {
922+ let wchar_t = if this. tcx . sess . target . os == Os :: Windows {
922923 // We don't have libc on Windows so we have to hard-code the type ourselves.
923924 this. machine . layouts . u16
924925 } else {
0 commit comments