Skip to content

Commit 5c01cf4

Browse files
committed
Initialize the ID map with known values
1 parent fa0269d commit 5c01cf4

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/librustdoc/html/render.rs

+22-2
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,33 @@ thread_local!(static CACHE_KEY: RefCell<Arc<Cache>> = Default::default());
343343
thread_local!(pub static CURRENT_LOCATION_KEY: RefCell<Vec<String>> =
344344
RefCell::new(Vec::new()));
345345
thread_local!(static USED_ID_MAP: RefCell<HashMap<String, usize>> =
346-
RefCell::new(HashMap::new()));
346+
RefCell::new(init_ids()));
347+
348+
fn init_ids() -> HashMap<String, usize> {
349+
[
350+
"main",
351+
"search",
352+
"help",
353+
"TOC",
354+
"render-detail",
355+
"associated-types",
356+
"associated-const",
357+
"required-methods",
358+
"provided-methods",
359+
"implementors",
360+
"implementors-list",
361+
"methods",
362+
"deref-methods",
363+
"implementations",
364+
"derived_implementations"
365+
].into_iter().map(|id| (String::from(*id), 1)).collect::<HashMap<_, _>>()
366+
}
347367

348368
/// This method resets the local table of used ID attributes. This is typically
349369
/// used at the beginning of rendering an entire HTML page to reset from the
350370
/// previous state (if any).
351371
pub fn reset_ids() {
352-
USED_ID_MAP.with(|s| s.borrow_mut().clear());
372+
USED_ID_MAP.with(|s| *s.borrow_mut() = init_ids());
353373
}
354374

355375
pub fn with_unique_id<T, F: FnOnce(&str) -> T>(candidate: String, f: F) -> T {

0 commit comments

Comments
 (0)