@@ -358,15 +358,15 @@ fn is_field_vis_inherited(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
358
358
359
359
impl Item {
360
360
pub ( crate ) fn stability < ' tcx > ( & self , tcx : TyCtxt < ' tcx > ) -> Option < Stability > {
361
- self . item_id . as_def_id ( ) . and_then ( |did| tcx. lookup_stability ( did) )
361
+ self . def_id ( ) . and_then ( |did| tcx. lookup_stability ( did) )
362
362
}
363
363
364
364
pub ( crate ) fn const_stability < ' tcx > ( & self , tcx : TyCtxt < ' tcx > ) -> Option < ConstStability > {
365
- self . item_id . as_def_id ( ) . and_then ( |did| tcx. lookup_const_stability ( did) )
365
+ self . def_id ( ) . and_then ( |did| tcx. lookup_const_stability ( did) )
366
366
}
367
367
368
368
pub ( crate ) fn deprecation ( & self , tcx : TyCtxt < ' _ > ) -> Option < Deprecation > {
369
- self . item_id . as_def_id ( ) . and_then ( |did| tcx. lookup_deprecation ( did) )
369
+ self . def_id ( ) . and_then ( |did| tcx. lookup_deprecation ( did) )
370
370
}
371
371
372
372
pub ( crate ) fn inner_docs ( & self , tcx : TyCtxt < ' _ > ) -> bool {
@@ -391,7 +391,7 @@ impl Item {
391
391
panic ! ( "blanket impl item has non-blanket ID" )
392
392
}
393
393
}
394
- _ => self . item_id . as_def_id ( ) . map ( |did| rustc_span ( did, tcx) ) ,
394
+ _ => self . def_id ( ) . map ( |did| rustc_span ( did, tcx) ) ,
395
395
}
396
396
}
397
397
@@ -501,7 +501,7 @@ impl Item {
501
501
}
502
502
503
503
pub ( crate ) fn is_crate ( & self ) -> bool {
504
- self . is_mod ( ) && self . item_id . as_def_id ( ) . map_or ( false , |did| did. is_crate_root ( ) )
504
+ self . is_mod ( ) && self . def_id ( ) . map_or ( false , |did| did. is_crate_root ( ) )
505
505
}
506
506
pub ( crate ) fn is_mod ( & self ) -> bool {
507
507
self . type_ ( ) == ItemType :: Module
@@ -638,11 +638,11 @@ impl Item {
638
638
}
639
639
let header = match * self . kind {
640
640
ItemKind :: ForeignFunctionItem ( _) => {
641
- let def_id = self . item_id . as_def_id ( ) . unwrap ( ) ;
641
+ let def_id = self . def_id ( ) . unwrap ( ) ;
642
642
let abi = tcx. fn_sig ( def_id) . skip_binder ( ) . abi ( ) ;
643
643
hir:: FnHeader {
644
644
unsafety : if abi == Abi :: RustIntrinsic {
645
- intrinsic_operation_unsafety ( tcx, self . item_id . as_def_id ( ) . unwrap ( ) )
645
+ intrinsic_operation_unsafety ( tcx, self . def_id ( ) . unwrap ( ) )
646
646
} else {
647
647
hir:: Unsafety :: Unsafe
648
648
} ,
@@ -659,7 +659,7 @@ impl Item {
659
659
}
660
660
}
661
661
ItemKind :: FunctionItem ( _) | ItemKind :: MethodItem ( _, _) | ItemKind :: TyMethodItem ( _) => {
662
- let def_id = self . item_id . as_def_id ( ) . unwrap ( ) ;
662
+ let def_id = self . def_id ( ) . unwrap ( ) ;
663
663
build_fn_header ( def_id, tcx, tcx. asyncness ( def_id) )
664
664
}
665
665
_ => return None ,
@@ -738,7 +738,7 @@ impl Item {
738
738
}
739
739
} )
740
740
. collect ( ) ;
741
- if let Some ( def_id) = self . item_id . as_def_id ( ) &&
741
+ if let Some ( def_id) = self . def_id ( ) &&
742
742
!def_id. is_local ( ) &&
743
743
// This check is needed because `adt_def` will panic if not a compatible type otherwise...
744
744
matches ! ( self . type_( ) , ItemType :: Struct | ItemType :: Enum | ItemType :: Union )
@@ -787,6 +787,10 @@ impl Item {
787
787
pub fn is_doc_hidden ( & self ) -> bool {
788
788
self . attrs . is_doc_hidden ( )
789
789
}
790
+
791
+ pub fn def_id ( & self ) -> Option < DefId > {
792
+ self . item_id . as_def_id ( )
793
+ }
790
794
}
791
795
792
796
#[ derive( Clone , Debug ) ]
0 commit comments