Skip to content

Commit

Permalink
Ignore in-proc-macros items
Browse files Browse the repository at this point in the history
  • Loading branch information
blyxyas authored and flip1995 committed Jul 6, 2023
1 parent cbadffc commit 8cde275
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tools/clippy/clippy_lints/src/items_after_test_module.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clippy_utils::{diagnostics::span_lint_and_help, is_in_cfg_test};
use clippy_utils::{diagnostics::span_lint_and_help, is_from_proc_macro, is_in_cfg_test};
use rustc_hir::{HirId, ItemId, ItemKind, Mod};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
Expand Down Expand Up @@ -59,6 +59,7 @@ impl LateLintPass<'_> for ItemsAfterTestModule {
if !matches!(item.kind, ItemKind::Mod(_));
if !is_in_cfg_test(cx.tcx, itid.hir_id()); // The item isn't in the testing module itself
if !in_external_macro(cx.sess(), item.span);
if !is_from_proc_macro(cx, item);

then {
span_lint_and_help(cx, ITEMS_AFTER_TEST_MODULE, test_mod_span.unwrap().with_hi(item.span.hi()), "items were found after the testing module", None, "move the items to before the testing module was defined");
Expand Down

0 comments on commit 8cde275

Please sign in to comment.