Skip to content

Commit 61468ad

Browse files
committed
use find_parent_node get parent node
1 parent 5e6de23 commit 61468ad

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

compiler/rustc_passes/src/hir_id_validator.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
143143
});
144144
}
145145

146+
if let Some(owner_hir_id) = self.hir_map.find_parent_node(hir_id) &&
147+
owner_hir_id.local_id >= hir_id.local_id && hir_id.local_id != ItemLocalId::from_u32(0) {
148+
self.error(|| {
149+
format!(
150+
"HirIdValidator: The local_id {} 's parent local_id {} is not smaller than children",
151+
self.hir_map.node_to_string(hir_id),
152+
self.hir_map.node_to_string(owner_hir_id),
153+
)
154+
});
155+
}
146156
self.hir_ids_seen.insert(hir_id.local_id);
147157
}
148158

0 commit comments

Comments
 (0)