Skip to content

Commit 7dd475e

Browse files
committed
Rename clean::Span::span() to clean::Span::inner()
Otherwise you get a lot of instances of `item.span.span()`, which is just plain confusing. `item.span.inner()` conveys the correct meaning of "get the type that `clean::Span` wraps".
1 parent 8b9b106 commit 7dd475e

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

src/librustdoc/clean/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,12 +1866,12 @@ impl Span {
18661866
Self(sp.source_callsite())
18671867
}
18681868

1869-
crate fn dummy() -> Self {
1870-
Self(rustc_span::DUMMY_SP)
1869+
crate fn inner(&self) -> rustc_span::Span {
1870+
self.0
18711871
}
18721872

1873-
crate fn span(&self) -> rustc_span::Span {
1874-
self.0
1873+
crate fn dummy() -> Self {
1874+
Self(rustc_span::DUMMY_SP)
18751875
}
18761876

18771877
crate fn is_dummy(&self) -> bool {

src/librustdoc/html/render/print_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ fn item_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Mac
937937
Some("macro"),
938938
None,
939939
None,
940-
it.span.span().edition(),
940+
it.span.inner().edition(),
941941
);
942942
});
943943
document(w, cx, it, None)

src/librustdoc/passes/check_code_block_syntax.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> {
8686
// We couldn't calculate the span of the markdown block that had the error, so our
8787
// diagnostics are going to be a bit lacking.
8888
let mut diag = self.cx.sess().struct_span_warn(
89-
super::span_of_attrs(&item.attrs).unwrap_or(item.span.span()),
89+
super::span_of_attrs(&item.attrs).unwrap_or(item.span.inner()),
9090
"doc comment contains an invalid Rust code block",
9191
);
9292

@@ -110,7 +110,7 @@ impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> {
110110
impl<'a, 'tcx> DocFolder for SyntaxChecker<'a, 'tcx> {
111111
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
112112
if let Some(dox) = &item.attrs.collapsed_doc_value() {
113-
let sp = span_of_attrs(&item.attrs).unwrap_or(item.span.span());
113+
let sp = span_of_attrs(&item.attrs).unwrap_or(item.span.inner());
114114
let extra = crate::html::markdown::ExtraInfo::new_did(self.cx.tcx, item.def_id, sp);
115115
for code_block in markdown::rust_code_blocks(&dox, &extra) {
116116
self.check_rust_syntax(&item, &dox, code_block);

src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ impl LinkCollector<'_, '_> {
12261226
&ori_link.range,
12271227
&item.attrs,
12281228
)
1229-
.unwrap_or_else(|| span_of_attrs(&item.attrs).unwrap_or(item.span.span()));
1229+
.unwrap_or_else(|| span_of_attrs(&item.attrs).unwrap_or(item.span.inner()));
12301230

12311231
rustc_session::parse::feature_err(
12321232
&self.cx.tcx.sess.parse_sess,
@@ -1691,7 +1691,7 @@ fn report_diagnostic(
16911691
};
16921692

16931693
let attrs = &item.attrs;
1694-
let sp = span_of_attrs(attrs).unwrap_or(item.span.span());
1694+
let sp = span_of_attrs(attrs).unwrap_or(item.span.inner());
16951695

16961696
tcx.struct_span_lint_hir(lint, hir_id, sp, |lint| {
16971697
let mut diag = lint.build(msg);

src/librustdoc/passes/doc_test_lints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
9797
if tests.found_tests == 0 && cx.tcx.sess.is_nightly_build() {
9898
if should_have_doc_example(cx, &item) {
9999
debug!("reporting error for {:?} (hir_id={:?})", item, hir_id);
100-
let sp = span_of_attrs(&item.attrs).unwrap_or(item.span.span());
100+
let sp = span_of_attrs(&item.attrs).unwrap_or(item.span.inner());
101101
cx.tcx.struct_span_lint_hir(
102102
crate::lint::MISSING_DOC_CODE_EXAMPLES,
103103
hir_id,
@@ -109,7 +109,7 @@ crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
109109
cx.tcx.struct_span_lint_hir(
110110
crate::lint::PRIVATE_DOC_TESTS,
111111
hir_id,
112-
span_of_attrs(&item.attrs).unwrap_or(item.span.span()),
112+
span_of_attrs(&item.attrs).unwrap_or(item.span.inner()),
113113
|lint| lint.build("documentation test in private item").emit(),
114114
);
115115
}

src/librustdoc/passes/html_tags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'a, 'tcx> DocFolder for InvalidHtmlTagsLinter<'a, 'tcx> {
181181
let sp = match super::source_span_for_markdown_range(tcx, &dox, range, &item.attrs)
182182
{
183183
Some(sp) => sp,
184-
None => span_of_attrs(&item.attrs).unwrap_or(item.span.span()),
184+
None => span_of_attrs(&item.attrs).unwrap_or(item.span.inner()),
185185
};
186186
tcx.struct_span_lint_hir(crate::lint::INVALID_HTML_TAGS, hir_id, sp, |lint| {
187187
lint.build(msg).emit()

src/librustdoc/passes/non_autolinks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'a, 'tcx> DocFolder for NonAutolinksLinter<'a, 'tcx> {
7272
let report_diag = |cx: &DocContext<'_>, msg: &str, url: &str, range: Range<usize>| {
7373
let sp = super::source_span_for_markdown_range(cx.tcx, &dox, &range, &item.attrs)
7474
.or_else(|| span_of_attrs(&item.attrs))
75-
.unwrap_or(item.span.span());
75+
.unwrap_or(item.span.inner());
7676
cx.tcx.struct_span_lint_hir(crate::lint::NON_AUTOLINKS, hir_id, sp, |lint| {
7777
lint.build(msg)
7878
.span_suggestion(

0 commit comments

Comments
 (0)