Skip to content

Commit b32cffe

Browse files
committed
Remove hir::Crate::attrs.
1 parent acd6014 commit b32cffe

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

clippy_lints/src/doc.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ impl_lint_pass!(DocMarkdown =>
208208
);
209209

210210
impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
211-
fn check_crate(&mut self, cx: &LateContext<'tcx>, krate: &'tcx hir::Crate<'_>) {
212-
check_attrs(cx, &self.valid_idents, &krate.item.attrs);
211+
fn check_crate(&mut self, cx: &LateContext<'tcx>, _: &'tcx hir::Crate<'_>) {
212+
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
213+
check_attrs(cx, &self.valid_idents, attrs);
213214
}
214215

215216
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {

clippy_lints/src/loops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ impl<'tcx> LateLintPass<'tcx> for Loops {
578578
// also check for empty `loop {}` statements, skipping those in #[panic_handler]
579579
if block.stmts.is_empty() && block.expr.is_none() && !is_in_panic_handler(cx, expr) {
580580
let msg = "empty `loop {}` wastes CPU cycles";
581-
let help = if is_no_std_crate(cx.tcx.hir().krate()) {
581+
let help = if is_no_std_crate(cx) {
582582
"you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body"
583583
} else {
584584
"you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body"

clippy_lints/src/main_recursion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ pub struct MainRecursion {
3232
impl_lint_pass!(MainRecursion => [MAIN_RECURSION]);
3333

3434
impl LateLintPass<'_> for MainRecursion {
35-
fn check_crate(&mut self, _: &LateContext<'_>, krate: &Crate<'_>) {
36-
self.has_no_std_attr = is_no_std_crate(krate);
35+
fn check_crate(&mut self, cx: &LateContext<'_>, _: &Crate<'_>) {
36+
self.has_no_std_attr = is_no_std_crate(cx);
3737
}
3838

3939
fn check_expr_post(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {

clippy_lints/src/missing_doc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
127127
}
128128

129129
fn check_crate(&mut self, cx: &LateContext<'tcx>, krate: &'tcx hir::Crate<'_>) {
130-
self.check_missing_docs_attrs(cx, &krate.item.attrs, krate.item.span, "the", "crate");
130+
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
131+
self.check_missing_docs_attrs(cx, attrs, krate.item.span, "the", "crate");
131132
}
132133

133134
fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {

clippy_utils/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE};
6161
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
6262
use rustc_hir::Node;
6363
use rustc_hir::{
64-
def, Arm, Block, Body, Constness, Crate, Expr, ExprKind, FnDecl, HirId, ImplItem, ImplItemKind, Item, ItemKind,
64+
def, Arm, Block, Body, Constness, Expr, ExprKind, FnDecl, HirId, ImplItem, ImplItemKind, Item, ItemKind,
6565
MatchSource, Param, Pat, PatKind, Path, PathSegment, QPath, TraitItem, TraitItemKind, TraitRef, TyKind, Unsafety,
6666
};
6767
use rustc_infer::infer::TyCtxtInferExt;
@@ -1510,8 +1510,8 @@ pub fn is_must_use_func_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
15101510
did.map_or(false, |did| must_use_attr(&cx.tcx.get_attrs(did)).is_some())
15111511
}
15121512

1513-
pub fn is_no_std_crate(krate: &Crate<'_>) -> bool {
1514-
krate.item.attrs.iter().any(|attr| {
1513+
pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
1514+
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
15151515
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
15161516
attr.path == sym::no_std
15171517
} else {

0 commit comments

Comments
 (0)