diff options
| author | bors <bors@rust-lang.org> | 2019-06-10 23:32:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-10 23:32:12 +0000 |
| commit | 5e2c11034f9255f8b7bc7ded527d1db5175985f8 (patch) | |
| tree | 0443ccac9ab63e6334eeddd541541e170944d26d /src/test | |
| parent | 02564de47b40e953b5144dfd37450c16a84672f1 (diff) | |
| parent | 630d5f355fc85fc2c3bab28a278c517d945d328d (diff) | |
| download | rust-5e2c11034f9255f8b7bc7ded527d1db5175985f8.tar.gz rust-5e2c11034f9255f8b7bc7ded527d1db5175985f8.zip | |
Auto merge of #60793 - Xanewok:raw-string-cleanup, r=petrochenkov
lexer: Disallow bare CR in raw byte strings Handles bare CR ~but doesn't translate `\r\n` to `\n` yet in raw strings yet~ and translates CRLF to LF in raw strings. As a side-note I think it'd be good to change the `unescape_` to return plain iterators to reduce some boilerplate (e.g. `has_error` could benefit from collecting `Result<T>` and aborting early on errors) but will do that separately, unless I missed something here that prevents it. @matklad @petrochenkov thoughts?
Diffstat (limited to 'src/test')
4 files changed, 19 insertions, 7 deletions
diff --git a/src/test/run-pass/lexer-crlf-line-endings-string-literal-doc-comment.rs b/src/test/run-pass/lexer-crlf-line-endings-string-literal-doc-comment.rs index 126cab67c1c..f9d1b17b8dd 100644 --- a/src/test/run-pass/lexer-crlf-line-endings-string-literal-doc-comment.rs +++ b/src/test/run-pass/lexer-crlf-line-endings-string-literal-doc-comment.rs @@ -30,6 +30,9 @@ literal"; let s = r"string literal"; assert_eq!(s, "string\nliteral"); + let s = br"byte string +literal"; + assert_eq!(s, "byte string\nliteral".as_bytes()); // validate that our source file has CRLF endings let source = include_str!("lexer-crlf-line-endings-string-literal-doc-comment.rs"); diff --git a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr index 7d944569ca9..b0fe4b6acd4 100644 --- a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr +++ b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr @@ -28,11 +28,11 @@ error: bare CR not allowed in string, use \r instead LL | let _s = "foo bar"; | ^ -error: bare CR not allowed in raw string, use \r instead - --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:24:14 +error: bare CR not allowed in raw string + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:24:19 | LL | let _s = r"bar foo"; - | ^^^^^ + | ^ error: unknown character escape: \r --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:27:19 diff --git a/src/test/ui/parser/raw-byte-string-literals.rs b/src/test/ui/parser/raw-byte-string-literals.rs index 3b50fb8036a..534afabdf77 100644 --- a/src/test/ui/parser/raw-byte-string-literals.rs +++ b/src/test/ui/parser/raw-byte-string-literals.rs @@ -1,4 +1,7 @@ +// ignore-tidy-cr +// compile-flags: -Z continue-parse-after-error pub fn main() { + br"a "; //~ ERROR bare CR not allowed in raw string br"é"; //~ ERROR raw byte string must be ASCII br##~"a"~##; //~ ERROR only `#` is allowed in raw string delimitation } diff --git a/src/test/ui/parser/raw-byte-string-literals.stderr b/src/test/ui/parser/raw-byte-string-literals.stderr index 671ed97d1b5..4880d1fdbe8 100644 --- a/src/test/ui/parser/raw-byte-string-literals.stderr +++ b/src/test/ui/parser/raw-byte-string-literals.stderr @@ -1,14 +1,20 @@ -error: raw byte string must be ASCII: \u{e9} - --> $DIR/raw-byte-string-literals.rs:2:8 +error: bare CR not allowed in raw string + --> $DIR/raw-byte-string-literals.rs:4:9 + | +LL | br"a "; + | ^ + +error: raw byte string must be ASCII + --> $DIR/raw-byte-string-literals.rs:5:8 | LL | br"é"; | ^ error: found invalid character; only `#` is allowed in raw string delimitation: ~ - --> $DIR/raw-byte-string-literals.rs:3:6 + --> $DIR/raw-byte-string-literals.rs:6:6 | LL | br##~"a"~##; | ^^^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors |
