@@ -48,7 +48,7 @@ use rustc_errors::ErrorReported;
4848use rustc_hir as hir;
4949use rustc_hir:: def:: { DefKind , Res } ;
5050use rustc_hir:: def_id:: { CrateNum , DefId , DefIdMap , DefIdSet , LocalDefId , LOCAL_CRATE } ;
51- use rustc_hir:: definitions:: { DefPathData , DefPathHash , Definitions } ;
51+ use rustc_hir:: definitions:: { DefPathHash , Definitions } ;
5252use rustc_hir:: lang_items;
5353use rustc_hir:: lang_items:: PanicLocationLangItem ;
5454use rustc_hir:: { HirId , Node , TraitCandidate } ;
@@ -1492,21 +1492,13 @@ impl<'tcx> TyCtxt<'tcx> {
14921492
14931493 /// Returns a displayable description and article for the given `def_id` (e.g. `("a", "struct")`).
14941494 pub fn article_and_description ( & self , def_id : DefId ) -> ( & ' static str , & ' static str ) {
1495- self . def_kind ( def_id)
1496- . map ( |def_kind| ( def_kind. article ( ) , def_kind. descr ( def_id) ) )
1497- . unwrap_or_else ( || match self . def_key ( def_id) . disambiguated_data . data {
1498- DefPathData :: ClosureExpr => match self . generator_kind ( def_id) {
1499- None => ( "a" , "closure" ) ,
1500- Some ( rustc_hir:: GeneratorKind :: Async ( ..) ) => ( "an" , "async closure" ) ,
1501- Some ( rustc_hir:: GeneratorKind :: Gen ) => ( "a" , "generator" ) ,
1502- } ,
1503- DefPathData :: LifetimeNs ( ..) => ( "a" , "lifetime" ) ,
1504- DefPathData :: Impl => ( "an" , "implementation" ) ,
1505- DefPathData :: TypeNs ( ..) | DefPathData :: ValueNs ( ..) | DefPathData :: MacroNs ( ..) => {
1506- unreachable ! ( )
1507- }
1508- _ => bug ! ( "article_and_description called on def_id {:?}" , def_id) ,
1509- } )
1495+ match self . def_kind ( def_id) {
1496+ DefKind :: Generator => match self . generator_kind ( def_id) . unwrap ( ) {
1497+ rustc_hir:: GeneratorKind :: Async ( ..) => ( "an" , "async closure" ) ,
1498+ rustc_hir:: GeneratorKind :: Gen => ( "a" , "generator" ) ,
1499+ } ,
1500+ def_kind => ( def_kind. article ( ) , def_kind. descr ( def_id) ) ,
1501+ }
15101502 }
15111503}
15121504
0 commit comments