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! {
450450 }
451451 }
452452
453+ /// A list of all bodies inside of `key`, nested bodies are always stored
454+ /// before their parent.
453455 query nested_bodies_within(
454456 key: LocalDefId
455457 ) -> & ' 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> {
2222 fn visit_nested_body ( & mut self , id : hir:: BodyId ) {
2323 let body_def_id = self . tcx . hir_body_owner_def_id ( id) ;
2424 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.
2627 let body = self . tcx . hir_body ( id) ;
2728 self . visit_body ( body) ;
29+ self . nested_bodies . push ( body_def_id) ;
2830 }
2931 }
3032}
You can’t perform that action at this time.
0 commit comments