@@ -690,25 +690,29 @@ crate fn find_testable_code<T: doctest::Tester>(
690690}
691691
692692crate struct ExtraInfo < ' tcx > {
693- hir_id : Option < HirId > ,
694- item_did : Option < DefId > ,
693+ id : ExtraInfoId ,
695694 sp : Span ,
696695 tcx : TyCtxt < ' tcx > ,
697696}
698697
698+ enum ExtraInfoId {
699+ Hir ( HirId ) ,
700+ Def ( DefId ) ,
701+ }
702+
699703impl < ' tcx > ExtraInfo < ' tcx > {
700704 crate fn new ( tcx : TyCtxt < ' tcx > , hir_id : HirId , sp : Span ) -> ExtraInfo < ' tcx > {
701- ExtraInfo { hir_id : Some ( hir_id) , item_did : None , sp, tcx }
705+ ExtraInfo { id : ExtraInfoId :: Hir ( hir_id) , sp, tcx }
702706 }
703707
704708 crate fn new_did ( tcx : TyCtxt < ' tcx > , did : DefId , sp : Span ) -> ExtraInfo < ' tcx > {
705- ExtraInfo { hir_id : None , item_did : Some ( did) , sp, tcx }
709+ ExtraInfo { id : ExtraInfoId :: Def ( did) , sp, tcx }
706710 }
707711
708712 fn error_invalid_codeblock_attr ( & self , msg : & str , help : & str ) {
709- let hir_id = match ( self . hir_id , self . item_did ) {
710- ( Some ( h ) , _ ) => h ,
711- ( None , Some ( item_did) ) => {
713+ let hir_id = match self . id {
714+ ExtraInfoId :: Hir ( hir_id ) => hir_id ,
715+ ExtraInfoId :: Def ( item_did) => {
712716 match item_did. as_local ( ) {
713717 Some ( item_did) => self . tcx . hir ( ) . local_def_id_to_hir_id ( item_did) ,
714718 None => {
@@ -717,7 +721,6 @@ impl<'tcx> ExtraInfo<'tcx> {
717721 }
718722 }
719723 }
720- ( None , None ) => return ,
721724 } ;
722725 self . tcx . struct_span_lint_hir (
723726 crate :: lint:: INVALID_CODEBLOCK_ATTRIBUTES ,
0 commit comments