]> git.lizzy.rs Git - rust.git/commitdiff
added test for method arg hygiene
authorJohn Clements <clements@racket-lang.org>
Fri, 4 Jul 2014 17:57:17 +0000 (10:57 -0700)
committerJohn Clements <clements@racket-lang.org>
Tue, 8 Jul 2014 22:14:45 +0000 (15:14 -0700)
src/libsyntax/ext/expand.rs

index 74cede2a125add771ed548a336517dc45d83e104..1569b4ac4e95d1e97df8e88f485d8747b77af922 100644 (file)
@@ -1390,6 +1390,19 @@ macro_rules! outer ( ($e:pat ) => (inner!($e)))
     // but *shouldn't* bind because it was inserted by a different macro....
     // can't write this test case until we have macro-generating macros.
 
+    // method arg hygiene
+    // method expands to fn get_x(&self_0, x_1:int) {self_0 + self_2 + x_3 + x_1}
+    #[test] fn method_arg_hygiene(){
+        run_renaming_test(
+            &("macro_rules! inject_x (()=>(x))
+              macro_rules! inject_self (()=>(self))
+              struct A;
+              impl A{fn get_x(&self, x: int) {self + inject_self!() + inject_x!() + x;} }",
+              vec!(vec!(0),vec!(3)),
+              true),
+            0)
+    }
+
     // item fn hygiene
     // expands to fn q(x_1:int){fn g(x_2:int){x_2 + x_1};}
     #[test] fn issue_9383(){