about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-09-12 13:16:14 +0000
committerbors <bors@rust-lang.org>2022-09-12 13:16:14 +0000
commit7f115e3cd239af753aeb398a114fa321a3ce584b (patch)
tree4f941d47b92d9baffa335a306be4a71d9a60b1ac /compiler/rustc_codegen_ssa/src
parenta93214ec06b57f1eb0cc2fd07e3c4b86b1b1d949 (diff)
parent9bf89e72184c4f598360f81cea7612759b560372 (diff)
downloadrust-7f115e3cd239af753aeb398a114fa321a3ce584b.tar.gz
rust-7f115e3cd239af753aeb398a114fa321a3ce584b.zip
Auto merge of #101716 - Dylan-DPC:rollup-ayvh6nd, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #100293 (Add inline-llvm option for disabling/enabling LLVM inlining)
 - #100767 (Remove manual <[u8]>::escape_ascii)
 - #101668 (Suggest pub instead of public for const type item)
 - #101671 (Fix naming format of IEEE 754 standard)
 - #101676 (Check that the types in return position `impl Trait` in traits are well-formed)
 - #101681 (Deny return-position `impl Trait` in traits for object safety)
 - #101693 (Update browser UI test 0 10)
 - #101701 (Rustdoc-Json: Add tests for trait impls.)
 - #101706 (rustdoc: remove no-op `#search`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs25
1 files changed, 8 insertions, 17 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index a3fed88cc4b..d7c7037ce1a 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -44,7 +44,7 @@ use std::io::{BufWriter, Write};
 use std::ops::Deref;
 use std::path::{Path, PathBuf};
 use std::process::{ExitStatus, Output, Stdio};
-use std::{ascii, char, env, fmt, fs, io, mem, str};
+use std::{env, fmt, fs, io, mem, str};
 
 pub fn ensure_removed(diag_handler: &Handler, path: &Path) {
     if let Err(e) = fs::remove_file(path) {
@@ -552,14 +552,6 @@ fn link_staticlib<'a>(
     Ok(())
 }
 
-fn escape_stdout_stderr_string(s: &[u8]) -> String {
-    str::from_utf8(s).map(|s| s.to_owned()).unwrap_or_else(|_| {
-        let mut x = "Non-UTF-8 output: ".to_string();
-        x.extend(s.iter().flat_map(|&b| ascii::escape_default(b)).map(char::from));
-        x
-    })
-}
-
 /// Use `thorin` (rust implementation of a dwarf packaging utility) to link DWARF objects into a
 /// DWARF package.
 fn link_dwarf_object<'a>(
@@ -866,7 +858,7 @@ fn link_natively<'a>(
             if !prog.status.success() {
                 let mut output = prog.stderr.clone();
                 output.extend_from_slice(&prog.stdout);
-                let escaped_output = escape_stdout_stderr_string(&output);
+                let escaped_output = escape_string(&output);
                 let mut err = sess.struct_err(&format!(
                     "linking with `{}` failed: {}",
                     linker_path.display(),
@@ -934,8 +926,8 @@ fn link_natively<'a>(
 
                 sess.abort_if_errors();
             }
-            info!("linker stderr:\n{}", escape_stdout_stderr_string(&prog.stderr));
-            info!("linker stdout:\n{}", escape_stdout_stderr_string(&prog.stdout));
+            info!("linker stderr:\n{}", escape_string(&prog.stderr));
+            info!("linker stdout:\n{}", escape_string(&prog.stdout));
         }
         Err(e) => {
             let linker_not_found = e.kind() == io::ErrorKind::NotFound;
@@ -1065,11 +1057,10 @@ fn strip_symbols_in_osx<'a>(sess: &'a Session, out_filename: &Path, option: Opti
 }
 
 fn escape_string(s: &[u8]) -> String {
-    str::from_utf8(s).map(|s| s.to_owned()).unwrap_or_else(|_| {
-        let mut x = "Non-UTF-8 output: ".to_string();
-        x.extend(s.iter().flat_map(|&b| ascii::escape_default(b)).map(char::from));
-        x
-    })
+    match str::from_utf8(s) {
+        Ok(s) => s.to_owned(),
+        Err(_) => format!("Non-UTF-8 output: {}", s.escape_ascii()),
+    }
 }
 
 fn add_sanitizer_libraries(sess: &Session, crate_type: CrateType, linker: &mut dyn Linker) {