Avoid more invocations of hir_crate query.

This commit is contained in:
Camille GILLOT 2021-09-12 01:11:22 +02:00
parent 23d5457e6d
commit 3037c40e9a

View File

@ -78,9 +78,7 @@ fn check_missing_docs_attrs(
return;
}
let has_doc = attrs
.iter()
.any(|a| a.doc_str().is_some());
let has_doc = attrs.iter().any(|a| a.doc_str().is_some());
if !has_doc {
span_lint(
cx,
@ -104,9 +102,9 @@ fn exit_lint_attrs(&mut self, _: &LateContext<'tcx>, _: &'tcx [ast::Attribute])
self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
}
fn check_crate(&mut self, cx: &LateContext<'tcx>, krate: &'tcx hir::Crate<'_>) {
fn check_crate(&mut self, cx: &LateContext<'tcx>, _: &'tcx hir::Crate<'_>) {
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
self.check_missing_docs_attrs(cx, attrs, krate.module().inner, "the", "crate");
self.check_missing_docs_attrs(cx, attrs, cx.tcx.hir().root_module().inner, "the", "crate");
}
fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {