Skip to content

Commit a3993c5

Browse files
committed
change order of nested_bodies_within
1 parent 269d5b5 commit a3993c5

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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> {

compiler/rustc_ty_utils/src/nested_bodies.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)