@@ -43,7 +43,7 @@ use rustc_session::Session;
4343use rustc_session:: config:: { CrateType , OutputFilenames , OutputType } ;
4444use rustc_session:: output:: out_filename;
4545use rustc_span:: { Symbol , sym} ;
46- use rustc_target:: spec:: { Arch , PanicStrategy } ;
46+ use rustc_target:: spec:: { Arch , Os , PanicStrategy } ;
4747use std:: any:: Any ;
4848use std:: cmp:: min;
4949use std:: collections:: BTreeMap ;
@@ -302,15 +302,15 @@ impl CodegenBackend for GotocCodegenBackend {
302302 fn target_config ( & self , sess : & Session ) -> TargetConfig {
303303 // This code is adapted from the cranelift backend:
304304 // https://github.com/rust-lang/rust/blob/a124fb3cb7291d75872934f411d81fe298379ace/compiler/rustc_codegen_cranelift/src/lib.rs#L184
305- let target_features = if sess. target . arch == Arch :: X86_64 && sess. target . os != "none" {
305+ let target_features = if sess. target . arch == Arch :: X86_64 && sess. target . os != Os :: None {
306306 // x86_64 mandates SSE2 support and rustc requires the x87 feature to be enabled
307307 vec ! [ sym:: sse, sym:: sse2, Symbol :: intern( "x87" ) ]
308308 } else if sess. target . arch == Arch :: AArch64 {
309- match & * sess. target . os {
310- "none" => vec ! [ ] ,
309+ match sess. target . os {
310+ Os :: None => vec ! [ ] ,
311311 // On macOS the aes, sha2 and sha3 features are enabled by default and ring
312312 // fails to compile on macOS when they are not present.
313- "macos" => vec ! [ sym:: neon, sym:: aes, sym:: sha2, sym:: sha3] ,
313+ Os :: MacOs => vec ! [ sym:: neon, sym:: aes, sym:: sha2, sym:: sha3] ,
314314 // AArch64 mandates Neon support
315315 _ => vec ! [ sym:: neon] ,
316316 }
@@ -818,7 +818,11 @@ fn new_machine_model(sess: &Session) -> MachineModel {
818818 let wchar_t_width = 32 ;
819819
820820 MachineModel {
821- architecture : architecture. to_string ( ) ,
821+ architecture : match architecture {
822+ Arch :: X86_64 => "x86_64" . to_string ( ) ,
823+ Arch :: AArch64 => "aarch64" . to_string ( ) ,
824+ _ => panic ! ( "Unsupported architecture: {:?}" , architecture) ,
825+ } ,
822826 alignment,
823827 bool_width,
824828 char_is_unsigned,
@@ -848,8 +852,8 @@ fn new_machine_model(sess: &Session) -> MachineModel {
848852 let double_width = 64 ;
849853 let float_width = 32 ;
850854 let int_width = 32 ;
851- let long_double_width = match os. as_ref ( ) {
852- "linux" => 128 ,
855+ let long_double_width = match os {
856+ Os :: Linux => 128 ,
853857 _ => 64 ,
854858 } ;
855859 let long_int_width = 64 ;
@@ -859,7 +863,7 @@ fn new_machine_model(sess: &Session) -> MachineModel {
859863 // https://developer.arm.com/documentation/dui0491/i/Compiler-Command-line-Options/--signed-chars----unsigned-chars
860864 // https://www.arm.linux.org.uk/docs/faqs/signedchar.php
861865 // https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
862- let wchar_t_is_unsigned = matches ! ( os. as_ref ( ) , "linux" ) ;
866+ let wchar_t_is_unsigned = matches ! ( os, Os :: Linux ) ;
863867 let wchar_t_width = 32 ;
864868
865869 MachineModel {
0 commit comments