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.
This commit is contained in:
parent
47b0059dba
commit
85f8ae8ec4
@ -117,7 +117,6 @@ impl From<DefId> for ItemId {
|
||||
#[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 @@ crate struct Crate {
|
||||
|
||||
// `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 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
|
||||
}
|
||||
|
||||
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 fn krate(cx: &mut DocContext<'_>) -> Crate {
|
||||
|
||||
Crate {
|
||||
name,
|
||||
src,
|
||||
module,
|
||||
externs,
|
||||
primitives,
|
||||
|
@ -405,7 +405,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
||||
..
|
||||
} = 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(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user