Skip to content

Commit e62fce3

Browse files
authored
Rollup merge of #83809 - GuillaumeGomez:remove-initial-ids, r=camelid
Remove unneeded INITIAL_IDS const Some IDs inside this map didn't exist anymore, some others were duplicates of what we have inside `IdMap`. So instead of keeping the two around and since `INITIAL_IDS` was only used by `IdMap`, no need to keep both of them.
2 parents 25026c9 + 13e482b commit e62fce3

File tree

4 files changed

+11
-30
lines changed

4 files changed

+11
-30
lines changed

src/librustdoc/config.rs

-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ impl Options {
510510
let edition = config::parse_crate_edition(&matches);
511511

512512
let mut id_map = html::markdown::IdMap::new();
513-
id_map.populate(&html::render::INITIAL_IDS);
514513
let external_html = match ExternalHtml::load(
515514
&matches.opt_strs("html-in-header"),
516515
&matches.opt_strs("html-before-content"),

src/librustdoc/html/markdown.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,9 @@ fn init_id_map() -> FxHashMap<String, usize> {
13561356
map.insert("rustdoc-vars".to_owned(), 1);
13571357
map.insert("sidebar-vars".to_owned(), 1);
13581358
map.insert("copy-path".to_owned(), 1);
1359+
map.insert("help".to_owned(), 1);
1360+
map.insert("TOC".to_owned(), 1);
1361+
map.insert("render-detail".to_owned(), 1);
13591362
// This is the list of IDs used by rustdoc sections.
13601363
map.insert("fields".to_owned(), 1);
13611364
map.insert("variants".to_owned(), 1);
@@ -1365,6 +1368,12 @@ fn init_id_map() -> FxHashMap<String, usize> {
13651368
map.insert("trait-implementations".to_owned(), 1);
13661369
map.insert("synthetic-implementations".to_owned(), 1);
13671370
map.insert("blanket-implementations".to_owned(), 1);
1371+
map.insert("associated-types".to_owned(), 1);
1372+
map.insert("associated-const".to_owned(), 1);
1373+
map.insert("required-methods".to_owned(), 1);
1374+
map.insert("provided-methods".to_owned(), 1);
1375+
map.insert("implementors".to_owned(), 1);
1376+
map.insert("synthetic-implementors".to_owned(), 1);
13681377
map
13691378
}
13701379

@@ -1373,12 +1382,6 @@ impl IdMap {
13731382
IdMap { map: init_id_map() }
13741383
}
13751384

1376-
crate fn populate<I: IntoIterator<Item = S>, S: AsRef<str> + ToString>(&mut self, ids: I) {
1377-
for id in ids {
1378-
let _ = self.derive(id);
1379-
}
1380-
}
1381-
13821385
crate fn derive<S: AsRef<str> + ToString>(&mut self, candidate: S) -> String {
13831386
let id = match self.map.get_mut(candidate.as_ref()) {
13841387
None => candidate.to_string(),

src/librustdoc/html/render/context.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use super::print_item::{full_path, item_path, print_item};
1818
use super::write_shared::write_shared;
1919
use super::{
2020
print_sidebar, settings, AllTypes, NameDoc, SharedContext, StylePath, BASIC_KEYWORDS,
21-
CURRENT_DEPTH, INITIAL_IDS,
21+
CURRENT_DEPTH,
2222
};
2323

2424
use crate::clean::{self, AttributesExt};
@@ -423,14 +423,11 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
423423
}
424424

425425
fn make_child_renderer(&self) -> Self {
426-
let mut id_map = IdMap::new();
427-
id_map.populate(&INITIAL_IDS);
428-
429426
Self {
430427
current: self.current.clone(),
431428
dst: self.dst.clone(),
432429
render_redirect_pages: self.render_redirect_pages,
433-
id_map: RefCell::new(id_map),
430+
id_map: RefCell::new(IdMap::new()),
434431
deref_id_map: RefCell::new(FxHashMap::default()),
435432
shared: Rc::clone(&self.shared),
436433
cache: Rc::clone(&self.cache),

src/librustdoc/html/render/mod.rs

-18
Original file line numberDiff line numberDiff line change
@@ -283,24 +283,6 @@ crate struct StylePath {
283283

284284
thread_local!(crate static CURRENT_DEPTH: Cell<usize> = Cell::new(0));
285285

286-
crate const INITIAL_IDS: [&'static str; 15] = [
287-
"main",
288-
"search",
289-
"help",
290-
"TOC",
291-
"render-detail",
292-
"associated-types",
293-
"associated-const",
294-
"required-methods",
295-
"provided-methods",
296-
"implementors",
297-
"synthetic-implementors",
298-
"implementors-list",
299-
"synthetic-implementors-list",
300-
"methods",
301-
"implementations",
302-
];
303-
304286
fn write_srclink(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer) {
305287
if let Some(l) = cx.src_href(item) {
306288
write!(buf, "<a class=\"srclink\" href=\"{}\" title=\"goto source code\">[src]</a>", l)

0 commit comments

Comments
 (0)