Skip to content

Commit 38444f6

Browse files
* Rename Span::from_rustc_span to Span::new
* Rename Span::wrap to Span::wrap_raw * Improve documentation for Span::wrap_raw
1 parent 2a3b71a commit 38444f6

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

src/librustdoc/clean/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ fn build_module(
517517
}
518518
}
519519

520-
let span = clean::Span::from_rustc_span(cx.tcx.def_span(did));
520+
let span = clean::Span::new(cx.tcx.def_span(did));
521521
clean::Module { items, span }
522522
}
523523

src/librustdoc/clean/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ impl Clean<Item> for doctree::Module<'_> {
9595

9696
// determine if we should display the inner contents or
9797
// the outer `mod` item for the source code.
98-
let span = Span::from_rustc_span({
98+
99+
let span = Span::new({
99100
let where_outer = self.where_outer(cx.tcx);
100101
let sm = cx.sess().source_map();
101102
let outer = sm.lookup_char_pos(where_outer.lo());

src/librustdoc/clean/types.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ crate struct Item {
343343
rustc_data_structures::static_assert_size!(Item, 56);
344344

345345
crate fn rustc_span(def_id: DefId, tcx: TyCtxt<'_>) -> Span {
346-
Span::from_rustc_span(def_id.as_local().map_or_else(
346+
Span::new(def_id.as_local().map_or_else(
347347
|| tcx.def_span(def_id),
348348
|local| {
349349
let hir = tcx.hir();
@@ -1947,15 +1947,15 @@ impl Span {
19471947
/// span will be updated to point to the macro invocation instead of the macro definition.
19481948
///
19491949
/// (See rust-lang/rust#39726)
1950-
crate fn from_rustc_span(sp: rustc_span::Span) -> Self {
1950+
crate fn new(sp: rustc_span::Span) -> Self {
19511951
Self(sp.source_callsite())
19521952
}
19531953

1954-
/// Unless you know what you're doing, use [`Self::from_rustc_span`] instead!
1954+
/// Unless you know what you're doing, use [`Self::new`] instead!
19551955
///
1956-
/// Contrary to [`Self::from_rustc_span`], this constructor wraps the span as is and don't
1957-
/// perform any operation on it, even if it's from a macro expansion.
1958-
crate fn wrap(sp: rustc_span::Span) -> Span {
1956+
/// This function doesn't clean the span at all. Compare with [`Self::new`]'s body to see the
1957+
/// difference.
1958+
crate fn wrap_raw(sp: rustc_span::Span) -> Span {
19591959
Self(sp)
19601960
}
19611961

src/librustdoc/html/highlight.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ fn string<T: Display>(
597597
LinkFromSrc::Local(span) => {
598598
eprintln!("==> {:?}:{:?}", span.lo(), span.hi());
599599
context
600-
.href_from_span(clean::Span::wrap(*span))
600+
.href_from_span(clean::Span::wrap_raw(*span))
601601
.map(|s| format!("{}{}", root_path, s))
602602
}
603603
LinkFromSrc::External(def_id) => {

0 commit comments

Comments
 (0)