mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Add regression tests for token hygiene annotations in macro bodies
Add `unpretty-debug-shadow` test covering macro body tokens that reference a shadowed variable, and simplify the `unpretty-debug-metavars` test macro. Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
//@ check-pass
|
||||
//@ compile-flags: -Zunpretty=expanded,hygiene
|
||||
|
||||
// Regression test: metavar parameters in macro-generated macro_rules!
|
||||
// definitions should have hygiene annotations so that textually identical
|
||||
// `$marg` bindings are distinguishable by their syntax contexts.
|
||||
// Regression test for token hygiene annotations in -Zunpretty=expanded,hygiene
|
||||
// Previously, metavar parameters in macro-generated macro_rules! definitions
|
||||
// were missing hygiene annotations, making identical `$marg` bindings
|
||||
// indistinguishable.
|
||||
|
||||
// Don't break whenever Symbol numbering changes
|
||||
//@ normalize-stdout: "\d+#" -> "0#"
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
//@ check-pass
|
||||
//@ compile-flags: -Zunpretty=expanded,hygiene
|
||||
|
||||
// Regression test: metavar parameters in macro-generated macro_rules!
|
||||
// definitions should have hygiene annotations so that textually identical
|
||||
// `$marg` bindings are distinguishable by their syntax contexts.
|
||||
// Regression test for token hygiene annotations in -Zunpretty=expanded,hygiene
|
||||
// Previously, metavar parameters in macro-generated macro_rules! definitions
|
||||
// were missing hygiene annotations, making identical `$marg` bindings
|
||||
// indistinguishable.
|
||||
|
||||
// Don't break whenever Symbol numbering changes
|
||||
//@ normalize-stdout: "\d+#" -> "0#"
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//@ check-pass
|
||||
//@ compile-flags: -Zunpretty=expanded,hygiene
|
||||
|
||||
// Regression test for token hygiene annotations in -Zunpretty=expanded,hygiene
|
||||
// Previously, tokens in macro_rules! bodies were missing hygiene annotations,
|
||||
// making it impossible to see how a macro's reference to a shadowed variable
|
||||
// is distinguished from the shadowing binding.
|
||||
|
||||
// Don't break whenever Symbol numbering changes
|
||||
//@ normalize-stdout: "\d+#" -> "0#"
|
||||
|
||||
#![feature(no_core)]
|
||||
#![no_core]
|
||||
|
||||
fn f() {
|
||||
let x = 0;
|
||||
macro_rules! use_x { () => { x }; }
|
||||
let x = 1;
|
||||
use_x!();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//@ check-pass
|
||||
//@ compile-flags: -Zunpretty=expanded,hygiene
|
||||
|
||||
// Regression test for token hygiene annotations in -Zunpretty=expanded,hygiene
|
||||
// Previously, tokens in macro_rules! bodies were missing hygiene annotations,
|
||||
// making it impossible to see how a macro's reference to a shadowed variable
|
||||
// is distinguished from the shadowing binding.
|
||||
|
||||
// Don't break whenever Symbol numbering changes
|
||||
//@ normalize-stdout: "\d+#" -> "0#"
|
||||
|
||||
#![feature /* 0#0 */(no_core /* 0#0 */)]
|
||||
#![no_core /* 0#0 */]
|
||||
|
||||
fn f /* 0#0 */() {
|
||||
let x /* 0#0 */ = 0;
|
||||
macro_rules! use_x /* 0#0 */ { () => { x /* 0#0 */ }; }
|
||||
let x /* 0#0 */ = 1;
|
||||
x /* 0#1 */;
|
||||
}
|
||||
|
||||
/*
|
||||
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, "use_x")
|
||||
|
||||
SyntaxContexts:
|
||||
#0: parent: #0, outer_mark: (crate0::{{expn0}}, Opaque)
|
||||
#1: parent: #0, outer_mark: (crate0::{{expn1}}, SemiOpaque)
|
||||
*/
|
||||
Reference in New Issue
Block a user