diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 9fd476bfbab55..e7304b6951083 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -607,7 +607,7 @@ mod tests {
fn issue_17736() {
let markdown = "# title";
format!("{}", Markdown(markdown));
- reset_ids();
+ reset_ids(true);
}
#[test]
@@ -615,7 +615,7 @@ mod tests {
fn t(input: &str, expect: &str) {
let output = format!("{}", Markdown(input));
assert_eq!(output, expect);
- reset_ids();
+ reset_ids(true);
}
t("# Foo bar", "\n
");
};
test();
- reset_ids();
+ reset_ids(true);
test();
}
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 462cef2e0e3c6..0f436efd70b2e 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -378,8 +378,14 @@ fn init_ids() -> HashMap {
/// This method resets the local table of used ID attributes. This is typically
/// used at the beginning of rendering an entire HTML page to reset from the
/// previous state (if any).
-pub fn reset_ids() {
- USED_ID_MAP.with(|s| *s.borrow_mut() = init_ids());
+pub fn reset_ids(embedded: bool) {
+ USED_ID_MAP.with(|s| {
+ *s.borrow_mut() = if embedded {
+ init_ids()
+ } else {
+ HashMap::new()
+ };
+ });
}
pub fn derive_id(candidate: String) -> String {
@@ -1280,7 +1286,7 @@ impl Context {
keywords: &keywords,
};
- reset_ids();
+ reset_ids(true);
// We have a huge number of calls to write, so try to alleviate some
// of the pain by using a buffered writer instead of invoking the
@@ -2748,6 +2754,6 @@ fn test_unique_id() {
assert_eq!(&actual[..], expected);
};
test();
- reset_ids();
+ reset_ids(true);
test();
}
diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs
index 03d2c1a1b4d0d..d21726dd40f08 100644
--- a/src/librustdoc/markdown.rs
+++ b/src/librustdoc/markdown.rs
@@ -83,7 +83,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
}
let title = metadata[0];
- reset_ids();
+ reset_ids(false);
let rendered = if include_toc {
format!("{}", MarkdownWithToc(text))