Skip to content

Commit

Permalink
Move items_after_test_module logic into check_crate
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexendoo committed Oct 4, 2023
1 parent 331d01e commit b463c09
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/items_after_test_module.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::{is_from_proc_macro, is_in_cfg_test};
use rustc_hir::{HirId, ItemId, ItemKind, Mod};
use rustc_hir::{ItemId, ItemKind};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};
Expand Down Expand Up @@ -42,7 +42,7 @@ declare_clippy_lint! {
declare_lint_pass!(ItemsAfterTestModule => [ITEMS_AFTER_TEST_MODULE]);

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

Expand Down
1 change: 0 additions & 1 deletion tests/ui/items_after_test_module/block_module.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@compile-flags: --test
#![allow(unused)]
#![warn(clippy::items_after_test_module)]

Expand Down
18 changes: 17 additions & 1 deletion tests/ui/items_after_test_module/block_module.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
error: Option 'test' given more than once
error: items were found after the testing module
--> $DIR/block_module.rs:12:1
|
LL | / mod tests {
LL | | #[test]
LL | | fn hi() {}
LL | | }
... |
LL | | () => {};
LL | | }
| |_^
|
= help: move the items to before the testing module was defined
= note: `-D clippy::items-after-test-module` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]`

error: aborting due to previous error

0 comments on commit b463c09

Please sign in to comment.