borrowck typeck children together with their parent
This commit is contained in:
parent
e643f59f6d
commit
f05a23be5c
19 changed files with 335 additions and 217 deletions
|
@ -397,8 +397,11 @@ fn best_definition_site_of_opaque<'tcx>(
|
|||
return ControlFlow::Continue(());
|
||||
}
|
||||
|
||||
if let Some(hidden_ty) =
|
||||
self.tcx.mir_borrowck(item_def_id).concrete_opaque_types.get(&self.opaque_def_id)
|
||||
if let Some(hidden_ty) = self
|
||||
.tcx
|
||||
.mir_borrowck(item_def_id)
|
||||
.ok()
|
||||
.and_then(|opaque_types| opaque_types.0.get(&self.opaque_def_id))
|
||||
{
|
||||
ControlFlow::Break((hidden_ty.span, item_def_id))
|
||||
} else {
|
||||
|
@ -413,9 +416,6 @@ fn best_definition_site_of_opaque<'tcx>(
|
|||
self.tcx
|
||||
}
|
||||
fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) -> Self::Result {
|
||||
if let hir::ExprKind::Closure(closure) = ex.kind {
|
||||
self.check(closure.def_id)?;
|
||||
}
|
||||
intravisit::walk_expr(self, ex)
|
||||
}
|
||||
fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) -> Self::Result {
|
||||
|
|
|
@ -183,25 +183,23 @@ impl<'tcx> TaitConstraintLocator<'tcx> {
|
|||
self.non_defining_use_in_defining_scope(item_def_id);
|
||||
}
|
||||
}
|
||||
DefiningScopeKind::MirBorrowck => {
|
||||
let borrowck_result = tcx.mir_borrowck(item_def_id);
|
||||
if let Some(guar) = borrowck_result.tainted_by_errors {
|
||||
self.insert_found(ty::OpaqueHiddenType::new_error(tcx, guar));
|
||||
} else if let Some(&hidden_type) =
|
||||
borrowck_result.concrete_opaque_types.get(&self.def_id)
|
||||
{
|
||||
debug!(?hidden_type, "found constraint");
|
||||
self.insert_found(hidden_type);
|
||||
} else if let Err(guar) = tcx
|
||||
.type_of_opaque_hir_typeck(self.def_id)
|
||||
.instantiate_identity()
|
||||
.error_reported()
|
||||
{
|
||||
self.insert_found(ty::OpaqueHiddenType::new_error(tcx, guar));
|
||||
} else {
|
||||
self.non_defining_use_in_defining_scope(item_def_id);
|
||||
DefiningScopeKind::MirBorrowck => match tcx.mir_borrowck(item_def_id) {
|
||||
Err(guar) => self.insert_found(ty::OpaqueHiddenType::new_error(tcx, guar)),
|
||||
Ok(concrete_opaque_types) => {
|
||||
if let Some(&hidden_type) = concrete_opaque_types.0.get(&self.def_id) {
|
||||
debug!(?hidden_type, "found constraint");
|
||||
self.insert_found(hidden_type);
|
||||
} else if let Err(guar) = tcx
|
||||
.type_of_opaque_hir_typeck(self.def_id)
|
||||
.instantiate_identity()
|
||||
.error_reported()
|
||||
{
|
||||
self.insert_found(ty::OpaqueHiddenType::new_error(tcx, guar));
|
||||
} else {
|
||||
self.non_defining_use_in_defining_scope(item_def_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -264,20 +262,20 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
|
|||
Ty::new_diverging_default(tcx)
|
||||
}
|
||||
}
|
||||
DefiningScopeKind::MirBorrowck => {
|
||||
let borrowck_result = tcx.mir_borrowck(owner_def_id);
|
||||
if let Some(guar) = borrowck_result.tainted_by_errors {
|
||||
Ty::new_error(tcx, guar)
|
||||
} else if let Some(hidden_ty) = borrowck_result.concrete_opaque_types.get(&def_id) {
|
||||
hidden_ty.ty
|
||||
} else {
|
||||
let hir_ty = tcx.type_of_opaque_hir_typeck(def_id).instantiate_identity();
|
||||
if let Err(guar) = hir_ty.error_reported() {
|
||||
Ty::new_error(tcx, guar)
|
||||
DefiningScopeKind::MirBorrowck => match tcx.mir_borrowck(owner_def_id) {
|
||||
Ok(concrete_opaque_types) => {
|
||||
if let Some(hidden_ty) = concrete_opaque_types.0.get(&def_id) {
|
||||
hidden_ty.ty
|
||||
} else {
|
||||
hir_ty
|
||||
let hir_ty = tcx.type_of_opaque_hir_typeck(def_id).instantiate_identity();
|
||||
if let Err(guar) = hir_ty.error_reported() {
|
||||
Ty::new_error(tcx, guar)
|
||||
} else {
|
||||
hir_ty
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(guar) => Ty::new_error(tcx, guar),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue