Skip to content

Commit ea44703

Browse files
committed
fix(toml): Ensure targets are in a deterministic order
With rust-lang#13713, we enumerate all targets in `Cargo.toml` on `cargo publish` and `cargo vendor`. However, the order of the targets is non-determistic. This can be annoying for comparing the published `Cargo.toml` across releases but even worse is the churn it causes for `cargo vendor`. So we sort all the targets during publish. This keeps costs minimal with the following risks - If the non-determinism shows up in a way that affects developers during development - If there is a reason the user wants to control target order for explicit targets Fixes rust-lang#13988
1 parent 0b72605 commit ea44703

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,6 +2777,8 @@ fn prepare_targets_for_publish(
27772777
};
27782778
prepared.push(target);
27792779
}
2780+
// `unstable` should be deterministic because we enforce that `t.name` is unique
2781+
prepared.sort_unstable_by_key(|t| t.name.clone());
27802782

27812783
if prepared.is_empty() {
27822784
Ok(None)

0 commit comments

Comments
 (0)