-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Improve error messages for raw strings (#60762) #70522
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
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)
0fc2569
to
629e97a
Compare
I've left some initial comments, but I'm not qualified to sign off on lexer changes myself. |
@bors r+ |
📌 Commit 20e2190 has been approved by |
…rochenkov Improve error messages for raw strings (rust-lang#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) Fixes rust-lang#60762 cc @estebank who reviewed the original (abandoned) PR for the same ticket. r? @Centril
⌛ Testing commit 20e2190 with merge a2e8ca2e8ec00ba36705760e1ff649cd620c531d... |
💔 Test failed - checks-azure |
@bors retry |
…rochenkov Improve error messages for raw strings (rust-lang#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) Fixes rust-lang#60762 cc @estebank who reviewed the original (abandoned) PR for the same ticket. r? @Centril
Failed in #70601 (comment), @bors r- |
@bors r+ |
📌 Commit 55a5eea has been approved by |
…rochenkov Improve error messages for raw strings (rust-lang#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) Fixes rust-lang#60762 cc @estebank who reviewed the original (abandoned) PR for the same ticket. r? @Centril
Rollup of 6 pull requests Successful merges: - rust-lang#70511 (Add `-Z dump-mir-dataflow` flag for dumping dataflow results visualization) - rust-lang#70522 (Improve error messages for raw strings (rust-lang#60762)) - rust-lang#70547 (Add `can_unwind` field to `FnAbi`) - rust-lang#70591 (Ensure LLVM is in the link path for "fulldeps" tests) - rust-lang#70627 (Use place directly its copy) - rust-lang#70652 (Add git repo address to unstable book) Failed merges: - rust-lang#70634 (Remove some reexports in `rustc_middle`) r? @ghost
cc @matklad is |
This seem to fit pretty well into the rustc_lexer interface, which returns tokens as a bunch of sub-offsets. Ideally, we should dissolve lexer cooking altogether and instead lower the tokens much later, after macro expansion. |
This diff improves error messages around raw strings in a few ways:
#
in the parser. This can't be handled in the lexer because we could be in a macro that actually expects another # (see test)Fixes #60762
cc @estebank who reviewed the original (abandoned) PR for the same ticket.
r? @Centril