@@ -924,6 +924,7 @@ pub(crate) struct TagIterator<'a, 'tcx> {
924924 data : & ' a str ,
925925 is_in_attribute_block : bool ,
926926 extra : Option < & ' a ExtraInfo < ' tcx > > ,
927+ is_error : bool ,
927928}
928929
929930#[ derive( Clone , Debug , Eq , PartialEq ) ]
@@ -950,13 +951,20 @@ struct Indices {
950951
951952impl < ' a , ' tcx > TagIterator < ' a , ' tcx > {
952953 pub ( crate ) fn new ( data : & ' a str , extra : Option < & ' a ExtraInfo < ' tcx > > ) -> Self {
953- Self { inner : data. char_indices ( ) . peekable ( ) , data, is_in_attribute_block : false , extra }
954+ Self {
955+ inner : data. char_indices ( ) . peekable ( ) ,
956+ data,
957+ is_in_attribute_block : false ,
958+ extra,
959+ is_error : false ,
960+ }
954961 }
955962
956- fn emit_error ( & self , err : impl Into < DiagMessage > ) {
963+ fn emit_error ( & mut self , err : impl Into < DiagMessage > ) {
957964 if let Some ( extra) = self . extra {
958965 extra. error_invalid_codeblock_attr ( err) ;
959966 }
967+ self . is_error = true ;
960968 }
961969
962970 fn skip_separators ( & mut self ) -> Option < usize > {
@@ -1154,6 +1162,9 @@ impl<'a, 'tcx> Iterator for TagIterator<'a, 'tcx> {
11541162 type Item = LangStringToken < ' a > ;
11551163
11561164 fn next ( & mut self ) -> Option < Self :: Item > {
1165+ if self . is_error {
1166+ return None ;
1167+ }
11571168 let Some ( start) = self . skip_separators ( ) else {
11581169 if self . is_in_attribute_block {
11591170 self . emit_error ( "unclosed attribute block (`{}`): missing `}` at the end" ) ;
@@ -1342,14 +1353,15 @@ impl LangString {
13421353 }
13431354 } ;
13441355
1345- call ( & mut TagIterator :: new ( string, extra) ) ;
1356+ let mut tag_iter = TagIterator :: new ( string, extra) ;
1357+ call ( & mut tag_iter) ;
13461358
13471359 // ignore-foo overrides ignore
13481360 if !ignores. is_empty ( ) {
13491361 data. ignore = Ignore :: Some ( ignores) ;
13501362 }
13511363
1352- data. rust &= !seen_custom_tag && ( !seen_other_tags || seen_rust_tags) ;
1364+ data. rust &= !seen_custom_tag && ( !seen_other_tags || seen_rust_tags) && !tag_iter . is_error ;
13531365
13541366 data
13551367 }
0 commit comments