]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/issue-7911.rs
cleanup: s/impl Copy/#[derive(Copy)]/g
[rust.git] / src / test / run-pass / issue-7911.rs
index 45f4b1127aefe8ecb1c0525cdc0284841cd2f593..86948ebcb91e0e4dbf2de046876376d3508a3f41 100644 (file)
@@ -13,9 +13,7 @@
 // (Closes #7911) Test that we can use the same self expression
 // with different mutability in macro in two methods
 
-#[allow(unused_variable)]; // unused foobar_immut + foobar_mut
-#[feature(macro_rules)];
-
+#![allow(unused_variable)] // unused foobar_immut + foobar_mut
 trait FooBar {}
 struct Bar(i32);
 struct Foo { bar: Bar }
@@ -23,23 +21,23 @@ struct Foo { bar: Bar }
 impl FooBar for Bar {}
 
 trait Test {
-    fn get_immut<'r>(&'r self) -> &'r FooBar;
-    fn get_mut<'r>(&'r mut self) -> &'r mut FooBar;
+    fn get_immut(&self) -> &FooBar;
+    fn get_mut(&mut self) -> &mut FooBar;
 }
 
-macro_rules! generate_test(($type_:path, $field:expr) => (
+macro_rules! generate_test { ($type_:path, $slf:ident, $field:expr) => (
     impl Test for $type_ {
-        fn get_immut<'r>(&'r self) -> &'r FooBar {
+        fn get_immut(&$slf) -> &FooBar {
             &$field as &FooBar
         }
 
-        fn get_mut<'r>(&'r mut self) -> &'r mut FooBar {
+        fn get_mut(&mut $slf) -> &mut FooBar {
             &mut $field as &mut FooBar
         }
     }
-))
+)}
 
-generate_test!(Foo, self.bar)
+generate_test!(Foo, self, self.bar);
 
 pub fn main() {
     let mut foo: Foo = Foo { bar: Bar(42) };