Use rustdoc Span in LinkFromSrc directly

This commit is contained in:
Guillaume Gomez 2021-05-05 14:48:41 +02:00 committed by Guillaume Gomez
parent dffc9c0a79
commit f233a70567
4 changed files with 6 additions and 15 deletions

View File

@ -98,7 +98,7 @@ 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::from_rustc_span(self.cx.tcx.def_span(impl_def_id)),
span: Span::new(self.cx.tcx.def_span(impl_def_id)),
unsafety: hir::Unsafety::Normal,
generics: (
self.cx.tcx.generics_of(impl_def_id),

View File

@ -1951,14 +1951,6 @@ impl Span {
Self(sp.source_callsite())
}
/// Unless you know what you're doing, use [`Self::new`] instead!
///
/// This function doesn't clean the span at all. Compare with [`Self::new`]'s body to see the
/// difference.
crate fn wrap_raw(sp: rustc_span::Span) -> Span {
Self(sp)
}
crate fn inner(&self) -> rustc_span::Span {
self.0
}

View File

@ -5,7 +5,6 @@
//!
//! Use the `render_with_highlighting` to highlight some rust code.
use crate::clean;
use crate::html::escape::Escape;
use crate::html::render::Context;
@ -584,7 +583,7 @@ fn string<T: Display>(
match href {
LinkFromSrc::Local(span) => {
context
.href_from_span(clean::Span::wrap_raw(*span))
.href_from_span(*span)
.map(|s| format!("{}{}", context_info.root_path, s))
}
LinkFromSrc::External(def_id) => {

View File

@ -20,7 +20,7 @@ use std::path::{Path, PathBuf};
/// instead of the source code directly.
#[derive(Debug)]
crate enum LinkFromSrc {
Local(Span),
Local(clean::Span),
External(DefId),
}
@ -113,7 +113,7 @@ impl<'tcx> SpanMapVisitor<'tcx> {
path_span
.map(LightSpan::new_from_span)
.unwrap_or_else(|| LightSpan::new_from_span(path.span)),
LinkFromSrc::Local(span),
LinkFromSrc::Local(clean::Span::new(span)),
);
} else if let Some(def_id) = info {
self.matches.insert(
@ -161,7 +161,7 @@ impl Visitor<'tcx> for SpanMapVisitor<'tcx> {
Node::Item(item) => {
self.matches.insert(
LightSpan::new_from_span(item.ident.span),
LinkFromSrc::Local(m.inner),
LinkFromSrc::Local(clean::Span::new(m.inner)),
);
}
_ => {}
@ -187,7 +187,7 @@ impl Visitor<'tcx> for SpanMapVisitor<'tcx> {
Some(span) => {
self.matches.insert(
LightSpan::new_from_span(method_span),
LinkFromSrc::Local(span),
LinkFromSrc::Local(clean::Span::new(span)),
);
}
None => {