1
Fork 0

Perform wf checking per module.

This commit is contained in:
Camille GILLOT 2021-05-10 12:18:55 +02:00
parent 42289ff931
commit 86290effd5
5 changed files with 19 additions and 10 deletions

View file

@ -826,6 +826,10 @@ rustc_queries! {
desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) }
}
query check_mod_type_wf(key: LocalDefId) -> () {
desc { |tcx| "checking that types are well-formed in {}", describe_as_module(key, tcx) }
}
query collect_mod_item_types(key: LocalDefId) -> () {
desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
}

View file

@ -99,8 +99,6 @@ pub use expectation::Expectation;
pub use fn_ctxt::*;
use hir::def::CtorOf;
pub use inherited::{Inherited, InheritedBuilder};
use wfcheck::check_well_formed;
pub(crate) use wfcheck::check_wf_new;
use crate::astconv::AstConv;
use crate::check::gather_locals::GatherLocalsVisitor;
@ -243,6 +241,7 @@ impl<'tcx> EnclosingBreakables<'tcx> {
pub fn provide(providers: &mut Providers) {
method::provide(providers);
wfcheck::provide(providers);
*providers = Providers {
typeck_item_bodies,
typeck_const_arg,
@ -251,7 +250,6 @@ pub fn provide(providers: &mut Providers) {
has_typeck_results,
adt_destructor,
used_trait_imports,
check_well_formed,
check_mod_item_types,
region_scope_tree,
..*providers

View file

@ -14,6 +14,7 @@ use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::infer::outlives::obligations::TypeOutlives;
use rustc_infer::infer::region_constraints::GenericKind;
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts, Subst};
use rustc_middle::ty::trait_def::TraitSpecializationKind;
use rustc_middle::ty::{
@ -67,7 +68,7 @@ impl<'tcx> CheckWfFcxBuilder<'tcx> {
}
}
pub(crate) fn check_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
fn check_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
let node = tcx.hir().expect_owner(def_id);
match node {
hir::OwnerNode::Crate(_) => {}
@ -1858,8 +1859,8 @@ fn check_false_global_bounds(fcx: &FnCtxt<'_, '_>, mut span: Span, id: hir::HirI
fcx.select_all_obligations_or_error();
}
pub(crate) fn check_wf_new(tcx: TyCtxt<'_>) {
let items = tcx.hir_crate_items(());
fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalDefId) {
let items = tcx.hir_module_items(module);
par_for_each_in(items.items(), |item| tcx.ensure().check_well_formed(item.def_id));
par_for_each_in(items.impl_items(), |item| tcx.ensure().check_well_formed(item.def_id));
par_for_each_in(items.trait_items(), |item| tcx.ensure().check_well_formed(item.def_id));
@ -1948,3 +1949,7 @@ fn error_392(
err.span_label(span, "unused parameter");
err
}
pub fn provide(providers: &mut Providers) {
*providers = Providers { check_mod_type_wf, check_well_formed, ..*providers };
}

View file

@ -525,7 +525,9 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
}
tcx.sess.track_errors(|| {
tcx.sess.time("wf_checking", || check::check_wf_new(tcx));
tcx.sess.time("wf_checking", || {
tcx.hir().par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module))
});
})?;
// NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync.