Split out the Generator case from DefKind::Closure.

This commit is contained in:
Eduard-Mihai Burtescu 2020-04-17 16:55:08 +03:00 committed by mark
parent cff5b998e0
commit d1db782dff
5 changed files with 12 additions and 6 deletions

View File

@ -88,6 +88,7 @@ pub enum DefKind {
GlobalAsm,
Impl,
Closure,
Generator,
}
impl DefKind {
@ -131,6 +132,7 @@ impl DefKind {
DefKind::Field => "field",
DefKind::Impl => "implementation",
DefKind::Closure => "closure",
DefKind::Generator => "generator",
DefKind::ExternCrate => "extern crate",
DefKind::GlobalAsm => "global assembly block",
}
@ -184,6 +186,7 @@ impl DefKind {
| DefKind::LifetimeParam
| DefKind::ExternCrate
| DefKind::Closure
| DefKind::Generator
| DefKind::Use
| DefKind::ForeignMod
| DefKind::GlobalAsm

View File

@ -592,7 +592,7 @@ impl EntryKind {
EntryKind::ForeignMod => DefKind::ForeignMod,
EntryKind::GlobalAsm => DefKind::GlobalAsm,
EntryKind::Field => DefKind::Field,
EntryKind::Generator(_) => DefKind::Closure,
EntryKind::Generator(_) => DefKind::Generator,
}
}
}

View File

@ -285,7 +285,8 @@ impl<'hir> Map<'hir> {
Node::AnonConst(_) => DefKind::AnonConst,
Node::Field(_) => DefKind::Field,
Node::Expr(expr) => match expr.kind {
ExprKind::Closure { .. } => DefKind::Closure,
ExprKind::Closure(.., None) => DefKind::Closure,
ExprKind::Closure(.., Some(_)) => DefKind::Generator,
_ => bug!("def_kind: unsupported node: {}", self.node_to_string(hir_id)),
},
Node::MacroDef(_) => DefKind::Macro(MacroKind::Bang),

View File

@ -613,8 +613,8 @@ impl EmbargoVisitor<'tcx> {
}
}
// These have type privacy or are not namespaced, so are not reachable unless they're
// public.
// These have type privacy, so are not reachable unless they're
// public, or are not namespaced at all.
DefKind::AssocConst
| DefKind::AssocTy
| DefKind::AssocOpaqueTy
@ -636,7 +636,8 @@ impl EmbargoVisitor<'tcx> {
| DefKind::Field
| DefKind::GlobalAsm
| DefKind::Impl
| DefKind::Closure => (),
| DefKind::Closure
| DefKind::Generator => (),
}
}

View File

@ -771,7 +771,8 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
| HirDefKind::Field
| HirDefKind::GlobalAsm
| HirDefKind::Impl
| HirDefKind::Closure,
| HirDefKind::Closure
| HirDefKind::Generator,
_,
)
| Res::PrimTy(..)