rustdoc: Remove redundant Impl.span
field
It can be computed on-demand in `Item::span()`.
This commit is contained in:
parent
88b4ea8fb6
commit
c32ee54380
src/librustdoc
@ -115,7 +115,6 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
||||
visibility: Inherited,
|
||||
def_id: ItemId::Auto { trait_: trait_def_id, for_: item_def_id },
|
||||
kind: box ImplItem(Impl {
|
||||
span: Span::dummy(),
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
generics: new_generics,
|
||||
trait_: Some(trait_ref.clean(self.cx)),
|
||||
|
@ -106,7 +106,6 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
|
||||
visibility: Inherited,
|
||||
def_id: ItemId::Blanket { impl_id: impl_def_id, for_: item_def_id },
|
||||
kind: box ImplItem(Impl {
|
||||
span: Span::new(self.cx.tcx.def_span(impl_def_id)),
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
generics: (
|
||||
self.cx.tcx.generics_of(impl_def_id),
|
||||
|
@ -490,7 +490,6 @@ crate fn build_impl(
|
||||
did,
|
||||
None,
|
||||
clean::ImplItem(clean::Impl {
|
||||
span: clean::types::rustc_span(did, cx.tcx),
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
generics,
|
||||
trait_,
|
||||
|
@ -1889,7 +1889,6 @@ fn clean_impl(impl_: &hir::Impl<'_>, hir_id: hir::HirId, cx: &mut DocContext<'_>
|
||||
});
|
||||
let mut make_item = |trait_: Option<Path>, for_: Type, items: Vec<Item>| {
|
||||
let kind = ImplItem(Impl {
|
||||
span: types::rustc_span(tcx.hir().local_def_id(hir_id).to_def_id(), tcx),
|
||||
unsafety: impl_.unsafety,
|
||||
generics: impl_.generics.clean(cx),
|
||||
trait_,
|
||||
|
@ -391,12 +391,19 @@ impl Item {
|
||||
ItemKind::StrippedItem(k) => k,
|
||||
_ => &*self.kind,
|
||||
};
|
||||
if let ItemKind::ModuleItem(Module { span, .. }) | ItemKind::ImplItem(Impl { span, .. }) =
|
||||
kind
|
||||
{
|
||||
*span
|
||||
} else {
|
||||
self.def_id.as_def_id().map(|did| rustc_span(did, tcx)).unwrap_or_else(Span::dummy)
|
||||
match kind {
|
||||
ItemKind::ModuleItem(Module { span, .. }) => *span,
|
||||
ItemKind::ImplItem(Impl { synthetic: true, .. }) => Span::dummy(),
|
||||
ItemKind::ImplItem(Impl { blanket_impl: Some(_), .. }) => {
|
||||
if let ItemId::Blanket { impl_id, .. } = self.def_id {
|
||||
rustc_span(impl_id, tcx)
|
||||
} else {
|
||||
panic!("blanket impl item has non-blanket ID")
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
self.def_id.as_def_id().map(|did| rustc_span(did, tcx)).unwrap_or_else(Span::dummy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2165,7 +2172,6 @@ impl Constant {
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
crate struct Impl {
|
||||
crate span: Span,
|
||||
crate unsafety: hir::Unsafety,
|
||||
crate generics: Generics,
|
||||
crate trait_: Option<Path>,
|
||||
|
@ -509,7 +509,6 @@ impl FromWithTcx<clean::Impl> for Impl {
|
||||
negative_polarity,
|
||||
synthetic,
|
||||
blanket_impl,
|
||||
span: _span,
|
||||
} = impl_;
|
||||
// FIXME: should `trait_` be a clean::Path equivalent in JSON?
|
||||
let trait_ = trait_.map(|path| {
|
||||
|
Loading…
x
Reference in New Issue
Block a user