]> git.lizzy.rs Git - rust.git/commitdiff
rustc_parse: work around instruction-counting non-determinism.
authorEduard-Mihai Burtescu <edy.burt@gmail.com>
Thu, 5 Nov 2020 17:28:17 +0000 (19:28 +0200)
committerEduard-Mihai Burtescu <eddyb@lyken.rs>
Mon, 13 Jun 2022 08:00:58 +0000 (08:00 +0000)
compiler/rustc_parse/src/lexer/mod.rs

index e9701ec2d7f456f3b85158c29f481b8be0539e91..f3b11e9b604bfdc5c8c6cfd81ecbc8c15a9a79a3 100644 (file)
@@ -335,17 +335,15 @@ fn cook_doc_comment(
         comment_kind: CommentKind,
         doc_style: DocStyle,
     ) -> TokenKind {
-        if content.contains('\r') {
-            for (idx, _) in content.char_indices().filter(|&(_, c)| c == '\r') {
-                self.err_span_(
-                    content_start + BytePos(idx as u32),
-                    content_start + BytePos(idx as u32 + 1),
-                    match comment_kind {
-                        CommentKind::Line => "bare CR not allowed in doc-comment",
-                        CommentKind::Block => "bare CR not allowed in block doc-comment",
-                    },
-                );
-            }
+        for (idx, _) in content.match_indices('\r') {
+            self.err_span_(
+                content_start + BytePos(idx as u32),
+                content_start + BytePos(idx as u32 + 1),
+                match comment_kind {
+                    CommentKind::Line => "bare CR not allowed in doc-comment",
+                    CommentKind::Block => "bare CR not allowed in block doc-comment",
+                },
+            );
         }
 
         let attr_style = match doc_style {