@@ -358,15 +358,15 @@ fn is_field_vis_inherited(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
358358
359359impl Item {
360360 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) )
362362 }
363363
364364 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) )
366366 }
367367
368368 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) )
370370 }
371371
372372 pub ( crate ) fn inner_docs ( & self , tcx : TyCtxt < ' _ > ) -> bool {
@@ -391,7 +391,7 @@ impl Item {
391391 panic ! ( "blanket impl item has non-blanket ID" )
392392 }
393393 }
394- _ => self . item_id . as_def_id ( ) . map ( |did| rustc_span ( did, tcx) ) ,
394+ _ => self . def_id ( ) . map ( |did| rustc_span ( did, tcx) ) ,
395395 }
396396 }
397397
@@ -501,7 +501,7 @@ impl Item {
501501 }
502502
503503 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 ( ) )
505505 }
506506 pub ( crate ) fn is_mod ( & self ) -> bool {
507507 self . type_ ( ) == ItemType :: Module
@@ -638,11 +638,11 @@ impl Item {
638638 }
639639 let header = match * self . kind {
640640 ItemKind :: ForeignFunctionItem ( _) => {
641- let def_id = self . item_id . as_def_id ( ) . unwrap ( ) ;
641+ let def_id = self . def_id ( ) . unwrap ( ) ;
642642 let abi = tcx. fn_sig ( def_id) . skip_binder ( ) . abi ( ) ;
643643 hir:: FnHeader {
644644 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 ( ) )
646646 } else {
647647 hir:: Unsafety :: Unsafe
648648 } ,
@@ -659,7 +659,7 @@ impl Item {
659659 }
660660 }
661661 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 ( ) ;
663663 build_fn_header ( def_id, tcx, tcx. asyncness ( def_id) )
664664 }
665665 _ => return None ,
@@ -738,7 +738,7 @@ impl Item {
738738 }
739739 } )
740740 . collect ( ) ;
741- if let Some ( def_id) = self . item_id . as_def_id ( ) &&
741+ if let Some ( def_id) = self . def_id ( ) &&
742742 !def_id. is_local ( ) &&
743743 // This check is needed because `adt_def` will panic if not a compatible type otherwise...
744744 matches ! ( self . type_( ) , ItemType :: Struct | ItemType :: Enum | ItemType :: Union )
@@ -787,6 +787,10 @@ impl Item {
787787 pub fn is_doc_hidden ( & self ) -> bool {
788788 self . attrs . is_doc_hidden ( )
789789 }
790+
791+ pub fn def_id ( & self ) -> Option < DefId > {
792+ self . item_id . as_def_id ( )
793+ }
790794}
791795
792796#[ derive( Clone , Debug ) ]
0 commit comments