]> git.lizzy.rs Git - rust.git/commitdiff
Add more hygiene tests
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Mon, 20 Jun 2016 12:13:05 +0000 (12:13 +0000)
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Mon, 20 Jun 2016 12:13:59 +0000 (12:13 +0000)
src/test/run-pass/hygiene.rs

index d39fd0cbf3835077bfd75701d780811b11b3f8b5..b455972202647fadaa41bcc44b9cbfd44f696788 100644 (file)
@@ -18,4 +18,27 @@ macro_rules! foo { () => {
 
     let x = 1;
     foo!();
+
+    g();
+}
+
+fn g() {
+    let x = 0;
+    macro_rules! m { ($x:ident) => {
+        macro_rules! m2 { () => { ($x, x) } }
+        let x = 1;
+        macro_rules! m3 { () => { ($x, x) } }
+    } }
+
+    let x = 2;
+    m!(x);
+
+    let x = 3;
+    assert_eq!(m2!(), (2, 0));
+    assert_eq!(m3!(), (2, 1));
+
+    let x = 4;
+    m!(x);
+    assert_eq!(m2!(), (4, 0));
+    assert_eq!(m3!(), (4, 1));
 }