]> git.lizzy.rs Git - rust.git/commitdiff
Simplify defining scope logic
authorOliver Schneider <github35764891676564198441@oli-obk.de>
Tue, 17 Jul 2018 09:21:10 +0000 (11:21 +0200)
committerOliver Schneider <github35764891676564198441@oli-obk.de>
Wed, 18 Jul 2018 08:53:10 +0000 (10:53 +0200)
src/librustc/infer/anon_types/mod.rs

index 8cc8abda70800ae54b48a71147ee1ffb1e318937..2cb47c7beb53a852973835bfe497d562453ed099 100644 (file)
@@ -690,38 +690,35 @@ fn instantiate_anon_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: &T) ->
                     // }
                     // ```
                     if let Some(anon_node_id) = tcx.hir.as_local_node_id(def_id) {
-                        let anon_parent_def_id = match tcx.hir.expect_item(anon_node_id).node {
+                        let in_definition_scope = match tcx.hir.expect_item(anon_node_id).node {
                             // impl trait
                             hir::ItemKind::Existential(hir::ExistTy {
                                 impl_trait_fn: Some(parent),
                                 ..
-                            }) => parent,
+                            }) => parent == self.parent_def_id,
                             // named existential types
                             hir::ItemKind::Existential(hir::ExistTy {
                                 impl_trait_fn: None,
                                 ..
-                            }) if may_define_existential_type(
+                            }) => may_define_existential_type(
                                 tcx,
                                 self.parent_def_id,
                                 anon_node_id,
-                            ) => {
-                                return self.fold_anon_ty(ty, def_id, substs);
-                            },
+                            ),
                             _ => {
                                 let anon_parent_node_id = tcx.hir.get_parent(anon_node_id);
-                                tcx.hir.local_def_id(anon_parent_node_id)
+                                self.parent_def_id == tcx.hir.local_def_id(anon_parent_node_id)
                             },
                         };
-                        if self.parent_def_id == anon_parent_def_id {
+                        if in_definition_scope {
                             return self.fold_anon_ty(ty, def_id, substs);
                         }
 
                         debug!(
                             "instantiate_anon_types_in_map: \
-                             encountered anon with wrong parent \
-                             def_id={:?} \
-                             anon_parent_def_id={:?}",
-                            def_id, anon_parent_def_id
+                             encountered anon outside it's definition scope \
+                             def_id={:?}",
+                            def_id,
                         );
                     }
                 }