提交 85f8ae8e 编写于 作者: N Noah Lev

rustdoc: Remove `Crate.src` and instead compute it on-demand

It is only used in one place; `src` was about a third of `Crate`'s total
size; `Crate` is frequently moved by-value; and `src` can be easily
computed on-demand.
上级 47b0059d
......@@ -117,7 +117,6 @@ fn from(id: DefId) -> Self {
#[derive(Clone, Debug)]
crate struct Crate {
crate name: Symbol,
crate src: FileName,
crate module: Item,
crate externs: Vec<ExternalCrate>,
crate primitives: ThinVec<(DefId, PrimitiveType)>,
......@@ -128,7 +127,13 @@ fn from(id: DefId) -> Self {
// `Crate` is frequently moved by-value. Make sure it doesn't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(Crate, 168);
rustc_data_structures::static_assert_size!(Crate, 104);
impl Crate {
crate fn src(&self, tcx: TyCtxt<'_>) -> FileName {
ExternalCrate::LOCAL.src(tcx)
}
}
/// This struct is used to wrap additional information added by rustdoc on a `trait` item.
#[derive(Clone, Debug)]
......
......@@ -57,7 +57,6 @@
}
let local_crate = ExternalCrate { crate_num: LOCAL_CRATE };
let src = local_crate.src(cx.tcx);
let name = local_crate.name(cx.tcx);
let primitives = local_crate.primitives(cx.tcx);
let keywords = local_crate.keywords(cx.tcx);
......@@ -81,7 +80,6 @@
Crate {
name,
src,
module,
externs,
primitives,
......
......@@ -405,7 +405,7 @@ fn init(
..
} = options;
let src_root = match krate.src {
let src_root = match krate.src(tcx) {
FileName::Real(ref p) => match p.local_path_if_available().parent() {
Some(p) => p.to_path_buf(),
None => PathBuf::new(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册