@@ -925,6 +925,7 @@ pub(crate) struct TagIterator<'a, 'tcx> {
925925 data : & ' a str ,
926926 is_in_attribute_block : bool ,
927927 extra : Option < & ' a ExtraInfo < ' tcx > > ,
928+ is_error : bool ,
928929}
929930
930931#[ derive( Clone , Debug , Eq , PartialEq ) ]
@@ -951,13 +952,20 @@ struct Indices {
951952
952953impl < ' a , ' tcx > TagIterator < ' a , ' tcx > {
953954 pub ( crate ) fn new ( data : & ' a str , extra : Option < & ' a ExtraInfo < ' tcx > > ) -> Self {
954- Self { inner : data. char_indices ( ) . peekable ( ) , data, is_in_attribute_block : false , extra }
955+ Self {
956+ inner : data. char_indices ( ) . peekable ( ) ,
957+ data,
958+ is_in_attribute_block : false ,
959+ extra,
960+ is_error : false ,
961+ }
955962 }
956963
957- fn emit_error ( & self , err : impl Into < DiagMessage > ) {
964+ fn emit_error ( & mut self , err : impl Into < DiagMessage > ) {
958965 if let Some ( extra) = self . extra {
959966 extra. error_invalid_codeblock_attr ( err) ;
960967 }
968+ self . is_error = true ;
961969 }
962970
963971 fn skip_separators ( & mut self ) -> Option < usize > {
@@ -1155,6 +1163,9 @@ impl<'a, 'tcx> Iterator for TagIterator<'a, 'tcx> {
11551163 type Item = LangStringToken < ' a > ;
11561164
11571165 fn next ( & mut self ) -> Option < Self :: Item > {
1166+ if self . is_error {
1167+ return None ;
1168+ }
11581169 let Some ( start) = self . skip_separators ( ) else {
11591170 if self . is_in_attribute_block {
11601171 self . emit_error ( "unclosed attribute block (`{}`): missing `}` at the end" ) ;
@@ -1343,14 +1354,15 @@ impl LangString {
13431354 }
13441355 } ;
13451356
1346- call ( & mut TagIterator :: new ( string, extra) ) ;
1357+ let mut tag_iter = TagIterator :: new ( string, extra) ;
1358+ call ( & mut tag_iter) ;
13471359
13481360 // ignore-foo overrides ignore
13491361 if !ignores. is_empty ( ) {
13501362 data. ignore = Ignore :: Some ( ignores) ;
13511363 }
13521364
1353- data. rust &= !seen_custom_tag && ( !seen_other_tags || seen_rust_tags) ;
1365+ data. rust &= !seen_custom_tag && ( !seen_other_tags || seen_rust_tags) && !tag_iter . is_error ;
13541366
13551367 data
13561368 }
0 commit comments