rustc_resolve: fix instability in lib.rmeta contents

rust-lang/rust@23032f31c9 accidentally introduced some nondeterminism
in the ordering of lib.rmeta files, which we caught in our bazel-based
builds only recently due to being further behind than normal. In my
testing, this fixes the issue.
This commit is contained in:
Augie Fackler 2025-03-18 16:32:09 -04:00
parent 75530e9f72
commit 795a6669f8
3 changed files with 4 additions and 1 deletions

View file

@ -4316,6 +4316,7 @@ name = "rustc_resolve"
version = "0.0.0"
dependencies = [
"bitflags",
"itertools",
"pulldown-cmark 0.11.3",
"rustc_arena",
"rustc_ast",

View file

@ -6,6 +6,7 @@ edition = "2024"
[dependencies]
# tidy-alphabetical-start
bitflags = "2.4.1"
itertools = "0.12"
pulldown-cmark = { version = "0.11", features = ["html"], default-features = false }
rustc_arena = { path = "../rustc_arena" }
rustc_ast = { path = "../rustc_ast" }

View file

@ -1,6 +1,7 @@
use std::mem;
use std::ops::Range;
use itertools::Itertools;
use pulldown_cmark::{
BrokenLink, BrokenLinkCallback, CowStr, Event, LinkType, Options, Parser, Tag,
};
@ -454,7 +455,7 @@ fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> {
}
}
for (label, refdef) in event_iter.reference_definitions().iter() {
for (label, refdef) in event_iter.reference_definitions().iter().sorted_by_key(|x| x.0) {
if !refids.contains(label) {
links.push(preprocess_link(&refdef.dest));
}