提交 7dd475e4 编写于 作者: C Camelid

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".
上级 8b9b106c
......@@ -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 @@ fn check_rust_syntax(&self, item: &clean::Item, dox: &str, code_block: RustCodeB
// 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 @@ fn check_rust_syntax(&self, item: &clean::Item, dox: &str, code_block: RustCodeB
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 @@ fn resolve_link(
&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 @@ fn add_test(&mut self, _: String, config: LangString, _: usize) {
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 @@ fn add_test(&mut self, _: String, config: LangString, _: usize) {
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 @@ fn fold_item(&mut self, item: Item) -> Option<Item> {
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 @@ fn fold_item(&mut self, item: Item) -> Option<Item> {
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(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册