Skip to content

Commit de258cc

Browse files
committed
Fix is_test_module_or_function
1 parent 898baf8 commit de258cc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clippy_utils/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,8 +2505,9 @@ fn with_test_item_names(tcx: TyCtxt<'_>, module: LocalModDefId, f: impl Fn(&[Sym
25052505
/// Note: Add `//@compile-flags: --test` to UI tests with a `#[test]` function
25062506
pub fn is_in_test_function(tcx: TyCtxt<'_>, id: HirId) -> bool {
25072507
with_test_item_names(tcx, tcx.parent_module(id), |names| {
2508-
tcx.hir()
2509-
.parent_iter(id)
2508+
let node = tcx.hir_node(id);
2509+
once((id, node))
2510+
.chain(tcx.hir().parent_iter(id))
25102511
// Since you can nest functions we need to collect all until we leave
25112512
// function scope
25122513
.any(|(_id, node)| {

0 commit comments

Comments
 (0)