quote_expr macro: embed Ident using special encoding that retains hygiene state.#16477
Closed
pnkfelix wants to merge 2 commits intorust-lang:masterfrom
Closed
quote_expr macro: embed Ident using special encoding that retains hygiene state.#16477pnkfelix wants to merge 2 commits intorust-lang:masterfrom
pnkfelix wants to merge 2 commits intorust-lang:masterfrom
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.
Contributor
Author
|
r? anyone, perhaps @huonw |
Contributor
|
Awesome hack! Thanks for working this out, @pnkfelix. |
Contributor
Author
|
I realized last night that perhaps the most important test was not included in the PR above: namely, a |
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this pull request
Aug 14, 2014
Contributor
|
@pnkfelix Thanks much! |
matthiaskrgr
pushed a commit
to matthiaskrgr/rust
that referenced
this pull request
Feb 11, 2024
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
quote_expr macro: embed Ident using special encoding that retains hygiene state.
Fix #15750, #15962