Skip to content

Commit 9f88880

Browse files
committed
config reading: Add a note about use of .exists
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.
1 parent 91f3e45 commit 9f88880

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/cargo/util/context/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,11 @@ impl GlobalContext {
15371537
let possible = dir.join(filename_without_extension);
15381538
let possible_with_extension = dir.join(format!("{}.toml", filename_without_extension));
15391539

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

0 commit comments

Comments
 (0)