@@ -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;
@@ -372,7 +372,7 @@ fn llvm_target_features(tm: &llvm::TargetMachine) -> Vec<(&str, &str)> {
372372 ret
373373}
374374
375- fn print_target_features ( out : & mut dyn PrintBackendInfo , sess : & Session , tm : & llvm:: TargetMachine ) {
375+ fn print_target_features ( out : & mut String , sess : & Session , tm : & llvm:: TargetMachine ) {
376376 let mut llvm_target_features = llvm_target_features ( tm) ;
377377 let mut known_llvm_target_features = FxHashSet :: < & ' static str > :: default ( ) ;
378378 let mut rustc_target_features = sess
@@ -412,24 +412,26 @@ fn print_target_features(out: &mut dyn PrintBackendInfo, sess: &Session, tm: &ll
412412 . max ( )
413413 . unwrap_or ( 0 ) ;
414414
415- writeln ! ( out, "Features supported by rustc for this target:" ) ;
415+ writeln ! ( out, "Features supported by rustc for this target:" ) . unwrap ( ) ;
416416 for ( feature, desc) in & rustc_target_features {
417- writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) ;
417+ writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) . unwrap ( ) ;
418418 }
419- writeln ! ( out, "\n Code-generation features supported by LLVM for this target:" ) ;
419+ writeln ! ( out, "\n Code-generation features supported by LLVM for this target:" ) . unwrap ( ) ;
420420 for ( feature, desc) in & llvm_target_features {
421- writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) ;
421+ writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) . unwrap ( ) ;
422422 }
423423 if llvm_target_features. is_empty ( ) {
424- writeln ! ( out, " Target features listing is not supported by this LLVM version." ) ;
424+ writeln ! ( out, " Target features listing is not supported by this LLVM version." )
425+ . unwrap ( ) ;
425426 }
426- writeln ! ( out, "\n Use +feature to enable a feature, or -feature to disable it." ) ;
427- writeln ! ( out, "For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2\n " ) ;
428- writeln ! ( out, "Code-generation features cannot be used in cfg or #[target_feature]," ) ;
429- writeln ! ( out, "and may be renamed or removed in a future version of LLVM or rustc.\n " ) ;
427+ writeln ! ( out, "\n Use +feature to enable a feature, or -feature to disable it." ) . unwrap ( ) ;
428+ writeln ! ( out, "For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2\n " )
429+ . unwrap ( ) ;
430+ writeln ! ( out, "Code-generation features cannot be used in cfg or #[target_feature]," ) . unwrap ( ) ;
431+ writeln ! ( out, "and may be renamed or removed in a future version of LLVM or rustc.\n " ) . unwrap ( ) ;
430432}
431433
432- pub ( crate ) fn print ( req : & PrintRequest , mut out : & mut dyn PrintBackendInfo , sess : & Session ) {
434+ pub ( crate ) fn print ( req : & PrintRequest , mut out : & mut String , sess : & Session ) {
433435 require_inited ( ) ;
434436 let tm = create_informational_target_machine ( sess) ;
435437 match req. kind {
@@ -440,9 +442,9 @@ pub(crate) fn print(req: &PrintRequest, mut out: &mut dyn PrintBackendInfo, sess
440442 let cpu_cstring = CString :: new ( handle_native ( sess. target . cpu . as_ref ( ) ) )
441443 . unwrap_or_else ( |e| bug ! ( "failed to convert to cstring: {}" , e) ) ;
442444 unsafe extern "C" fn callback ( out : * mut c_void , string : * const c_char , len : usize ) {
443- let out = & mut * ( out as * mut & mut dyn PrintBackendInfo ) ;
445+ let out = & mut * ( out as * mut & mut String ) ;
444446 let bytes = slice:: from_raw_parts ( string as * const u8 , len) ;
445- write ! ( out, "{}" , String :: from_utf8_lossy( bytes) ) ;
447+ write ! ( out, "{}" , String :: from_utf8_lossy( bytes) ) . unwrap ( ) ;
446448 }
447449 unsafe {
448450 llvm:: LLVMRustPrintTargetCPUs (
0 commit comments