File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -599,14 +599,16 @@ impl Cursor<'_> {
599599            if  potential_closing. is_none ( )  { 
600600                // a less fortunate recovery if all else fails which finds any dashes preceded by whitespace 
601601                // on a standalone line. Might be wrong. 
602+                 let  mut  base_index = 0 ; 
602603                while  let  Some ( closing)  = rest. find ( "---" )  { 
603604                    let  preceding_chars_start = rest[ ..closing] . rfind ( "\n " ) . map_or ( 0 ,  |i| i + 1 ) ; 
604605                    if  rest[ preceding_chars_start..closing] . chars ( ) . all ( is_horizontal_whitespace)  { 
605606                        // candidate found 
606-                         potential_closing = Some ( closing) ; 
607+                         potential_closing = Some ( closing + base_index ) ; 
607608                        break ; 
608609                    }  else  { 
609610                        rest = & rest[ closing + 3 ..] ; 
611+                         base_index += closing + 3 ; 
610612                    } 
611613                } 
612614            } 
Original file line number Diff line number Diff line change 1+ ---
2+ //~^ ERROR unclosed frontmatter 
3+ 🦀---
4+  ---
5+ 
6+ // This test checks the location of the --- recovered by the parser is not 
7+ // incorrectly tracked during the less fortunate recovery case and multiple 
8+ // candidates are found, as seen with #146847 
9+ 
10+ #![ feature ( frontmatter) ] 
11+ 
12+ fn main ( ) { } 
Original file line number Diff line number Diff line change 1+ error: unclosed frontmatter
2+   --> $DIR/unclosed-6.rs:1:1
3+    |
4+ LL | / ---
5+ LL | |
6+ LL | | 🦀---
7+ LL | |  ---
8+ ...  |
9+ LL | |
10+    | |_^
11+    |
12+ note: frontmatter opening here was not closed
13+   --> $DIR/unclosed-6.rs:1:1
14+    |
15+ LL | ---
16+    | ^^^
17+ 
18+ error: aborting due to 1 previous error
19+ 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments