From 616482e4c5c35be3c250374d9adf6ef14865f749 Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Sat, 5 Feb 2022 22:36:14 +0100 Subject: [PATCH] Add note explaining `OnlyBodies` filter better --- compiler/rustc_middle/src/hir/nested_filter.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_middle/src/hir/nested_filter.rs b/compiler/rustc_middle/src/hir/nested_filter.rs index 7cfb20745720d..48efae8045bdd 100644 --- a/compiler/rustc_middle/src/hir/nested_filter.rs +++ b/compiler/rustc_middle/src/hir/nested_filter.rs @@ -3,6 +3,10 @@ use rustc_hir::intravisit::nested_filter::NestedFilter; /// Do not visit nested item-like things, but visit nested things /// that are inside of an item-like. /// +/// Notably, possible occurrences of bodies in non-item-like things +/// include: closures/generators, inline `const {}` blocks, and +/// constant arguments of types, e.g. in `let _: [(); /* HERE */];`. +/// /// **This is the most common choice.** A very common pattern is /// to use `visit_all_item_likes()` as an outer loop, /// and to have the visitor that visits the contents of each item