diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 4db20817e641..7237b50d8f39 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1525,6 +1525,8 @@ impl<'tcx> TyCtxt<'tcx> { Some(rustc_hir::GeneratorKind::Async(..)) => ("an", "async closure"), Some(rustc_hir::GeneratorKind::Gen) => ("a", "generator"), }, + DefPathData::LifetimeNs(..) => ("a", "lifetime"), + DefPathData::Impl => ("an", "implementation"), _ => bug!("article_and_description called on def_id {:?}", def_id), } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 2b85cba90039..869a1dcbcc7a 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -2148,9 +2148,10 @@ fn static_mutability(tcx: TyCtxt<'_>, def_id: DefId) -> Option fn generator_kind(tcx: TyCtxt<'_>, def_id: DefId) -> Option { match tcx.hir().get_if_local(def_id) { - Some(Node::Item(&hir::Item { kind: hir::ItemKind::Fn(_, _, body_id), .. })) => { - tcx.hir().body(body_id).generator_kind() - } + Some(Node::Expr(&rustc_hir::Expr { + kind: rustc_hir::ExprKind::Closure(_, _, body_id, _, _), + .. + })) => tcx.hir().body(body_id).generator_kind(), Some(_) => None, _ => bug!("generator_kind applied to non-local def-id {:?}", def_id), }