Skip to content

Commit d1db782

Browse files
eddybmark-i-m
authored andcommitted
Split out the Generator case from DefKind::Closure.
1 parent cff5b99 commit d1db782

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

src/librustc_hir/def.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub enum DefKind {
8888
GlobalAsm,
8989
Impl,
9090
Closure,
91+
Generator,
9192
}
9293

9394
impl DefKind {
@@ -131,6 +132,7 @@ impl DefKind {
131132
DefKind::Field => "field",
132133
DefKind::Impl => "implementation",
133134
DefKind::Closure => "closure",
135+
DefKind::Generator => "generator",
134136
DefKind::ExternCrate => "extern crate",
135137
DefKind::GlobalAsm => "global assembly block",
136138
}
@@ -184,6 +186,7 @@ impl DefKind {
184186
| DefKind::LifetimeParam
185187
| DefKind::ExternCrate
186188
| DefKind::Closure
189+
| DefKind::Generator
187190
| DefKind::Use
188191
| DefKind::ForeignMod
189192
| DefKind::GlobalAsm

src/librustc_metadata/rmeta/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ impl EntryKind {
592592
EntryKind::ForeignMod => DefKind::ForeignMod,
593593
EntryKind::GlobalAsm => DefKind::GlobalAsm,
594594
EntryKind::Field => DefKind::Field,
595-
EntryKind::Generator(_) => DefKind::Closure,
595+
EntryKind::Generator(_) => DefKind::Generator,
596596
}
597597
}
598598
}

src/librustc_middle/hir/map/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ impl<'hir> Map<'hir> {
285285
Node::AnonConst(_) => DefKind::AnonConst,
286286
Node::Field(_) => DefKind::Field,
287287
Node::Expr(expr) => match expr.kind {
288-
ExprKind::Closure { .. } => DefKind::Closure,
288+
ExprKind::Closure(.., None) => DefKind::Closure,
289+
ExprKind::Closure(.., Some(_)) => DefKind::Generator,
289290
_ => bug!("def_kind: unsupported node: {}", self.node_to_string(hir_id)),
290291
},
291292
Node::MacroDef(_) => DefKind::Macro(MacroKind::Bang),

src/librustc_privacy/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ impl EmbargoVisitor<'tcx> {
613613
}
614614
}
615615

616-
// These have type privacy or are not namespaced, so are not reachable unless they're
617-
// public.
616+
// These have type privacy, so are not reachable unless they're
617+
// public, or are not namespaced at all.
618618
DefKind::AssocConst
619619
| DefKind::AssocTy
620620
| DefKind::AssocOpaqueTy
@@ -636,7 +636,8 @@ impl EmbargoVisitor<'tcx> {
636636
| DefKind::Field
637637
| DefKind::GlobalAsm
638638
| DefKind::Impl
639-
| DefKind::Closure => (),
639+
| DefKind::Closure
640+
| DefKind::Generator => (),
640641
}
641642
}
642643

src/librustc_save_analysis/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,8 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
771771
| HirDefKind::Field
772772
| HirDefKind::GlobalAsm
773773
| HirDefKind::Impl
774-
| HirDefKind::Closure,
774+
| HirDefKind::Closure
775+
| HirDefKind::Generator,
775776
_,
776777
)
777778
| Res::PrimTy(..)

0 commit comments

Comments
 (0)