@@ -557,39 +557,36 @@ impl<'a> StringReader<'a> {
557557 ) ;
558558 let mut nested_block_comment_open_idxs = vec ! [ ] ;
559559 let mut last_nested_block_comment_idxs = None ;
560- let mut content_chars = self . str_from ( start) . char_indices ( ) ;
560+ let mut content_chars = self . str_from ( start) . char_indices ( ) . peekable ( ) ;
561561
562- if let Some ( ( _, mut last_char) ) = content_chars. next ( ) {
563- while let Some ( ( idx, c) ) = content_chars. next ( ) {
564- match c {
565- '*' if last_char == '/' => {
566- nested_block_comment_open_idxs. push ( idx) ;
567- }
568- '/' if last_char == '*' => {
569- last_nested_block_comment_idxs =
570- nested_block_comment_open_idxs. pop ( ) . map ( |open_idx| ( open_idx, idx) ) ;
571- }
572- _ => { }
573- } ;
574- last_char = c;
575- }
562+ while let Some ( ( idx, current_char) ) = content_chars. next ( ) {
563+ match content_chars. peek ( ) {
564+ Some ( ( _, '*' ) ) if current_char == '/' => {
565+ nested_block_comment_open_idxs. push ( idx) ;
566+ }
567+ Some ( ( _, '/' ) ) if current_char == '*' => {
568+ last_nested_block_comment_idxs =
569+ nested_block_comment_open_idxs. pop ( ) . map ( |open_idx| ( open_idx, idx) ) ;
570+ }
571+ _ => { }
572+ } ;
576573 }
577574
578575 if let Some ( ( nested_open_idx, nested_close_idx) ) = last_nested_block_comment_idxs {
579576 err. span_label ( self . mk_sp ( start, start + BytePos ( 2 ) ) , msg)
580577 . span_label (
581578 self . mk_sp (
582- start + BytePos ( nested_open_idx as u32 - 1 ) ,
583- start + BytePos ( nested_open_idx as u32 + 1 ) ,
579+ start + BytePos ( nested_open_idx as u32 ) ,
580+ start + BytePos ( nested_open_idx as u32 + 2 ) ,
584581 ) ,
585582 "...as last nested comment starts here, maybe you want to close this instead?" ,
586583 )
587584 . span_label (
588585 self . mk_sp (
589- start + BytePos ( nested_close_idx as u32 - 1 ) ,
590- start + BytePos ( nested_close_idx as u32 + 1 ) ,
586+ start + BytePos ( nested_close_idx as u32 ) ,
587+ start + BytePos ( nested_close_idx as u32 + 2 ) ,
591588 ) ,
592- "...and last nested comment terminates here" ,
589+ "...and last nested comment terminates here. " ,
593590 ) ;
594591 }
595592
0 commit comments