@@ -48,7 +48,7 @@ use rustc_errors::ErrorReported;
48
48
use rustc_hir as hir;
49
49
use rustc_hir:: def:: { DefKind , Res } ;
50
50
use 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 } ;
52
52
use rustc_hir:: lang_items;
53
53
use rustc_hir:: lang_items:: PanicLocationLangItem ;
54
54
use rustc_hir:: { HirId , Node , TraitCandidate } ;
@@ -1492,21 +1492,13 @@ impl<'tcx> TyCtxt<'tcx> {
1492
1492
1493
1493
/// Returns a displayable description and article for the given `def_id` (e.g. `("a", "struct")`).
1494
1494
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
+ }
1510
1502
}
1511
1503
}
1512
1504
0 commit comments