1
Fork 0

* Rename Span::from_rustc_span to Span::new

* Rename Span::wrap to Span::wrap_raw
* Improve documentation for Span::wrap_raw
This commit is contained in:
Guillaume Gomez 2021-04-22 15:14:49 +02:00 committed by Guillaume Gomez
parent 2a3b71ae33
commit 38444f61bb
4 changed files with 10 additions and 9 deletions

View file

@ -517,7 +517,7 @@ fn build_module(
}
}
let span = clean::Span::from_rustc_span(cx.tcx.def_span(did));
let span = clean::Span::new(cx.tcx.def_span(did));
clean::Module { items, span }
}

View file

@ -95,7 +95,8 @@ impl Clean<Item> for doctree::Module<'_> {
// determine if we should display the inner contents or
// the outer `mod` item for the source code.
let span = Span::from_rustc_span({
let span = Span::new({
let where_outer = self.where_outer(cx.tcx);
let sm = cx.sess().source_map();
let outer = sm.lookup_char_pos(where_outer.lo());

View file

@ -343,7 +343,7 @@ crate struct Item {
rustc_data_structures::static_assert_size!(Item, 56);
crate fn rustc_span(def_id: DefId, tcx: TyCtxt<'_>) -> Span {
Span::from_rustc_span(def_id.as_local().map_or_else(
Span::new(def_id.as_local().map_or_else(
|| tcx.def_span(def_id),
|local| {
let hir = tcx.hir();
@ -1947,15 +1947,15 @@ impl Span {
/// span will be updated to point to the macro invocation instead of the macro definition.
///
/// (See rust-lang/rust#39726)
crate fn from_rustc_span(sp: rustc_span::Span) -> Self {
crate fn new(sp: rustc_span::Span) -> Self {
Self(sp.source_callsite())
}
/// Unless you know what you're doing, use [`Self::from_rustc_span`] instead!
/// Unless you know what you're doing, use [`Self::new`] instead!
///
/// Contrary to [`Self::from_rustc_span`], this constructor wraps the span as is and don't
/// perform any operation on it, even if it's from a macro expansion.
crate fn wrap(sp: rustc_span::Span) -> Span {
/// 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)
}

View file

@ -597,7 +597,7 @@ fn string<T: Display>(
LinkFromSrc::Local(span) => {
eprintln!("==> {:?}:{:?}", span.lo(), span.hi());
context
.href_from_span(clean::Span::wrap(*span))
.href_from_span(clean::Span::wrap_raw(*span))
.map(|s| format!("{}{}", root_path, s))
}
LinkFromSrc::External(def_id) => {