Skip to content

Commit ef01ae7

Browse files
Force footnote references to be sorted by id
1 parent 4de4a95 commit ef01ae7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/librustdoc/html/markdown.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,13 @@ pub fn render(w: &mut fmt::Formatter,
585585
}
586586
}
587587
if !parser.footnotes.is_empty() {
588+
let mut v: Vec<_> = parser.footnotes.values().collect();
589+
v.sort_by(|a, b| a.1.cmp(&b.1));
588590
buffer.push_str(&format!("<div class=\"footnotes\"><hr><ol>{}</ol></div>",
589-
parser.footnotes.values()
590-
.map(|&(ref s, _)| s.as_str())
591-
.collect::<Vec<_>>()
592-
.join("")));
591+
v.iter()
592+
.map(|s| s.0.as_str())
593+
.collect::<Vec<_>>()
594+
.join("")));
593595
}
594596
let mut ret = toc_builder.map_or(Ok(()), |builder| {
595597
write!(w, "<nav id=\"TOC\">{}</nav>", builder.into_toc())

0 commit comments

Comments
 (0)