@@ -6,7 +6,6 @@ use crate::errors::{
66use crate :: llvm;
77use libc:: c_int;
88use rustc_codegen_ssa:: base:: wants_wasm_eh;
9- use rustc_codegen_ssa:: traits:: PrintBackendInfo ;
109use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
1110use rustc_data_structures:: small_c_str:: SmallCStr ;
1211use rustc_fs_util:: path_to_c_string;
@@ -18,6 +17,7 @@ use rustc_target::spec::{MergeFunctions, PanicStrategy};
1817use rustc_target:: target_features:: RUSTC_SPECIFIC_FEATURES ;
1918
2019use std:: ffi:: { c_char, c_void, CStr , CString } ;
20+ use std:: fmt:: Write ;
2121use std:: path:: Path ;
2222use std:: ptr;
2323use std:: slice;
@@ -371,7 +371,7 @@ fn llvm_target_features(tm: &llvm::TargetMachine) -> Vec<(&str, &str)> {
371371 ret
372372}
373373
374- fn print_target_features ( out : & mut dyn PrintBackendInfo , sess : & Session , tm : & llvm:: TargetMachine ) {
374+ fn print_target_features ( out : & mut String , sess : & Session , tm : & llvm:: TargetMachine ) {
375375 let mut llvm_target_features = llvm_target_features ( tm) ;
376376 let mut known_llvm_target_features = FxHashSet :: < & ' static str > :: default ( ) ;
377377 let mut rustc_target_features = sess
@@ -406,24 +406,26 @@ fn print_target_features(out: &mut dyn PrintBackendInfo, sess: &Session, tm: &ll
406406 . max ( )
407407 . unwrap_or ( 0 ) ;
408408
409- writeln ! ( out, "Features supported by rustc for this target:" ) ;
409+ writeln ! ( out, "Features supported by rustc for this target:" ) . unwrap ( ) ;
410410 for ( feature, desc) in & rustc_target_features {
411- writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) ;
411+ writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) . unwrap ( ) ;
412412 }
413- writeln ! ( out, "\n Code-generation features supported by LLVM for this target:" ) ;
413+ writeln ! ( out, "\n Code-generation features supported by LLVM for this target:" ) . unwrap ( ) ;
414414 for ( feature, desc) in & llvm_target_features {
415- writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) ;
415+ writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) . unwrap ( ) ;
416416 }
417417 if llvm_target_features. is_empty ( ) {
418- writeln ! ( out, " Target features listing is not supported by this LLVM version." ) ;
418+ writeln ! ( out, " Target features listing is not supported by this LLVM version." )
419+ . unwrap ( ) ;
419420 }
420- writeln ! ( out, "\n Use +feature to enable a feature, or -feature to disable it." ) ;
421- writeln ! ( out, "For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2\n " ) ;
422- writeln ! ( out, "Code-generation features cannot be used in cfg or #[target_feature]," ) ;
423- writeln ! ( out, "and may be renamed or removed in a future version of LLVM or rustc.\n " ) ;
421+ writeln ! ( out, "\n Use +feature to enable a feature, or -feature to disable it." ) . unwrap ( ) ;
422+ writeln ! ( out, "For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2\n " )
423+ . unwrap ( ) ;
424+ writeln ! ( out, "Code-generation features cannot be used in cfg or #[target_feature]," ) . unwrap ( ) ;
425+ writeln ! ( out, "and may be renamed or removed in a future version of LLVM or rustc.\n " ) . unwrap ( ) ;
424426}
425427
426- pub ( crate ) fn print ( req : & PrintRequest , mut out : & mut dyn PrintBackendInfo , sess : & Session ) {
428+ pub ( crate ) fn print ( req : & PrintRequest , mut out : & mut String , sess : & Session ) {
427429 require_inited ( ) ;
428430 let tm = create_informational_target_machine ( sess) ;
429431 match req. kind {
@@ -434,9 +436,9 @@ pub(crate) fn print(req: &PrintRequest, mut out: &mut dyn PrintBackendInfo, sess
434436 let cpu_cstring = CString :: new ( handle_native ( sess. target . cpu . as_ref ( ) ) )
435437 . unwrap_or_else ( |e| bug ! ( "failed to convert to cstring: {}" , e) ) ;
436438 unsafe extern "C" fn callback ( out : * mut c_void , string : * const c_char , len : usize ) {
437- let out = & mut * ( out as * mut & mut dyn PrintBackendInfo ) ;
439+ let out = & mut * ( out as * mut & mut String ) ;
438440 let bytes = slice:: from_raw_parts ( string as * const u8 , len) ;
439- write ! ( out, "{}" , String :: from_utf8_lossy( bytes) ) ;
441+ write ! ( out, "{}" , String :: from_utf8_lossy( bytes) ) . unwrap ( ) ;
440442 }
441443 unsafe {
442444 llvm:: LLVMRustPrintTargetCPUs (
0 commit comments