Skip to content

Commit b463c09

Browse files
committed
Move items_after_test_module logic into check_crate
1 parent 331d01e commit b463c09

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

clippy_lints/src/items_after_test_module.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::{is_from_proc_macro, is_in_cfg_test};
3-
use rustc_hir::{HirId, ItemId, ItemKind, Mod};
3+
use rustc_hir::{ItemId, ItemKind};
44
use rustc_lint::{LateContext, LateLintPass, LintContext};
55
use rustc_middle::lint::in_external_macro;
66
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -42,7 +42,7 @@ declare_clippy_lint! {
4242
declare_lint_pass!(ItemsAfterTestModule => [ITEMS_AFTER_TEST_MODULE]);
4343

4444
impl LateLintPass<'_> for ItemsAfterTestModule {
45-
fn check_mod(&mut self, cx: &LateContext<'_>, _: &Mod<'_>, _: HirId) {
45+
fn check_crate(&mut self, cx: &LateContext<'_>) {
4646
let mut was_test_mod_visited = false;
4747
let mut test_mod_span: Option<Span> = None;
4848

tests/ui/items_after_test_module/block_module.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@compile-flags: --test
21
#![allow(unused)]
32
#![warn(clippy::items_after_test_module)]
43

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
1-
error: Option 'test' given more than once
1+
error: items were found after the testing module
2+
--> $DIR/block_module.rs:12:1
3+
|
4+
LL | / mod tests {
5+
LL | | #[test]
6+
LL | | fn hi() {}
7+
LL | | }
8+
... |
9+
LL | | () => {};
10+
LL | | }
11+
| |_^
12+
|
13+
= help: move the items to before the testing module was defined
14+
= note: `-D clippy::items-after-test-module` implied by `-D warnings`
15+
= help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]`
16+
17+
error: aborting due to previous error
218

0 commit comments

Comments
 (0)