Skip to content

Commit

Permalink
config reading: Add a note about use of .exists
Browse files Browse the repository at this point in the history
std::path::Path::exists is wrong and should never be used.  But let's
deal with that on a future occasion, as it may be controversial and/or
too much risk of a breaking change.
  • Loading branch information
ijackson committed Apr 24, 2024
1 parent 00895e8 commit 35d5fd5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cargo/util/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,11 @@ impl GlobalContext {
let possible = dir.join(filename_without_extension);
let possible_with_extension = dir.join(format!("{}.toml", filename_without_extension));

// Arguably this is wrong, because it ignores errors.
// I.e. it is "error-prone", as discussed in the docs for `std::path::Path::exists`.
//
// Instead, if we got an error, we should bail, but perhaps
// that might be too much risk of being a breaking change.
if possible.exists() {
if warn {
// We don't want to print a warning if the version
Expand Down

0 comments on commit 35d5fd5

Please sign in to comment.