diff options
| author | bors <bors@rust-lang.org> | 2021-02-17 19:39:58 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-02-17 19:39:58 +0000 |
| commit | 152f6609246558be5e2582e67376194815e6ba0d (patch) | |
| tree | 2ff1f32fc6c1440a034dc09c11ca80613489e1e9 /compiler/rustc_codegen_ssa/src | |
| parent | 5ef21063f0c0fd5b973bfa8cb88c0b70982da977 (diff) | |
| parent | 03477e9a26fb1d600e21dc33116063f71ba295ef (diff) | |
| download | rust-152f6609246558be5e2582e67376194815e6ba0d.tar.gz rust-152f6609246558be5e2582e67376194815e6ba0d.zip | |
Auto merge of #82235 - GuillaumeGomez:rollup-oflxc08, r=GuillaumeGomez
Rollup of 11 pull requests Successful merges: - #79981 (Add 'consider using' message to overflowing_literals) - #82094 (To digit simplification) - #82105 (Don't fail to remove files if they are missing) - #82136 (Fix ICE: Use delay_span_bug for mismatched subst/hir arg) - #82169 (Document that `assert!` format arguments are evaluated lazily) - #82174 (Replace File::create and write_all with fs::write) - #82196 (Add caveat to Path::display() about lossiness) - #82198 (Use internal iteration in Iterator::is_sorted_by) - #82204 (Update books) - #82207 (rustdoc: treat edition 2021 as unstable) - #82231 (Add long explanation for E0543) 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.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/write.rs | 14 |
2 files changed, 14 insertions, 11 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 6c58417590e..972b9bbfe1c 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1,5 +1,6 @@ use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::temp_dir::MaybeTempDir; +use rustc_errors::Handler; use rustc_fs_util::fix_windows_verbatim_for_gcc; use rustc_hir::def_id::CrateNum; use rustc_middle::middle::cstore::{EncodedMetadata, LibSource}; @@ -34,9 +35,11 @@ use std::path::{Path, PathBuf}; use std::process::{ExitStatus, Output, Stdio}; use std::{ascii, char, env, fmt, fs, io, mem, str}; -pub fn remove(sess: &Session, path: &Path) { +pub fn ensure_removed(diag_handler: &Handler, path: &Path) { if let Err(e) = fs::remove_file(path) { - sess.err(&format!("failed to remove {}: {}", path.display(), e)); + if e.kind() != io::ErrorKind::NotFound { + diag_handler.err(&format!("failed to remove {}: {}", path.display(), e)); + } } } @@ -112,11 +115,11 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>( if !sess.opts.cg.save_temps { let remove_temps_from_module = |module: &CompiledModule| { if let Some(ref obj) = module.object { - remove(sess, obj); + ensure_removed(sess.diagnostic(), obj); } if let Some(ref obj) = module.dwarf_object { - remove(sess, obj); + ensure_removed(sess.diagnostic(), obj); } }; diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 6aef5cb535a..b0aed812460 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -1,4 +1,4 @@ -use super::link::{self, remove}; +use super::link::{self, ensure_removed}; use super::linker::LinkerInfo; use super::lto::{self, SerializedModule}; use super::symbol_export::symbol_name_for_instance_in_crate; @@ -543,7 +543,7 @@ fn produce_final_output_artifacts( copy_gracefully(&path, &crate_output.path(output_type)); if !sess.opts.cg.save_temps && !keep_numbered { // The user just wants `foo.x`, not `foo.#module-name#.x`. - remove(sess, &path); + ensure_removed(sess.diagnostic(), &path); } } else { let ext = crate_output @@ -642,19 +642,19 @@ fn produce_final_output_artifacts( for module in compiled_modules.modules.iter() { if let Some(ref path) = module.object { if !keep_numbered_objects { - remove(sess, path); + ensure_removed(sess.diagnostic(), path); } } if let Some(ref path) = module.dwarf_object { if !keep_numbered_objects { - remove(sess, path); + ensure_removed(sess.diagnostic(), path); } } if let Some(ref path) = module.bytecode { if !keep_numbered_bitcode { - remove(sess, path); + ensure_removed(sess.diagnostic(), path); } } } @@ -662,13 +662,13 @@ fn produce_final_output_artifacts( if !user_wants_bitcode { if let Some(ref metadata_module) = compiled_modules.metadata_module { if let Some(ref path) = metadata_module.bytecode { - remove(sess, &path); + ensure_removed(sess.diagnostic(), &path); } } if let Some(ref allocator_module) = compiled_modules.allocator_module { if let Some(ref path) = allocator_module.bytecode { - remove(sess, path); + ensure_removed(sess.diagnostic(), path); } } } |
