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())
|
||||
}
|
||||
|
||||
crate fn dummy() -> Self {
|
||||
Self(rustc_span::DUMMY_SP)
|
||||
crate fn inner(&self) -> rustc_span::Span {
|
||||
self.0
|
||||
}
|
||||
|
||||
crate fn span(&self) -> rustc_span::Span {
|
||||
self.0
|
||||
crate fn dummy() -> Self {
|
||||
Self(rustc_span::DUMMY_SP)
|
||||
}
|
||||
|
||||
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"),
|
||||
None,
|
||||
None,
|
||||
it.span.span().edition(),
|
||||
it.span.inner().edition(),
|
||||
);
|
||||
});
|
||||
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
|
||||
// diagnostics are going to be a bit lacking.
|
||||
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",
|
||||
);
|
||||
|
||||
|
@ -110,7 +110,7 @@ impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> {
|
|||
impl<'a, 'tcx> DocFolder for SyntaxChecker<'a, 'tcx> {
|
||||
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
|
||||
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);
|
||||
for code_block in markdown::rust_code_blocks(&dox, &extra) {
|
||||
self.check_rust_syntax(&item, &dox, code_block);
|
||||
|
|
|
@ -1226,7 +1226,7 @@ impl LinkCollector<'_, '_> {
|
|||
&ori_link.range,
|
||||
&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(
|
||||
&self.cx.tcx.sess.parse_sess,
|
||||
|
@ -1691,7 +1691,7 @@ fn report_diagnostic(
|
|||
};
|
||||
|
||||
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| {
|
||||
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 should_have_doc_example(cx, &item) {
|
||||
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(
|
||||
crate::lint::MISSING_DOC_CODE_EXAMPLES,
|
||||
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(
|
||||
crate::lint::PRIVATE_DOC_TESTS,
|
||||
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(),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
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| {
|
||||
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 sp = super::source_span_for_markdown_range(cx.tcx, &dox, &range, &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| {
|
||||
lint.build(msg)
|
||||
.span_suggestion(
|
||||
|
|
Loading…
Add table
Reference in a new issue