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".
This commit is contained in:
parent
8b9b106cdc
commit
7dd475e498
7 changed files with 13 additions and 13 deletions
|
@ -1866,12 +1866,12 @@ impl Span {
|
||||||
Self(sp.source_callsite())
|
Self(sp.source_callsite())
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn dummy() -> Self {
|
crate fn inner(&self) -> rustc_span::Span {
|
||||||
Self(rustc_span::DUMMY_SP)
|
self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn span(&self) -> rustc_span::Span {
|
crate fn dummy() -> Self {
|
||||||
self.0
|
Self(rustc_span::DUMMY_SP)
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn is_dummy(&self) -> bool {
|
crate fn is_dummy(&self) -> bool {
|
||||||
|
|
|
@ -937,7 +937,7 @@ fn item_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Mac
|
||||||
Some("macro"),
|
Some("macro"),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
it.span.span().edition(),
|
it.span.inner().edition(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
document(w, cx, it, None)
|
document(w, cx, it, None)
|
||||||
|
|
|
@ -86,7 +86,7 @@ impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> {
|
||||||
// We couldn't calculate the span of the markdown block that had the error, so our
|
// We couldn't calculate the span of the markdown block that had the error, so our
|
||||||
// diagnostics are going to be a bit lacking.
|
// diagnostics are going to be a bit lacking.
|
||||||
let mut diag = self.cx.sess().struct_span_warn(
|
let mut diag = self.cx.sess().struct_span_warn(
|
||||||
super::span_of_attrs(&item.attrs).unwrap_or(item.span.span()),
|
super::span_of_attrs(&item.attrs).unwrap_or(item.span.inner()),
|
||||||
"doc comment contains an invalid Rust code block",
|
"doc comment contains an invalid Rust code block",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> {
|
||||||
impl<'a, 'tcx> DocFolder for SyntaxChecker<'a, 'tcx> {
|
impl<'a, 'tcx> DocFolder for SyntaxChecker<'a, 'tcx> {
|
||||||
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
|
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
|
||||||
if let Some(dox) = &item.attrs.collapsed_doc_value() {
|
if let Some(dox) = &item.attrs.collapsed_doc_value() {
|
||||||
let sp = span_of_attrs(&item.attrs).unwrap_or(item.span.span());
|
let sp = span_of_attrs(&item.attrs).unwrap_or(item.span.inner());
|
||||||
let extra = crate::html::markdown::ExtraInfo::new_did(self.cx.tcx, item.def_id, sp);
|
let extra = crate::html::markdown::ExtraInfo::new_did(self.cx.tcx, item.def_id, sp);
|
||||||
for code_block in markdown::rust_code_blocks(&dox, &extra) {
|
for code_block in markdown::rust_code_blocks(&dox, &extra) {
|
||||||
self.check_rust_syntax(&item, &dox, code_block);
|
self.check_rust_syntax(&item, &dox, code_block);
|
||||||
|
|
|
@ -1226,7 +1226,7 @@ impl LinkCollector<'_, '_> {
|
||||||
&ori_link.range,
|
&ori_link.range,
|
||||||
&item.attrs,
|
&item.attrs,
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|| span_of_attrs(&item.attrs).unwrap_or(item.span.span()));
|
.unwrap_or_else(|| span_of_attrs(&item.attrs).unwrap_or(item.span.inner()));
|
||||||
|
|
||||||
rustc_session::parse::feature_err(
|
rustc_session::parse::feature_err(
|
||||||
&self.cx.tcx.sess.parse_sess,
|
&self.cx.tcx.sess.parse_sess,
|
||||||
|
@ -1691,7 +1691,7 @@ fn report_diagnostic(
|
||||||
};
|
};
|
||||||
|
|
||||||
let attrs = &item.attrs;
|
let attrs = &item.attrs;
|
||||||
let sp = span_of_attrs(attrs).unwrap_or(item.span.span());
|
let sp = span_of_attrs(attrs).unwrap_or(item.span.inner());
|
||||||
|
|
||||||
tcx.struct_span_lint_hir(lint, hir_id, sp, |lint| {
|
tcx.struct_span_lint_hir(lint, hir_id, sp, |lint| {
|
||||||
let mut diag = lint.build(msg);
|
let mut diag = lint.build(msg);
|
||||||
|
|
|
@ -97,7 +97,7 @@ crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
|
||||||
if tests.found_tests == 0 && cx.tcx.sess.is_nightly_build() {
|
if tests.found_tests == 0 && cx.tcx.sess.is_nightly_build() {
|
||||||
if should_have_doc_example(cx, &item) {
|
if should_have_doc_example(cx, &item) {
|
||||||
debug!("reporting error for {:?} (hir_id={:?})", item, hir_id);
|
debug!("reporting error for {:?} (hir_id={:?})", item, hir_id);
|
||||||
let sp = span_of_attrs(&item.attrs).unwrap_or(item.span.span());
|
let sp = span_of_attrs(&item.attrs).unwrap_or(item.span.inner());
|
||||||
cx.tcx.struct_span_lint_hir(
|
cx.tcx.struct_span_lint_hir(
|
||||||
crate::lint::MISSING_DOC_CODE_EXAMPLES,
|
crate::lint::MISSING_DOC_CODE_EXAMPLES,
|
||||||
hir_id,
|
hir_id,
|
||||||
|
@ -109,7 +109,7 @@ crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
|
||||||
cx.tcx.struct_span_lint_hir(
|
cx.tcx.struct_span_lint_hir(
|
||||||
crate::lint::PRIVATE_DOC_TESTS,
|
crate::lint::PRIVATE_DOC_TESTS,
|
||||||
hir_id,
|
hir_id,
|
||||||
span_of_attrs(&item.attrs).unwrap_or(item.span.span()),
|
span_of_attrs(&item.attrs).unwrap_or(item.span.inner()),
|
||||||
|lint| lint.build("documentation test in private item").emit(),
|
|lint| lint.build("documentation test in private item").emit(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ impl<'a, 'tcx> DocFolder for InvalidHtmlTagsLinter<'a, 'tcx> {
|
||||||
let sp = match super::source_span_for_markdown_range(tcx, &dox, range, &item.attrs)
|
let sp = match super::source_span_for_markdown_range(tcx, &dox, range, &item.attrs)
|
||||||
{
|
{
|
||||||
Some(sp) => sp,
|
Some(sp) => sp,
|
||||||
None => span_of_attrs(&item.attrs).unwrap_or(item.span.span()),
|
None => span_of_attrs(&item.attrs).unwrap_or(item.span.inner()),
|
||||||
};
|
};
|
||||||
tcx.struct_span_lint_hir(crate::lint::INVALID_HTML_TAGS, hir_id, sp, |lint| {
|
tcx.struct_span_lint_hir(crate::lint::INVALID_HTML_TAGS, hir_id, sp, |lint| {
|
||||||
lint.build(msg).emit()
|
lint.build(msg).emit()
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl<'a, 'tcx> DocFolder for NonAutolinksLinter<'a, 'tcx> {
|
||||||
let report_diag = |cx: &DocContext<'_>, msg: &str, url: &str, range: Range<usize>| {
|
let report_diag = |cx: &DocContext<'_>, msg: &str, url: &str, range: Range<usize>| {
|
||||||
let sp = super::source_span_for_markdown_range(cx.tcx, &dox, &range, &item.attrs)
|
let sp = super::source_span_for_markdown_range(cx.tcx, &dox, &range, &item.attrs)
|
||||||
.or_else(|| span_of_attrs(&item.attrs))
|
.or_else(|| span_of_attrs(&item.attrs))
|
||||||
.unwrap_or(item.span.span());
|
.unwrap_or(item.span.inner());
|
||||||
cx.tcx.struct_span_lint_hir(crate::lint::NON_AUTOLINKS, hir_id, sp, |lint| {
|
cx.tcx.struct_span_lint_hir(crate::lint::NON_AUTOLINKS, hir_id, sp, |lint| {
|
||||||
lint.build(msg)
|
lint.build(msg)
|
||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue