Skip to content

Commit 187d4cf

Browse files
committed
Auto merge of #13273 - BD103:master, r=weihanglo
Document why `du` function uses mutex ### What does this PR try to resolve? After closing #13253, it [was suggested](#13253 (comment)) to document why the `du` function uses a `Mutex` instead of an `AtomicU64`. This will prevent others from making the same mistake I did. :) ### How should we test and review this PR? N/A ### Additional information N/A
2 parents 3e428a3 + 0a6fe23 commit 187d4cf

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cargo-util/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-util"
3-
version = "0.2.9"
3+
version = "0.2.10"
44
rust-version.workspace = true
55
edition.workspace = true
66
license.workspace = true

crates/cargo-util/src/du.rs

+7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ fn du_inner(path: &Path, patterns: &[&str]) -> Result<u64> {
3939
.git_ignore(false)
4040
.git_exclude(false);
4141
let walker = builder.build_parallel();
42+
43+
// Platforms like PowerPC don't support AtomicU64, so we use a Mutex instead.
44+
//
45+
// See:
46+
// - https://github.com/rust-lang/cargo/pull/12981
47+
// - https://github.com/rust-lang/rust/pull/117916#issuecomment-1812635848
4248
let total = Arc::new(Mutex::new(0u64));
49+
4350
// A slot used to indicate there was an error while walking.
4451
//
4552
// It is possible that more than one error happens (such as in different

0 commit comments

Comments
 (0)