mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
WfCheck opaques.
This commit is contained in:
parent
d6f247f3d5
commit
68f7ed4495
@ -185,15 +185,16 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) -> Result<(), ErrorGuaranteed> {
|
fn check_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorGuaranteed> {
|
||||||
let node = tcx.hir_owner_node(def_id);
|
let node = tcx.hir_node_by_def_id(def_id);
|
||||||
let mut res = match node {
|
let mut res = match node {
|
||||||
hir::OwnerNode::Crate(_) => bug!("check_well_formed cannot be applied to the crate root"),
|
hir::Node::Crate(_) => bug!("check_well_formed cannot be applied to the crate root"),
|
||||||
hir::OwnerNode::Item(item) => check_item(tcx, item),
|
hir::Node::Item(item) => check_item(tcx, item),
|
||||||
hir::OwnerNode::TraitItem(item) => check_trait_item(tcx, item),
|
hir::Node::TraitItem(item) => check_trait_item(tcx, item),
|
||||||
hir::OwnerNode::ImplItem(item) => check_impl_item(tcx, item),
|
hir::Node::ImplItem(item) => check_impl_item(tcx, item),
|
||||||
hir::OwnerNode::ForeignItem(item) => check_foreign_item(tcx, item),
|
hir::Node::ForeignItem(item) => check_foreign_item(tcx, item),
|
||||||
hir::OwnerNode::Synthetic => unreachable!(),
|
hir::Node::OpaqueTy(_) => Ok(crate::check::check::check_item_type(tcx, def_id)),
|
||||||
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(generics) = node.generics() {
|
if let Some(generics) = node.generics() {
|
||||||
@ -201,6 +202,7 @@ fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) -> Result<(), ErrorG
|
|||||||
res = res.and(check_param_wf(tcx, param));
|
res = res.and(check_param_wf(tcx, param));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2172,10 +2174,14 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
|
|||||||
|
|
||||||
fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalModDefId) -> Result<(), ErrorGuaranteed> {
|
fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalModDefId) -> Result<(), ErrorGuaranteed> {
|
||||||
let items = tcx.hir_module_items(module);
|
let items = tcx.hir_module_items(module);
|
||||||
let mut res = items.par_items(|item| tcx.ensure().check_well_formed(item.owner_id));
|
let mut res = items.par_items(|item| tcx.ensure().check_well_formed(item.owner_id.def_id));
|
||||||
res = res.and(items.par_impl_items(|item| tcx.ensure().check_well_formed(item.owner_id)));
|
res =
|
||||||
res = res.and(items.par_trait_items(|item| tcx.ensure().check_well_formed(item.owner_id)));
|
res.and(items.par_impl_items(|item| tcx.ensure().check_well_formed(item.owner_id.def_id)));
|
||||||
res = res.and(items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.owner_id)));
|
res =
|
||||||
|
res.and(items.par_trait_items(|item| tcx.ensure().check_well_formed(item.owner_id.def_id)));
|
||||||
|
res = res
|
||||||
|
.and(items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.owner_id.def_id)));
|
||||||
|
res = res.and(items.par_opaques(|item| tcx.ensure().check_well_formed(item)));
|
||||||
if module == LocalModDefId::CRATE_DEF_ID {
|
if module == LocalModDefId::CRATE_DEF_ID {
|
||||||
super::entry::check_for_entry_fn(tcx);
|
super::entry::check_for_entry_fn(tcx);
|
||||||
}
|
}
|
||||||
|
@ -328,6 +328,19 @@ impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
|
|||||||
intravisit::walk_expr(self, expr);
|
intravisit::walk_expr(self, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Don't call `type_of` on opaque types, since that depends on type checking function bodies.
|
||||||
|
/// `check_item_type` ensures that it's called instead.
|
||||||
|
fn visit_opaque_ty(&mut self, opaque: &'tcx hir::OpaqueTy<'tcx>) {
|
||||||
|
let def_id = opaque.def_id;
|
||||||
|
self.tcx.ensure().generics_of(def_id);
|
||||||
|
self.tcx.ensure().predicates_of(def_id);
|
||||||
|
self.tcx.ensure().explicit_item_bounds(def_id);
|
||||||
|
self.tcx.ensure().explicit_item_super_predicates(def_id);
|
||||||
|
self.tcx.ensure().item_bounds(def_id);
|
||||||
|
self.tcx.ensure().item_super_predicates(def_id);
|
||||||
|
intravisit::walk_opaque_ty(self, opaque);
|
||||||
|
}
|
||||||
|
|
||||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
||||||
lower_trait_item(self.tcx, trait_item.trait_item_id());
|
lower_trait_item(self.tcx, trait_item.trait_item_id());
|
||||||
intravisit::walk_trait_item(self, trait_item);
|
intravisit::walk_trait_item(self, trait_item);
|
||||||
|
@ -1552,7 +1552,7 @@ rustc_queries! {
|
|||||||
feedable
|
feedable
|
||||||
}
|
}
|
||||||
|
|
||||||
query check_well_formed(key: hir::OwnerId) -> Result<(), ErrorGuaranteed> {
|
query check_well_formed(key: LocalDefId) -> Result<(), ErrorGuaranteed> {
|
||||||
desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key) }
|
desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key) }
|
||||||
ensure_forwards_result_if_red
|
ensure_forwards_result_if_red
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user