Unconditionally encode hidden types in typeck results
This commit is contained in:
parent
43c22af267
commit
5d15beb591
4 changed files with 43 additions and 47 deletions
|
@ -536,33 +536,29 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
let opaque_types =
|
||||
self.fcx.infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
|
||||
for (opaque_type_key, decl) in opaque_types {
|
||||
let hidden_type = match decl.origin {
|
||||
hir::OpaqueTyOrigin::FnReturn(_) | hir::OpaqueTyOrigin::AsyncFn(_) => {
|
||||
let ty = self.resolve(decl.hidden_type.ty, &decl.hidden_type.span);
|
||||
struct RecursionChecker {
|
||||
def_id: LocalDefId,
|
||||
}
|
||||
impl<'tcx> ty::TypeVisitor<'tcx> for RecursionChecker {
|
||||
type BreakTy = ();
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let ty::Opaque(def_id, _) = *t.kind() {
|
||||
if def_id == self.def_id.to_def_id() {
|
||||
return ControlFlow::Break(());
|
||||
}
|
||||
}
|
||||
t.super_visit_with(self)
|
||||
let hidden_type = self.resolve(decl.hidden_type.ty, &decl.hidden_type.span);
|
||||
|
||||
struct RecursionChecker {
|
||||
def_id: LocalDefId,
|
||||
}
|
||||
impl<'tcx> ty::TypeVisitor<'tcx> for RecursionChecker {
|
||||
type BreakTy = ();
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let ty::Opaque(def_id, _) = *t.kind() {
|
||||
if def_id == self.def_id.to_def_id() {
|
||||
return ControlFlow::Break(());
|
||||
}
|
||||
}
|
||||
if ty
|
||||
.visit_with(&mut RecursionChecker { def_id: opaque_type_key.def_id })
|
||||
.is_break()
|
||||
{
|
||||
return;
|
||||
}
|
||||
Some(ty)
|
||||
t.super_visit_with(self)
|
||||
}
|
||||
hir::OpaqueTyOrigin::TyAlias => None,
|
||||
};
|
||||
}
|
||||
if hidden_type
|
||||
.visit_with(&mut RecursionChecker { def_id: opaque_type_key.def_id })
|
||||
.is_break()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
self.typeck_results.concrete_opaque_types.insert(opaque_type_key.def_id, hidden_type);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue