about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAugie Fackler <augie@google.com>2025-03-18 16:32:09 -0400
committerAugie Fackler <augie@google.com>2025-03-18 16:41:32 -0400
commit795a6669f83274ce3ada1046e6c9284b8e900a98 (patch)
tree2c3dade89be1c58df263034d87fe1675f54ff613
parent75530e9f72a1990ed2305e16fd51d02f47048f12 (diff)
downloadrust-795a6669f83274ce3ada1046e6c9284b8e900a98.tar.gz
rust-795a6669f83274ce3ada1046e6c9284b8e900a98.zip
rustc_resolve: fix instability in lib.rmeta contents
rust-lang/rust@23032f31c91f2 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.
-rw-r--r--Cargo.lock1
-rw-r--r--compiler/rustc_resolve/Cargo.toml1
-rw-r--r--compiler/rustc_resolve/src/rustdoc.rs3
3 files changed, 4 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 63a3f5dd037..67ddac6032b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4316,6 +4316,7 @@ name = "rustc_resolve"
 version = "0.0.0"
 dependencies = [
  "bitflags",
+ "itertools",
  "pulldown-cmark 0.11.3",
  "rustc_arena",
  "rustc_ast",
diff --git a/compiler/rustc_resolve/Cargo.toml b/compiler/rustc_resolve/Cargo.toml
index f4771f1af2c..9ea9c58cfd1 100644
--- a/compiler/rustc_resolve/Cargo.toml
+++ b/compiler/rustc_resolve/Cargo.toml
@@ -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" }
diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs
index 52aaab77ebe..9fda1eb4dc4 100644
--- a/compiler/rustc_resolve/src/rustdoc.rs
+++ b/compiler/rustc_resolve/src/rustdoc.rs
@@ -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));
         }