Skip to content

Commit faa7d42

Browse files
committed
Do not pass hir::Crate to lints.
1 parent abc57f6 commit faa7d42

17 files changed

+32
-33
lines changed

compiler/rustc_lint/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
584584
self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
585585
}
586586

587-
fn check_crate(&mut self, cx: &LateContext<'_>, _: &hir::Crate<'_>) {
587+
fn check_crate(&mut self, cx: &LateContext<'_>) {
588588
self.check_missing_docs_attrs(
589589
cx,
590590
CRATE_DEF_ID,

compiler/rustc_lint/src/late.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,6 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx>>(
430430
fn late_lint_pass_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, pass: T) {
431431
let access_levels = &tcx.privacy_access_levels(());
432432

433-
let krate = tcx.hir().krate();
434-
435433
let context = LateContext {
436434
tcx,
437435
enclosing_body: None,
@@ -450,10 +448,10 @@ fn late_lint_pass_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, pass: T)
450448
cx.with_lint_attrs(hir::CRATE_HIR_ID, |cx| {
451449
// since the root module isn't visited as an item (because it isn't an
452450
// item), warn for it here.
453-
lint_callback!(cx, check_crate, krate);
451+
lint_callback!(cx, check_crate,);
454452
tcx.hir().walk_toplevel_module(cx);
455453
tcx.hir().walk_attributes(cx);
456-
lint_callback!(cx, check_crate_post, krate);
454+
lint_callback!(cx, check_crate_post,);
457455
})
458456
}
459457

compiler/rustc_lint/src/passes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ macro_rules! late_lint_methods {
1616
fn check_body(a: &$hir hir::Body<$hir>);
1717
fn check_body_post(a: &$hir hir::Body<$hir>);
1818
fn check_name(a: Span, b: Symbol);
19-
fn check_crate(a: &$hir hir::Crate<$hir>);
20-
fn check_crate_post(a: &$hir hir::Crate<$hir>);
19+
fn check_crate();
20+
fn check_crate_post();
2121
fn check_mod(a: &$hir hir::Mod<$hir>, b: Span, c: hir::HirId);
2222
fn check_mod_post(a: &$hir hir::Mod<$hir>, b: Span, c: hir::HirId);
2323
fn check_foreign_item(a: &$hir hir::ForeignItem<$hir>);

compiler/rustc_middle/src/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl<'hir> Map<'hir> {
164164
}
165165
}
166166

167-
crate fn items(&self) -> impl Iterator<Item = &'hir Item<'hir>> + 'hir {
167+
pub fn items(&self) -> impl Iterator<Item = &'hir Item<'hir>> + 'hir {
168168
let krate = self.krate();
169169
krate.owners.iter().filter_map(|owner| match owner.as_ref()? {
170170
OwnerNode::Item(item) => Some(*item),

src/tools/clippy/clippy_lints/src/cargo_common_metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! lint on missing cargo common metadata
22
33
use clippy_utils::{diagnostics::span_lint, is_lint_allowed};
4-
use rustc_hir::{hir_id::CRATE_HIR_ID, Crate};
4+
use rustc_hir::hir_id::CRATE_HIR_ID;
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_session::{declare_tool_lint, impl_lint_pass};
77
use rustc_span::source_map::DUMMY_SP;
@@ -77,7 +77,7 @@ fn is_empty_vec(value: &[String]) -> bool {
7777
}
7878

7979
impl LateLintPass<'_> for CargoCommonMetadata {
80-
fn check_crate(&mut self, cx: &LateContext<'_>, _: &Crate<'_>) {
80+
fn check_crate(&mut self, cx: &LateContext<'_>) {
8181
if is_lint_allowed(cx, CARGO_COMMON_METADATA, CRATE_HIR_ID) {
8282
return;
8383
}

src/tools/clippy/clippy_lints/src/disallowed_method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::fn_def_id;
33

4-
use rustc_hir::{def::Res, def_id::DefIdMap, Crate, Expr};
4+
use rustc_hir::{def::Res, def_id::DefIdMap, Expr};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_session::{declare_tool_lint, impl_lint_pass};
77

@@ -70,7 +70,7 @@ impl DisallowedMethod {
7070
impl_lint_pass!(DisallowedMethod => [DISALLOWED_METHOD]);
7171

7272
impl<'tcx> LateLintPass<'tcx> for DisallowedMethod {
73-
fn check_crate(&mut self, cx: &LateContext<'_>, _: &Crate<'_>) {
73+
fn check_crate(&mut self, cx: &LateContext<'_>) {
7474
for conf in &self.conf_disallowed {
7575
let (path, reason) = match conf {
7676
conf::DisallowedMethod::Simple(path) => (path, None),

src/tools/clippy/clippy_lints/src/disallowed_type.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint;
22

33
use rustc_data_structures::fx::FxHashSet;
44
use rustc_hir::{
5-
def::Res, def_id::DefId, Crate, Item, ItemKind, PolyTraitRef, PrimTy, TraitBoundModifier, Ty, TyKind, UseKind,
5+
def::Res, def_id::DefId, Item, ItemKind, PolyTraitRef, PrimTy, TraitBoundModifier, Ty, TyKind, UseKind,
66
};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -75,7 +75,7 @@ impl DisallowedType {
7575
impl_lint_pass!(DisallowedType => [DISALLOWED_TYPE]);
7676

7777
impl<'tcx> LateLintPass<'tcx> for DisallowedType {
78-
fn check_crate(&mut self, cx: &LateContext<'_>, _: &Crate<'_>) {
78+
fn check_crate(&mut self, cx: &LateContext<'_>) {
7979
for path in &self.disallowed {
8080
let segs = path.iter().map(ToString::to_string).collect::<Vec<_>>();
8181
match clippy_utils::path_to_res(cx, &segs.iter().map(String::as_str).collect::<Vec<_>>()) {

src/tools/clippy/clippy_lints/src/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl_lint_pass!(DocMarkdown =>
212212
);
213213

214214
impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
215-
fn check_crate(&mut self, cx: &LateContext<'tcx>, _: &'tcx hir::Crate<'_>) {
215+
fn check_crate(&mut self, cx: &LateContext<'tcx>) {
216216
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
217217
check_attrs(cx, &self.valid_idents, attrs);
218218
}

src/tools/clippy/clippy_lints/src/feature_name.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::{diagnostics::span_lint, is_lint_allowed};
3-
use rustc_hir::{Crate, CRATE_HIR_ID};
3+
use rustc_hir::CRATE_HIR_ID;
44
use rustc_lint::{LateContext, LateLintPass};
55
use rustc_session::{declare_lint_pass, declare_tool_lint};
66
use rustc_span::source_map::DUMMY_SP;
@@ -110,7 +110,7 @@ fn lint(cx: &LateContext<'_>, feature: &str, substring: &str, is_prefix: bool) {
110110
}
111111

112112
impl LateLintPass<'_> for FeatureName {
113-
fn check_crate(&mut self, cx: &LateContext<'_>, _: &Crate<'_>) {
113+
fn check_crate(&mut self, cx: &LateContext<'_>) {
114114
if is_lint_allowed(cx, REDUNDANT_FEATURE_NAMES, CRATE_HIR_ID)
115115
&& is_lint_allowed(cx, NEGATIVE_FEATURE_NAMES, CRATE_HIR_ID)
116116
{

src/tools/clippy/clippy_lints/src/inherent_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use clippy_utils::diagnostics::span_lint_and_note;
44
use clippy_utils::{in_macro, is_lint_allowed};
55
use rustc_data_structures::fx::FxHashMap;
6-
use rustc_hir::{def_id::LocalDefId, Crate, Item, ItemKind, Node};
6+
use rustc_hir::{def_id::LocalDefId, Item, ItemKind, Node};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
99
use rustc_span::Span;
@@ -44,7 +44,7 @@ declare_clippy_lint! {
4444
declare_lint_pass!(MultipleInherentImpl => [MULTIPLE_INHERENT_IMPL]);
4545

4646
impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
47-
fn check_crate_post(&mut self, cx: &LateContext<'tcx>, _: &'tcx Crate<'_>) {
47+
fn check_crate_post(&mut self, cx: &LateContext<'tcx>) {
4848
// Map from a type to it's first impl block. Needed to distinguish generic arguments.
4949
// e.g. `Foo<Bar>` and `Foo<Baz>`
5050
let mut type_map = FxHashMap::default();

0 commit comments

Comments
 (0)