Skip to content

Commit

Permalink
Simplify defining scope logic
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jul 18, 2018
1 parent 41b0315 commit 8c1b0d7
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/librustc/infer/anon_types/mod.rs
Expand Up @@ -690,38 +690,35 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
// }
// ```
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,
);
}
}
Expand Down

0 comments on commit 8c1b0d7

Please sign in to comment.