Skip to content

Commit

Permalink
Sort crates by version when synthesizing the virtual Cargo.lock file (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril authored Apr 10, 2022
1 parent 73eba00 commit 9b69c96
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/diag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ impl KrateSpans {
let mut spans = Vec::with_capacity(krates.len());
let mut cargo_spans = RawCargoSpans::new();

for krate in krates.krates().map(|kn| &kn.krate) {
let mut krates: Vec<_> = krates.krates().map(|kn| &kn.krate).collect();
// [Krates::krates] guarantees the krates to be ordered by name but we
// want the outputs of diagnostics to also be stable in regards to
// their version, so we do an additional sort for that here.
krates.sort_unstable_by_key(|a| (&a.name, &a.version));
for krate in krates {
let span_start = sl.len();
match &krate.source {
Some(src) => writeln!(sl, "{} {} {}", krate.name, krate.version, src)
Expand Down

0 comments on commit 9b69c96

Please sign in to comment.