Skip to content

Commit bdc5adf

Browse files
authored
Rollup merge of #138678 - durin42:rmeta-stability, r=fmease
rustc_resolve: fix instability in lib.rmeta contents 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.
2 parents ad87732 + 1437dec commit bdc5adf

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4300,6 +4300,7 @@ name = "rustc_resolve"
43004300
version = "0.0.0"
43014301
dependencies = [
43024302
"bitflags",
4303+
"itertools",
43034304
"pulldown-cmark 0.11.3",
43044305
"rustc_arena",
43054306
"rustc_ast",

compiler/rustc_resolve/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
9+
itertools = "0.12"
910
pulldown-cmark = { version = "0.11", features = ["html"], default-features = false }
1011
rustc_arena = { path = "../rustc_arena" }
1112
rustc_ast = { path = "../rustc_ast" }

compiler/rustc_resolve/src/rustdoc.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
use std::mem;
22
use std::ops::Range;
33

4+
use itertools::Itertools;
45
use pulldown_cmark::{
56
BrokenLink, BrokenLinkCallback, CowStr, Event, LinkType, Options, Parser, Tag,
67
};
78
use rustc_ast as ast;
89
use rustc_ast::attr::AttributeExt;
910
use rustc_ast::util::comments::beautify_doc_string;
10-
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
11+
use rustc_data_structures::fx::FxIndexMap;
12+
use rustc_data_structures::unord::UnordSet;
1113
use rustc_middle::ty::TyCtxt;
1214
use rustc_span::def_id::DefId;
1315
use rustc_span::{DUMMY_SP, InnerSpan, Span, Symbol, kw, sym};
@@ -422,7 +424,7 @@ fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> {
422424
);
423425
let mut links = Vec::new();
424426

425-
let mut refids = FxHashSet::default();
427+
let mut refids = UnordSet::default();
426428

427429
while let Some(event) = event_iter.next() {
428430
match event {
@@ -454,7 +456,7 @@ fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> {
454456
}
455457
}
456458

457-
for (label, refdef) in event_iter.reference_definitions().iter() {
459+
for (label, refdef) in event_iter.reference_definitions().iter().sorted_by_key(|x| x.0) {
458460
if !refids.contains(label) {
459461
links.push(preprocess_link(&refdef.dest));
460462
}

src/librustdoc/html/markdown.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,7 @@ pub(crate) fn markdown_links<'md, R>(
17241724
md: &'md str,
17251725
preprocess_link: impl Fn(MarkdownLink) -> Option<R>,
17261726
) -> Vec<R> {
1727+
use itertools::Itertools;
17271728
if md.is_empty() {
17281729
return vec![];
17291730
}
@@ -1882,7 +1883,7 @@ pub(crate) fn markdown_links<'md, R>(
18821883
let mut links = Vec::new();
18831884

18841885
let mut refdefs = FxIndexMap::default();
1885-
for (label, refdef) in event_iter.reference_definitions().iter() {
1886+
for (label, refdef) in event_iter.reference_definitions().iter().sorted_by_key(|x| x.0) {
18861887
refdefs.insert(label.to_string(), (false, refdef.dest.to_string(), refdef.span.clone()));
18871888
}
18881889

0 commit comments

Comments
 (0)