diff options
| author | Russell Cohen <russell.r.cohen@gmail.com> | 2020-04-02 00:08:58 -0400 |
|---|---|---|
| committer | Russell Cohen <russell.r.cohen@gmail.com> | 2020-04-02 01:02:55 -0400 |
| commit | f543689eb65aeacb6ec85c07f0c82800174d21c1 (patch) | |
| tree | 370f8aaebf7c5397d96eaaa5453ce78bfe0da558 /src/test/ui/parser | |
| parent | 76b11980ad416c3ad6143504c2277757ecacf9b5 (diff) | |
| download | rust-f543689eb65aeacb6ec85c07f0c82800174d21c1.tar.gz rust-f543689eb65aeacb6ec85c07f0c82800174d21c1.zip | |
Handle unterminated raw strings with no #s properly
The modified code to handle parsing raw strings didn't properly account for the case where there was no "#" on either end and erroneously reported this strings as complete. This lead to a panic trying to read off the end of the file.
Diffstat (limited to 'src/test/ui/parser')
| -rw-r--r-- | src/test/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.stderr | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/test/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.rs b/src/test/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.rs new file mode 100644 index 00000000000..bdfc29a3d57 --- /dev/null +++ b/src/test/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.rs @@ -0,0 +1,5 @@ +// This won't actually panic because of the error comment -- the `"` needs to be +// the last byte in the file (including not having a trailing newline) +// Prior to the fix you get the error: 'expected item, found `r" ...`' +// because the string being unterminated wasn't properly detected. +r" //~ unterminated raw string diff --git a/src/test/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.stderr b/src/test/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.stderr new file mode 100644 index 00000000000..3a7e2a4b14a --- /dev/null +++ b/src/test/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.stderr @@ -0,0 +1,9 @@ +error[E0748]: unterminated raw string + --> $DIR/issue-70677-panic-on-unterminated-raw-str-at-eof.rs:5:1 + | +LL | r" + | ^ unterminated raw string + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0748`. |
