about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-06-20 04:14:20 +0000
committerbors <bors@rust-lang.org>2023-06-20 04:14:20 +0000
commit89294e1756309da6e5ea0056222c19a09898af2c (patch)
tree2734fa2f98beca4b9456b70e19d8e1524900d3a3
parent5b60388e5a0979c03da1d3cd170fbd0b7ade6156 (diff)
parent62c9e0b87d5cb08f2c7e8ab00cbb8dcf64324b37 (diff)
downloadrust-89294e1756309da6e5ea0056222c19a09898af2c.tar.gz
rust-89294e1756309da6e5ea0056222c19a09898af2c.zip
Auto merge of #10992 - blyxyas:fix-test_case_lib, r=Manishearth
`items_after_test_module`: Ignore in-proc-macros items

The library `test-case` is having some problems with this lint, ignoring proc macros should fix it.
Related to #10713 and frondeus/test-case#122

(Couldn't add test cases for this exact situation without importing the library, but I think the fix is simple enough that we can be pretty sure there won't be any problems :) )

changelog:[`items_after_test_module`]: Ignore items in procedural macros
-rw-r--r--clippy_lints/src/items_after_test_module.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/clippy_lints/src/items_after_test_module.rs b/clippy_lints/src/items_after_test_module.rs
index b992d689aa9..40378ee8205 100644
--- a/clippy_lints/src/items_after_test_module.rs
+++ b/clippy_lints/src/items_after_test_module.rs
@@ -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;
@@ -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");