Skip to content

Commit

Permalink
Rollup merge of #85044 - ChrisDenton:file-exists, r=jackh726
Browse files Browse the repository at this point in the history
Use `path.exists()` instead of `fs::metadata(path).is_ok()`

It's more explicit and potentially allows platforms to optimize the existence check.
  • Loading branch information
Dylan-DPC authored May 7, 2021
2 parents b4a0020 + d9a58f4 commit b509262
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ impl<'a> Linker for MsvcLinker<'a> {
// check to see if the file is there and just omit linking to it if it's
// not present.
let name = format!("{}.dll.lib", lib);
if fs::metadata(&path.join(&name)).is_ok() {
if path.join(&name).exists() {
self.cmd.arg(name);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub struct RealFileLoader;

impl FileLoader for RealFileLoader {
fn file_exists(&self, path: &Path) -> bool {
fs::metadata(path).is_ok()
path.exists()
}

fn read_file(&self, path: &Path) -> io::Result<String> {
Expand Down

0 comments on commit b509262

Please sign in to comment.