mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
Fix is_test_module_or_function
This commit is contained in:
parent
898baf81cd
commit
de258cc6be
1 changed files with 3 additions and 2 deletions
|
@ -2505,8 +2505,9 @@ fn with_test_item_names(tcx: TyCtxt<'_>, module: LocalModDefId, f: impl Fn(&[Sym
|
|||
/// Note: Add `//@compile-flags: --test` to UI tests with a `#[test]` function
|
||||
pub fn is_in_test_function(tcx: TyCtxt<'_>, id: HirId) -> bool {
|
||||
with_test_item_names(tcx, tcx.parent_module(id), |names| {
|
||||
tcx.hir()
|
||||
.parent_iter(id)
|
||||
let node = tcx.hir_node(id);
|
||||
once((id, node))
|
||||
.chain(tcx.hir().parent_iter(id))
|
||||
// Since you can nest functions we need to collect all until we leave
|
||||
// function scope
|
||||
.any(|(_id, node)| {
|
||||
|
|
Loading…
Add table
Reference in a new issue