File tree 1 file changed +11
-9
lines changed
compiler/rustc_parse/src/lexer
1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -335,15 +335,17 @@ impl<'a> StringReader<'a> {
335
335
comment_kind : CommentKind ,
336
336
doc_style : DocStyle ,
337
337
) -> TokenKind {
338
- for ( idx, _) in content. match_indices ( '\r' ) {
339
- self . err_span_ (
340
- content_start + BytePos ( idx as u32 ) ,
341
- content_start + BytePos ( idx as u32 + 1 ) ,
342
- match comment_kind {
343
- CommentKind :: Line => "bare CR not allowed in doc-comment" ,
344
- CommentKind :: Block => "bare CR not allowed in block doc-comment" ,
345
- } ,
346
- ) ;
338
+ if content. contains ( '\r' ) {
339
+ for ( idx, _) in content. char_indices ( ) . filter ( |& ( _, c) | c == '\r' ) {
340
+ self . err_span_ (
341
+ content_start + BytePos ( idx as u32 ) ,
342
+ content_start + BytePos ( idx as u32 + 1 ) ,
343
+ match comment_kind {
344
+ CommentKind :: Line => "bare CR not allowed in doc-comment" ,
345
+ CommentKind :: Block => "bare CR not allowed in block doc-comment" ,
346
+ } ,
347
+ ) ;
348
+ }
347
349
}
348
350
349
351
let attr_style = match doc_style {
You can’t perform that action at this time.
0 commit comments