@@ -690,38 +690,35 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
690
690
// }
691
691
// ```
692
692
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 {
694
694
// impl trait
695
695
hir:: ItemKind :: Existential ( hir:: ExistTy {
696
696
impl_trait_fn : Some ( parent) ,
697
697
..
698
- } ) => parent,
698
+ } ) => parent == self . parent_def_id ,
699
699
// named existential types
700
700
hir:: ItemKind :: Existential ( hir:: ExistTy {
701
701
impl_trait_fn : None ,
702
702
..
703
- } ) if may_define_existential_type (
703
+ } ) => may_define_existential_type (
704
704
tcx,
705
705
self . parent_def_id ,
706
706
anon_node_id,
707
- ) => {
708
- return self . fold_anon_ty ( ty, def_id, substs) ;
709
- } ,
707
+ ) ,
710
708
_ => {
711
709
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)
713
711
} ,
714
712
} ;
715
- if self . parent_def_id == anon_parent_def_id {
713
+ if in_definition_scope {
716
714
return self . fold_anon_ty ( ty, def_id, substs) ;
717
715
}
718
716
719
717
debug ! (
720
718
"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,
725
722
) ;
726
723
}
727
724
}
0 commit comments