mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 01:05:39 +03:00
f5a2bb6263
`-Zunpretty=expanded,hygiene` was not printing syntax context annotations for identifiers and lifetimes inside `macro_rules!` bodies. These tokens are printed via `print_tt()` → `token_to_string_ext()`, which converts tokens to strings without calling `ann_post()`. This meant that macro-generated `macro_rules!` definitions with hygienic metavar parameters (e.g. multiple `$marg` distinguished only by hygiene) were printed with no way to tell them apart. This was fixed by adding a match on `token.kind` in `print_tt()` to call `ann_post()` for `Ident`, `NtIdent`, `Lifetime`, and `NtLifetime` tokens, matching how `print_ident()` and `print_lifetime()` already handle AST-level identifiers and lifetimes. Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
35 lines
805 B
Plaintext
35 lines
805 B
Plaintext
//@ check-pass
|
|
//@ compile-flags: -Zunpretty=expanded,hygiene
|
|
|
|
// Don't break whenever Symbol numbering changes
|
|
//@ normalize-stdout: "\d+#" -> "0#"
|
|
|
|
// minimal junk
|
|
#![feature /* 0#0 */(no_core /* 0#0 */)]
|
|
#![no_core /* 0#0 */]
|
|
|
|
macro_rules! foo
|
|
/*
|
|
0#0
|
|
*/ {
|
|
($x /* 0#0 */: ident /* 0#0 */) =>
|
|
{ y /* 0#0 */ + $x /* 0#0 */ }
|
|
}
|
|
|
|
fn bar /* 0#0 */() {
|
|
let x /* 0#0 */ = 1;
|
|
y /* 0#1 */ + x /* 0#0 */
|
|
}
|
|
|
|
fn y /* 0#0 */() {}
|
|
|
|
/*
|
|
Expansions:
|
|
crate0::{{expn0}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Root
|
|
crate0::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "foo")
|
|
|
|
SyntaxContexts:
|
|
#0: parent: #0, outer_mark: (crate0::{{expn0}}, Opaque)
|
|
#1: parent: #0, outer_mark: (crate0::{{expn1}}, SemiOpaque)
|
|
*/
|