@@ -690,38 +690,35 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
690690 // }
691691 // ```
692692 if let Some ( anon_node_id) = tcx. hir . as_local_node_id ( def_id) {
693- let anon_parent_def_id = match tcx. hir . expect_item ( anon_node_id) . node {
693+ let in_definition_scope = match tcx. hir . expect_item ( anon_node_id) . node {
694694 // impl trait
695695 hir:: ItemKind :: Existential ( hir:: ExistTy {
696696 impl_trait_fn : Some ( parent) ,
697697 ..
698- } ) => parent,
698+ } ) => parent == self . parent_def_id ,
699699 // named existential types
700700 hir:: ItemKind :: Existential ( hir:: ExistTy {
701701 impl_trait_fn : None ,
702702 ..
703- } ) if may_define_existential_type (
703+ } ) => may_define_existential_type (
704704 tcx,
705705 self . parent_def_id ,
706706 anon_node_id,
707- ) => {
708- return self . fold_anon_ty ( ty, def_id, substs) ;
709- } ,
707+ ) ,
710708 _ => {
711709 let anon_parent_node_id = tcx. hir . get_parent ( anon_node_id) ;
712- tcx. hir . local_def_id ( anon_parent_node_id)
710+ self . parent_def_id == tcx. hir . local_def_id ( anon_parent_node_id)
713711 } ,
714712 } ;
715- if self . parent_def_id == anon_parent_def_id {
713+ if in_definition_scope {
716714 return self . fold_anon_ty ( ty, def_id, substs) ;
717715 }
718716
719717 debug ! (
720718 "instantiate_anon_types_in_map: \
721- encountered anon with wrong parent \
722- def_id={:?} \
723- anon_parent_def_id={:?}",
724- def_id, anon_parent_def_id
719+ encountered anon outside it's definition scope \
720+ def_id={:?}",
721+ def_id,
725722 ) ;
726723 }
727724 }
0 commit comments