File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -450,6 +450,8 @@ rustc_queries! {
450
450
}
451
451
}
452
452
453
+ /// A list of all bodies inside of `key`, nested bodies are always stored
454
+ /// before their parent.
453
455
query nested_bodies_within(
454
456
key: LocalDefId
455
457
) -> & ' tcx ty:: List <LocalDefId > {
Original file line number Diff line number Diff line change @@ -22,9 +22,11 @@ impl<'tcx> Visitor<'tcx> for NestedBodiesVisitor<'tcx> {
22
22
fn visit_nested_body ( & mut self , id : hir:: BodyId ) {
23
23
let body_def_id = self . tcx . hir_body_owner_def_id ( id) ;
24
24
if self . tcx . typeck_root_def_id ( body_def_id. to_def_id ( ) ) == self . root_def_id {
25
- self . nested_bodies . push ( body_def_id) ;
25
+ // We visit nested bodies before adding the current body. This
26
+ // means that nested bodies are always stored before their parent.
26
27
let body = self . tcx . hir_body ( id) ;
27
28
self . visit_body ( body) ;
29
+ self . nested_bodies . push ( body_def_id) ;
28
30
}
29
31
}
30
32
}
You can’t perform that action at this time.
0 commit comments