rustdoc: get rid of CURRENT_DEPTH

This commit is contained in:
Michael Howell 2021-04-17 22:34:58 -07:00
parent 755b4fb02b
commit 18fbd3692f
3 changed files with 44 additions and 52 deletions

View file

@ -16,7 +16,7 @@ use rustc_span::{symbol::sym, Symbol};
use super::cache::{build_index, ExternalLocation};
use super::print_item::{full_path, item_path, print_item};
use super::write_shared::write_shared;
use super::{print_sidebar, settings, AllTypes, NameDoc, StylePath, BASIC_KEYWORDS, CURRENT_DEPTH};
use super::{print_sidebar, settings, AllTypes, NameDoc, StylePath, BASIC_KEYWORDS};
use crate::clean::{self, AttributesExt};
use crate::config::RenderOptions;
@ -168,12 +168,6 @@ impl<'tcx> Context<'tcx> {
}
fn render_item(&self, it: &clean::Item, pushname: bool) -> String {
// A little unfortunate that this is done like this, but it sure
// does make formatting *a lot* nicer.
CURRENT_DEPTH.with(|slot| {
slot.set(self.current.len());
});
let mut title = if it.is_primitive() || it.is_keyword() {
// No need to include the namespace for primitive types and keywords
String::new()
@ -482,8 +476,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
cache: Rc::new(cache),
};
CURRENT_DEPTH.with(|s| s.set(0));
// Write shared runs within a flock; disable thread dispatching of IO temporarily.
Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
write_shared(&cx, &krate, index, &md_opts)?;

View file

@ -35,7 +35,6 @@ mod write_shared;
crate use context::*;
crate use write_shared::FILES_UNVERSIONED;
use std::cell::Cell;
use std::collections::VecDeque;
use std::default::Default;
use std::fmt;
@ -209,8 +208,6 @@ crate struct StylePath {
crate disabled: bool,
}
thread_local!(crate static CURRENT_DEPTH: Cell<usize> = Cell::new(0));
fn write_srclink(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer) {
if let Some(l) = cx.src_href(item) {
write!(buf, "<a class=\"srclink\" href=\"{}\" title=\"goto source code\">[src]</a>", l)