Auto merge of #82265 - GuillaumeGomez:cleanup-attrs-twice, r=jyn514
Prevent to compute Item attributes twice I came across this case when working on another part of rustdoc. Not a game changer but a nice little improvement. cc `@camelid` r? `@jyn514`
This commit is contained in:
commit
b36f77012d
2 changed files with 23 additions and 6 deletions
|
@ -414,7 +414,10 @@ crate fn build_impl(
|
||||||
|
|
||||||
debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id());
|
debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id());
|
||||||
|
|
||||||
let mut item = clean::Item::from_def_id_and_parts(
|
let attrs = box merge_attrs(cx, parent_module.into(), load_attrs(cx, did), attrs);
|
||||||
|
debug!("merged_attrs={:?}", attrs);
|
||||||
|
|
||||||
|
ret.push(clean::Item::from_def_id_and_attrs_and_parts(
|
||||||
did,
|
did,
|
||||||
None,
|
None,
|
||||||
clean::ImplItem(clean::Impl {
|
clean::ImplItem(clean::Impl {
|
||||||
|
@ -428,11 +431,9 @@ crate fn build_impl(
|
||||||
synthetic: false,
|
synthetic: false,
|
||||||
blanket_impl: None,
|
blanket_impl: None,
|
||||||
}),
|
}),
|
||||||
|
attrs,
|
||||||
cx,
|
cx,
|
||||||
);
|
));
|
||||||
item.attrs = box merge_attrs(cx, parent_module.into(), load_attrs(cx, did), attrs);
|
|
||||||
debug!("merged_attrs={:?}", item.attrs);
|
|
||||||
ret.push(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_module(
|
fn build_module(
|
||||||
|
|
|
@ -147,6 +147,22 @@ impl Item {
|
||||||
name: Option<Symbol>,
|
name: Option<Symbol>,
|
||||||
kind: ItemKind,
|
kind: ItemKind,
|
||||||
cx: &mut DocContext<'_>,
|
cx: &mut DocContext<'_>,
|
||||||
|
) -> Item {
|
||||||
|
Self::from_def_id_and_attrs_and_parts(
|
||||||
|
def_id,
|
||||||
|
name,
|
||||||
|
kind,
|
||||||
|
box cx.tcx.get_attrs(def_id).clean(cx),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_def_id_and_attrs_and_parts(
|
||||||
|
def_id: DefId,
|
||||||
|
name: Option<Symbol>,
|
||||||
|
kind: ItemKind,
|
||||||
|
attrs: Box<Attributes>,
|
||||||
|
cx: &mut DocContext<'_>,
|
||||||
) -> Item {
|
) -> Item {
|
||||||
debug!("name={:?}, def_id={:?}", name, def_id);
|
debug!("name={:?}, def_id={:?}", name, def_id);
|
||||||
|
|
||||||
|
@ -164,7 +180,7 @@ impl Item {
|
||||||
kind: box kind,
|
kind: box kind,
|
||||||
name,
|
name,
|
||||||
source: source.clean(cx),
|
source: source.clean(cx),
|
||||||
attrs: box cx.tcx.get_attrs(def_id).clean(cx),
|
attrs,
|
||||||
visibility: cx.tcx.visibility(def_id).clean(cx),
|
visibility: cx.tcx.visibility(def_id).clean(cx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue