Rollup merge of #85044 - ChrisDenton:file-exists, r=jackh726

Use `path.exists()` instead of `fs::metadata(path).is_ok()`

It's more explicit and potentially allows platforms to optimize the existence check.
This commit is contained in:
Dylan DPC 2021-05-08 01:06:26 +02:00 committed by GitHub
commit b5092627c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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> {