1
Fork 0

Auto merge of #88703 - cjgillot:lazymod, r=petrochenkov

Gather module items after lowering.

This avoids having a non-local analysis inside lowering.

By implementing `hir_module_items` using a visitor, we make sure that iterations and visitors are consistent.
This commit is contained in:
bors 2021-09-19 16:13:42 +00:00
commit 7b5f95270f
14 changed files with 147 additions and 83 deletions

View file

@ -58,9 +58,7 @@ pub fn impl_wf_check(tcx: TyCtxt<'_>) {
// We will tag this as part of the WF check -- logically, it is,
// but it's one that we must perform earlier than the rest of
// WfCheck.
for &module in tcx.hir().krate().modules.keys() {
tcx.ensure().check_mod_impl_wf(module);
}
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_impl_wf(module))
}
fn check_mod_impl_wf(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {

View file

@ -473,9 +473,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorReported> {
// FIXME(matthewjasper) We shouldn't need to use `track_errors`.
tcx.sess.track_errors(|| {
tcx.sess.time("type_collecting", || {
for &module in tcx.hir().krate().modules.keys() {
tcx.ensure().collect_mod_item_types(module);
}
tcx.hir().for_each_module(|module| tcx.ensure().collect_mod_item_types(module))
});
})?;
@ -505,9 +503,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorReported> {
// NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync.
tcx.sess.time("item_types_checking", || {
for &module in tcx.hir().krate().modules.keys() {
tcx.ensure().check_mod_item_types(module);
}
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
});
tcx.sess.time("item_bodies_checking", || tcx.typeck_item_bodies(()));