@@ -690,25 +690,29 @@ crate fn find_testable_code<T: doctest::Tester>(
690
690
}
691
691
692
692
crate struct ExtraInfo < ' tcx > {
693
- hir_id : Option < HirId > ,
694
- item_did : Option < DefId > ,
693
+ id : ExtraInfoId ,
695
694
sp : Span ,
696
695
tcx : TyCtxt < ' tcx > ,
697
696
}
698
697
698
+ enum ExtraInfoId {
699
+ Hir ( HirId ) ,
700
+ Def ( DefId ) ,
701
+ }
702
+
699
703
impl < ' tcx > ExtraInfo < ' tcx > {
700
704
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 }
702
706
}
703
707
704
708
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 }
706
710
}
707
711
708
712
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) => {
712
716
match item_did. as_local ( ) {
713
717
Some ( item_did) => self . tcx . hir ( ) . local_def_id_to_hir_id ( item_did) ,
714
718
None => {
@@ -717,7 +721,6 @@ impl<'tcx> ExtraInfo<'tcx> {
717
721
}
718
722
}
719
723
}
720
- ( None , None ) => return ,
721
724
} ;
722
725
self . tcx . struct_span_lint_hir (
723
726
crate :: lint:: INVALID_CODEBLOCK_ATTRIBUTES ,
0 commit comments