diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-01 20:35:48 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-01 20:35:48 -0700 |
| commit | ce49944171aad0b53ffd1ea1dc9fdb47c25f85ec (patch) | |
| tree | d63f148a77ae33ac03ebeb4b178bfe01f9b11abd /src/test/codegen/src-hash-algorithm | |
| parent | 6b57050b17de7055ca2345867ee4eb8c5b5f1fa9 (diff) | |
| parent | 1ded7a581589b65be35724ea00bb5cec4e13c673 (diff) | |
| download | rust-ce49944171aad0b53ffd1ea1dc9fdb47c25f85ec.tar.gz rust-ce49944171aad0b53ffd1ea1dc9fdb47c25f85ec.zip | |
Rollup merge of #73569 - Aaron1011:fix/macro-rules-group, r=petrochenkov
Handle `macro_rules!` tokens consistently across crates When we serialize a `macro_rules!` macro, we used a 'lowered' `TokenStream` for its body, which has all `Nonterminal`s expanded in-place via `nt_to_tokenstream`. This matters when an 'outer' `macro_rules!` macro expands to an 'inner' `macro_rules!` macro - the inner macro may use tokens captured from the 'outer' macro in its definition. This means that invoking a foreign `macro_rules!` macro may use a different body `TokenStream` than when the same `macro_rules!` macro is invoked in the same crate. This difference is observable by proc-macros invoked by a `macro_rules!` macro - a `None`-delimited group will be seen in the same-crate case (inserted when convering `Nonterminal`s to the `proc_macro` crate's structs), but no `None`-delimited group in the cross-crate case. To fix this inconsistency, we now insert `None`-delimited groups when 'lowering' a `Nonterminal` `macro_rules!` body, just as we do in `proc_macro_server`. Additionally, we no longer print extra spaces for `None`-delimited groups - as far as pretty-printing is concerned, they don't exist (only their contents do). This ensures that `Display` output of a `TokenStream` does not depend on which crate a `macro_rules!` macro was invoked from. This PR is necessary in order to patch the `solana-genesis-programs` for the upcoming hygiene serialization breakage (https://github.com/rust-lang/rust/pull/72121#issuecomment-646924847). The `solana-genesis-programs` crate will need to use a proc macro to re-span certain tokens in a nested `macro_rules!`, which requires us to consistently use a `None`-delimited group. See `src/test/ui/proc-macro/nested-macro-rules.rs` for an example of the kind of nested `macro_rules!` affected by this crate.
Diffstat (limited to 'src/test/codegen/src-hash-algorithm')
0 files changed, 0 insertions, 0 deletions
