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.
This commit is contained in:
commit
e62fce32e5
4 changed files with 11 additions and 30 deletions
|
@ -510,7 +510,6 @@ impl Options {
|
||||||
let edition = config::parse_crate_edition(&matches);
|
let edition = config::parse_crate_edition(&matches);
|
||||||
|
|
||||||
let mut id_map = html::markdown::IdMap::new();
|
let mut id_map = html::markdown::IdMap::new();
|
||||||
id_map.populate(&html::render::INITIAL_IDS);
|
|
||||||
let external_html = match ExternalHtml::load(
|
let external_html = match ExternalHtml::load(
|
||||||
&matches.opt_strs("html-in-header"),
|
&matches.opt_strs("html-in-header"),
|
||||||
&matches.opt_strs("html-before-content"),
|
&matches.opt_strs("html-before-content"),
|
||||||
|
|
|
@ -1356,6 +1356,9 @@ fn init_id_map() -> FxHashMap<String, usize> {
|
||||||
map.insert("rustdoc-vars".to_owned(), 1);
|
map.insert("rustdoc-vars".to_owned(), 1);
|
||||||
map.insert("sidebar-vars".to_owned(), 1);
|
map.insert("sidebar-vars".to_owned(), 1);
|
||||||
map.insert("copy-path".to_owned(), 1);
|
map.insert("copy-path".to_owned(), 1);
|
||||||
|
map.insert("help".to_owned(), 1);
|
||||||
|
map.insert("TOC".to_owned(), 1);
|
||||||
|
map.insert("render-detail".to_owned(), 1);
|
||||||
// This is the list of IDs used by rustdoc sections.
|
// This is the list of IDs used by rustdoc sections.
|
||||||
map.insert("fields".to_owned(), 1);
|
map.insert("fields".to_owned(), 1);
|
||||||
map.insert("variants".to_owned(), 1);
|
map.insert("variants".to_owned(), 1);
|
||||||
|
@ -1365,6 +1368,12 @@ fn init_id_map() -> FxHashMap<String, usize> {
|
||||||
map.insert("trait-implementations".to_owned(), 1);
|
map.insert("trait-implementations".to_owned(), 1);
|
||||||
map.insert("synthetic-implementations".to_owned(), 1);
|
map.insert("synthetic-implementations".to_owned(), 1);
|
||||||
map.insert("blanket-implementations".to_owned(), 1);
|
map.insert("blanket-implementations".to_owned(), 1);
|
||||||
|
map.insert("associated-types".to_owned(), 1);
|
||||||
|
map.insert("associated-const".to_owned(), 1);
|
||||||
|
map.insert("required-methods".to_owned(), 1);
|
||||||
|
map.insert("provided-methods".to_owned(), 1);
|
||||||
|
map.insert("implementors".to_owned(), 1);
|
||||||
|
map.insert("synthetic-implementors".to_owned(), 1);
|
||||||
map
|
map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1373,12 +1382,6 @@ impl IdMap {
|
||||||
IdMap { map: init_id_map() }
|
IdMap { map: init_id_map() }
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn populate<I: IntoIterator<Item = S>, S: AsRef<str> + ToString>(&mut self, ids: I) {
|
|
||||||
for id in ids {
|
|
||||||
let _ = self.derive(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
crate fn derive<S: AsRef<str> + ToString>(&mut self, candidate: S) -> String {
|
crate fn derive<S: AsRef<str> + ToString>(&mut self, candidate: S) -> String {
|
||||||
let id = match self.map.get_mut(candidate.as_ref()) {
|
let id = match self.map.get_mut(candidate.as_ref()) {
|
||||||
None => candidate.to_string(),
|
None => candidate.to_string(),
|
||||||
|
|
|
@ -18,7 +18,7 @@ use super::print_item::{full_path, item_path, print_item};
|
||||||
use super::write_shared::write_shared;
|
use super::write_shared::write_shared;
|
||||||
use super::{
|
use super::{
|
||||||
print_sidebar, settings, AllTypes, NameDoc, SharedContext, StylePath, BASIC_KEYWORDS,
|
print_sidebar, settings, AllTypes, NameDoc, SharedContext, StylePath, BASIC_KEYWORDS,
|
||||||
CURRENT_DEPTH, INITIAL_IDS,
|
CURRENT_DEPTH,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::clean::{self, AttributesExt};
|
use crate::clean::{self, AttributesExt};
|
||||||
|
@ -423,14 +423,11 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_child_renderer(&self) -> Self {
|
fn make_child_renderer(&self) -> Self {
|
||||||
let mut id_map = IdMap::new();
|
|
||||||
id_map.populate(&INITIAL_IDS);
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
current: self.current.clone(),
|
current: self.current.clone(),
|
||||||
dst: self.dst.clone(),
|
dst: self.dst.clone(),
|
||||||
render_redirect_pages: self.render_redirect_pages,
|
render_redirect_pages: self.render_redirect_pages,
|
||||||
id_map: RefCell::new(id_map),
|
id_map: RefCell::new(IdMap::new()),
|
||||||
deref_id_map: RefCell::new(FxHashMap::default()),
|
deref_id_map: RefCell::new(FxHashMap::default()),
|
||||||
shared: Rc::clone(&self.shared),
|
shared: Rc::clone(&self.shared),
|
||||||
cache: Rc::clone(&self.cache),
|
cache: Rc::clone(&self.cache),
|
||||||
|
|
|
@ -283,24 +283,6 @@ crate struct StylePath {
|
||||||
|
|
||||||
thread_local!(crate static CURRENT_DEPTH: Cell<usize> = Cell::new(0));
|
thread_local!(crate static CURRENT_DEPTH: Cell<usize> = Cell::new(0));
|
||||||
|
|
||||||
crate const INITIAL_IDS: [&'static str; 15] = [
|
|
||||||
"main",
|
|
||||||
"search",
|
|
||||||
"help",
|
|
||||||
"TOC",
|
|
||||||
"render-detail",
|
|
||||||
"associated-types",
|
|
||||||
"associated-const",
|
|
||||||
"required-methods",
|
|
||||||
"provided-methods",
|
|
||||||
"implementors",
|
|
||||||
"synthetic-implementors",
|
|
||||||
"implementors-list",
|
|
||||||
"synthetic-implementors-list",
|
|
||||||
"methods",
|
|
||||||
"implementations",
|
|
||||||
];
|
|
||||||
|
|
||||||
fn write_srclink(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer) {
|
fn write_srclink(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer) {
|
||||||
if let Some(l) = cx.src_href(item) {
|
if let Some(l) = cx.src_href(item) {
|
||||||
write!(buf, "<a class=\"srclink\" href=\"{}\" title=\"goto source code\">[src]</a>", l)
|
write!(buf, "<a class=\"srclink\" href=\"{}\" title=\"goto source code\">[src]</a>", l)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue