]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/rustfmt/tests/target/issue-2977/impl.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / rustfmt / tests / target / issue-2977 / impl.rs
diff --git a/src/tools/rustfmt/tests/target/issue-2977/impl.rs b/src/tools/rustfmt/tests/target/issue-2977/impl.rs
new file mode 100644 (file)
index 0000000..8d7bb94
--- /dev/null
@@ -0,0 +1,44 @@
+macro_rules! atomic_bits {
+    // the println macro cannot be rewritten because of the asm macro
+    ($type:ty, $ldrex:expr, $strex:expr) => {
+        impl AtomicBits for $type {
+            unsafe fn load_excl(address: usize) -> Self {
+                let raw: $type;
+                asm!($ldrex
+                     : "=r"(raw)
+                     : "r"(address)
+                     :
+                     : "volatile");
+                raw
+            }
+
+            unsafe fn store_excl(self, address: usize) -> bool {
+                let status: $type;
+                println!("{}",
+                         status);
+                status == 0
+            }
+        }
+    };
+
+    // the println macro should be rewritten here
+    ($type:ty) => {
+        fn some_func(self) {
+            let status: $type;
+            println!("{}", status);
+        }
+    };
+
+    // unrewritale macro in func
+    ($type:ty, $ldrex:expr) => {
+        unsafe fn load_excl(address: usize) -> Self {
+            let raw: $type;
+            asm!($ldrex
+                 : "=r"(raw)
+                 : "r"(address)
+                 :
+                 : "volatile");
+            raw
+        }
+    }
+}