@@ -557,39 +557,36 @@ impl<'a> StringReader<'a> {
557
557
) ;
558
558
let mut nested_block_comment_open_idxs = vec ! [ ] ;
559
559
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 ( ) ;
561
561
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
+ } ;
576
573
}
577
574
578
575
if let Some ( ( nested_open_idx, nested_close_idx) ) = last_nested_block_comment_idxs {
579
576
err. span_label ( self . mk_sp ( start, start + BytePos ( 2 ) ) , msg)
580
577
. span_label (
581
578
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 ) ,
584
581
) ,
585
582
"...as last nested comment starts here, maybe you want to close this instead?" ,
586
583
)
587
584
. span_label (
588
585
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 ) ,
591
588
) ,
592
- "...and last nested comment terminates here" ,
589
+ "...and last nested comment terminates here. " ,
593
590
) ;
594
591
}
595
592
0 commit comments