Skip to content

Commit

Permalink
Use path.exists() instead of fs::metadata(path).is_ok()
Browse files Browse the repository at this point in the history
It's more explicit and allows platforms to optimize the existence check.
  • Loading branch information
ChrisDenton committed May 7, 2021
1 parent e5f83d2 commit d9a58f4
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 @@ -764,7 +764,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 d9a58f4

Please sign in to comment.