Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 8, 2021

Conversation

ChrisDenton
Copy link
Member

It's more explicit and potentially allows platforms to optimize the existence check.

It's more explicit and allows platforms to optimize the existence check.
@rust-highfive
Copy link
Collaborator

r? @jackh726

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 7, 2021
@Xanewok
Copy link
Member

Xanewok commented May 7, 2021

There's a discussion in https://internals.rust-lang.org/t/the-api-of-path-exists-encourages-broken-code/13817/46 that debates whether this Path::exists API is okay.

I noticed you replied in #83186, maybe it'd be more worthwhile waiting until it's stabilized before replacing the current calls with path.exists()?

@ChrisDenton
Copy link
Member Author

Perhaps. But I'm not sure that anything is gained by waiting. This PR has (or should have) zero impact on current code and is very easy to upgrade to try_exists once it's ready.

@jackh726
Copy link
Member

jackh726 commented May 7, 2021

Interally, this is exactly the same, so I'm going to go ahead and @bors r+ rollup

However, the point about try_exists is interesting. We can use unstable features in the compiler, so stabilization there is not a problem. I'm not sure if the semantic change here is what we want (I don't know this code), but if you think it's worth switching, I encourage a follow-up PR :)

@bors
Copy link
Contributor

bors commented May 7, 2021

📌 Commit d9a58f4 has been approved by jackh726

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 7, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request May 8, 2021
Rollup of 6 pull requests

Successful merges:

 - rust-lang#76808 (Improve diagnostics for functions in `struct` definitions)
 - rust-lang#84887 (Remove SpanInterner::get)
 - rust-lang#85034 (fix null pointer error messages)
 - rust-lang#85038 (Don't stop running rustdoc-gui tests at first failure)
 - rust-lang#85044 (Use `path.exists()` instead of `fs::metadata(path).is_ok()`)
 - rust-lang#85052 (rustdoc: Link to the docs on namespaces when an unknown disambiguator is found)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b509262 into rust-lang:master May 8, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 8, 2021
@ChrisDenton ChrisDenton deleted the file-exists branch May 8, 2021 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants