]> git.lizzy.rs Git - rust.git/commit
Improve error messages for raw strings (#60762)
authorRussell Cohen <russell.r.cohen@gmail.com>
Sat, 28 Mar 2020 05:46:20 +0000 (01:46 -0400)
committerRussell Cohen <russell.r.cohen@gmail.com>
Sun, 29 Mar 2020 04:43:43 +0000 (00:43 -0400)
commit629e97a5a02edb3d8dc63c5157962c093217d441
treeec748780e2098a0581b06d0501bc297447ca59ba
parent840a5769b0879f39e21d973a60ac0b0db172f050
Improve error messages for raw strings (#60762)

This diff improves error messages around raw strings in a few ways:
- Catch extra trailing `#` in the parser. This can't be handled in the lexer because we could be in a macro that actually expects another # (see test)
- Refactor & unify error handling in the lexer between ByteStrings and RawByteStrings
- Detect potentially intended terminators (longest sequence of "#*" is suggested)
src/librustc_lexer/src/cursor.rs
src/librustc_lexer/src/lib.rs
src/librustc_lexer/src/tests.rs [new file with mode: 0644]
src/librustc_parse/lexer/mod.rs
src/librustc_parse/parser/diagnostics.rs
src/test/ui/parser/raw/raw-byte-string-eof.stderr
src/test/ui/parser/raw/raw-str-in-macro-call.rs [new file with mode: 0644]
src/test/ui/parser/raw/raw-str-unbalanced.rs
src/test/ui/parser/raw/raw-str-unbalanced.stderr
src/test/ui/parser/raw/raw_string.stderr