-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
quote_expr macro: embed Ident using special encoding that retains hygiene state. #16477
Conversation
…ygiene. This adds support to `quote_expr!` and friends for round-trip hygienic preservation of Ident. Here are the pieces of the puzzle: * adding a method for encoding Ident for re-reading into token tree. * Support for reading such encoded Idents in the lexer. Note that one must peek ahead for MOD_SEP after scan_embedded_hygienic_ident. * To ensure that encoded Idents are only read when we are in the midst of expanding a `quote_expr` or similar, added a `read_embedded_ident` flag on `StringReader`. * pprust support for encoding Ident's as (uint,uint) pairs (for hygiene).
I chose to make two of them because I wanted something close to an "end-to-end" test (*), but at the same time I wanted a test that would run on Windows (**). (*) The run-make test serves as the end-to-end: It constructs an input that is trying to subvert the hack and we are going to check that it fails in the attempt). (**) The compile-fail-fulldeps test serves as a more narrow test that will be tested on all platforms. It also attempts to subvert the hack, testing that when you use `new_parser_from_tts`, the resulting parser does not support reading embedded Idents.
r? anyone, perhaps @huonw |
Awesome hack! Thanks for working this out, @pnkfelix. |
I realized last night that perhaps the most important test was not included in the PR above: namely, a |
@pnkfelix Thanks much! |
…agnostic, r=Veykril feat: Add incorrect case diagnostics for traits and their associated items Updates incorrect case diagnostic to: - Check traits and their associated items - Ignore trait implementations except for patterns in associated function bodies Also cleans up `hir-ty::diagnostics::decl_check` a bit (mostly to make it a bit more DRY and easier to maintain) Also fixes: rust-lang#8675 and fixes: rust-lang#8225
quote_expr macro: embed Ident using special encoding that retains hygiene state.
Fix #15750, #15962