Skip to content

Commit fba38a9

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

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
@@ -287,7 +287,8 @@ impl<'hir> Map<'hir> {
287287
Node::AnonConst(_) => DefKind::AnonConst,
288288
Node::Field(_) => DefKind::Field,
289289
Node::Expr(expr) => match expr.kind {
290-
ExprKind::Closure { .. } => DefKind::Closure,
290+
ExprKind::Closure(.., None) => DefKind::Closure,
291+
ExprKind::Closure(.., Some(_)) => DefKind::Generator,
291292
_ => bug!("def_kind: unsupported node: {}", self.node_to_string(hir_id)),
292293
},
293294
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
@@ -611,8 +611,8 @@ impl EmbargoVisitor<'tcx> {
611611
}
612612
}
613613

614-
// These have type privacy or are not namespaced, so are not reachable unless they're
615-
// public.
614+
// These have type privacy, so are not reachable unless they're
615+
// public, or are not namespaced at all.
616616
DefKind::AssocConst
617617
| DefKind::AssocTy
618618
| DefKind::AssocOpaqueTy
@@ -634,7 +634,8 @@ impl EmbargoVisitor<'tcx> {
634634
| DefKind::Field
635635
| DefKind::GlobalAsm
636636
| DefKind::Impl
637-
| DefKind::Closure => (),
637+
| DefKind::Closure
638+
| DefKind::Generator => (),
638639
}
639640
}
640641

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)