* 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:
parent
2a3b71ae33
commit
38444f61bb
4 changed files with 10 additions and 9 deletions
|
@ -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 }
|
clean::Module { items, span }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,8 @@ impl Clean<Item> for doctree::Module<'_> {
|
||||||
|
|
||||||
// determine if we should display the inner contents or
|
// determine if we should display the inner contents or
|
||||||
// the outer `mod` item for the source code.
|
// 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 where_outer = self.where_outer(cx.tcx);
|
||||||
let sm = cx.sess().source_map();
|
let sm = cx.sess().source_map();
|
||||||
let outer = sm.lookup_char_pos(where_outer.lo());
|
let outer = sm.lookup_char_pos(where_outer.lo());
|
||||||
|
|
|
@ -343,7 +343,7 @@ crate struct Item {
|
||||||
rustc_data_structures::static_assert_size!(Item, 56);
|
rustc_data_structures::static_assert_size!(Item, 56);
|
||||||
|
|
||||||
crate fn rustc_span(def_id: DefId, tcx: TyCtxt<'_>) -> Span {
|
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),
|
|| tcx.def_span(def_id),
|
||||||
|local| {
|
|local| {
|
||||||
let hir = tcx.hir();
|
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.
|
/// span will be updated to point to the macro invocation instead of the macro definition.
|
||||||
///
|
///
|
||||||
/// (See rust-lang/rust#39726)
|
/// (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())
|
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
|
/// This function doesn't clean the span at all. Compare with [`Self::new`]'s body to see the
|
||||||
/// perform any operation on it, even if it's from a macro expansion.
|
/// difference.
|
||||||
crate fn wrap(sp: rustc_span::Span) -> Span {
|
crate fn wrap_raw(sp: rustc_span::Span) -> Span {
|
||||||
Self(sp)
|
Self(sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -597,7 +597,7 @@ fn string<T: Display>(
|
||||||
LinkFromSrc::Local(span) => {
|
LinkFromSrc::Local(span) => {
|
||||||
eprintln!("==> {:?}:{:?}", span.lo(), span.hi());
|
eprintln!("==> {:?}:{:?}", span.lo(), span.hi());
|
||||||
context
|
context
|
||||||
.href_from_span(clean::Span::wrap(*span))
|
.href_from_span(clean::Span::wrap_raw(*span))
|
||||||
.map(|s| format!("{}{}", root_path, s))
|
.map(|s| format!("{}{}", root_path, s))
|
||||||
}
|
}
|
||||||
LinkFromSrc::External(def_id) => {
|
LinkFromSrc::External(def_id) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue