Skip to content

Commit c32ee54

Browse files
committed
rustdoc: Remove redundant Impl.span field
It can be computed on-demand in `Item::span()`.
1 parent 88b4ea8 commit c32ee54

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

src/librustdoc/clean/auto_trait.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
115115
visibility: Inherited,
116116
def_id: ItemId::Auto { trait_: trait_def_id, for_: item_def_id },
117117
kind: box ImplItem(Impl {
118-
span: Span::dummy(),
119118
unsafety: hir::Unsafety::Normal,
120119
generics: new_generics,
121120
trait_: Some(trait_ref.clean(self.cx)),

src/librustdoc/clean/blanket_impl.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
106106
visibility: Inherited,
107107
def_id: ItemId::Blanket { impl_id: impl_def_id, for_: item_def_id },
108108
kind: box ImplItem(Impl {
109-
span: Span::new(self.cx.tcx.def_span(impl_def_id)),
110109
unsafety: hir::Unsafety::Normal,
111110
generics: (
112111
self.cx.tcx.generics_of(impl_def_id),

src/librustdoc/clean/inline.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ crate fn build_impl(
490490
did,
491491
None,
492492
clean::ImplItem(clean::Impl {
493-
span: clean::types::rustc_span(did, cx.tcx),
494493
unsafety: hir::Unsafety::Normal,
495494
generics,
496495
trait_,

src/librustdoc/clean/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,6 @@ fn clean_impl(impl_: &hir::Impl<'_>, hir_id: hir::HirId, cx: &mut DocContext<'_>
18891889
});
18901890
let mut make_item = |trait_: Option<Path>, for_: Type, items: Vec<Item>| {
18911891
let kind = ImplItem(Impl {
1892-
span: types::rustc_span(tcx.hir().local_def_id(hir_id).to_def_id(), tcx),
18931892
unsafety: impl_.unsafety,
18941893
generics: impl_.generics.clean(cx),
18951894
trait_,

src/librustdoc/clean/types.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,19 @@ impl Item {
391391
ItemKind::StrippedItem(k) => k,
392392
_ => &*self.kind,
393393
};
394-
if let ItemKind::ModuleItem(Module { span, .. }) | ItemKind::ImplItem(Impl { span, .. }) =
395-
kind
396-
{
397-
*span
398-
} else {
399-
self.def_id.as_def_id().map(|did| rustc_span(did, tcx)).unwrap_or_else(Span::dummy)
394+
match kind {
395+
ItemKind::ModuleItem(Module { span, .. }) => *span,
396+
ItemKind::ImplItem(Impl { synthetic: true, .. }) => Span::dummy(),
397+
ItemKind::ImplItem(Impl { blanket_impl: Some(_), .. }) => {
398+
if let ItemId::Blanket { impl_id, .. } = self.def_id {
399+
rustc_span(impl_id, tcx)
400+
} else {
401+
panic!("blanket impl item has non-blanket ID")
402+
}
403+
}
404+
_ => {
405+
self.def_id.as_def_id().map(|did| rustc_span(did, tcx)).unwrap_or_else(Span::dummy)
406+
}
400407
}
401408
}
402409

@@ -2165,7 +2172,6 @@ impl Constant {
21652172

21662173
#[derive(Clone, Debug)]
21672174
crate struct Impl {
2168-
crate span: Span,
21692175
crate unsafety: hir::Unsafety,
21702176
crate generics: Generics,
21712177
crate trait_: Option<Path>,

src/librustdoc/json/conversions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ impl FromWithTcx<clean::Impl> for Impl {
509509
negative_polarity,
510510
synthetic,
511511
blanket_impl,
512-
span: _span,
513512
} = impl_;
514513
// FIXME: should `trait_` be a clean::Path equivalent in JSON?
515514
let trait_ = trait_.map(|path| {

0 commit comments

Comments
 (0)