diff options
| author | Eduard-Mihai Burtescu <eddyb@lyken.rs> | 2022-06-13 08:04:27 +0000 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <eddyb@lyken.rs> | 2022-06-13 08:04:27 +0000 |
| commit | 44783f1db0bd1076d825b2b681c4220bbf97bbec (patch) | |
| tree | cba0c44e481d19225ef914f9561b7a7719597d2e | |
| parent | 521218ce88e12ed2960f619545cf22404cee8d1e (diff) | |
| download | rust-44783f1db0bd1076d825b2b681c4220bbf97bbec.tar.gz rust-44783f1db0bd1076d825b2b681c4220bbf97bbec.zip | |
Revert "rustc_parse: work around instruction-counting non-determinism."
This reverts commit 521218ce88e12ed2960f619545cf22404cee8d1e.
| -rw-r--r-- | compiler/rustc_parse/src/lexer/mod.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index f3b11e9b604..e9701ec2d7f 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -335,15 +335,17 @@ impl<'a> StringReader<'a> { comment_kind: CommentKind, doc_style: DocStyle, ) -> TokenKind { - 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", - }, - ); + 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", + }, + ); + } } let attr_style = match doc_style { |
