rust/compiler/rustc_ast/src
bors 1773f60ea5 Auto merge of #78712 - petrochenkov:visitok, r=Aaron1011
rustc_ast: Visit tokens stored in AST nodes in mutable visitor

After #77271 token visiting is enabled only for one visitor in `rustc_expand\src\mbe\transcribe.rs` which applies hygiene marks to tokens produced by declarative macros (`macro_rules` or `macro`), so this change doesn't affect anything else.

When a macro has some interpolated token from an outer macro in its output
```rust
macro inner() {
    $interpolated
}
```
we can use the usual interpretation of interpolated tokens in token-based model - a None-delimited group - to write this macro in an equivalent form
```rust
macro inner() {
    ⟪ a b c d ⟫
}
```

When we are expanding the macro `inner` we need to apply hygiene marks to all tokens produced by it, including the tokens inside the group.

Before this PR we did this by visiting the AST piece inside the interpolated token and applying marks to all spans in it.
I'm not sure this is 100% correct (ideally we should apply the marks to tokens and then re-parse the AST from tokens), but it's a very good approximation at least.
We didn't however apply the marks to actual tokens stored in the nonterminal, so if we used the nonterminal as a token rather than as an AST piece (e.g. passed it to a proc macro), then we got hygiene bugs.
This PR applies the marks to tokens in addition to the AST pieces thus fixing the issue.

r? `@Aaron1011`
2020-11-08 20:00:51 +00:00
..
ast mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
attr fix a couple of clippy warnings: 2020-11-04 13:48:50 +01:00
expand mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
util Auto merge of #78066 - bugadani:wat, r=jonas-schievink 2020-10-18 13:50:31 +00:00
ast.rs Treat trailing semicolon as a statement in macro call 2020-11-02 13:03:13 -05:00
crate_disambiguator.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
entry.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
lib.rs tidy 2020-09-23 22:08:30 +02:00
mut_visit.rs rustc_ast: Never clone empty token streams in mutable visitor 2020-11-06 00:59:08 +03:00
node_id.rs The renumber pass is long gone 2020-11-06 03:18:01 +01:00
ptr.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
token.rs Suggest expressions that look like const generic arguments should be enclosed in brackets 2020-10-26 21:54:45 +00:00
tokenstream.rs Expand NtExpr tokens only in key-value attributes 2020-11-03 00:53:43 +03:00
visit.rs Expand NtExpr tokens only in key-value attributes 2020-11-03 00:53:43 +03:00