From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/tools/rustfmt/tests/target/issue-2977/block.rs | 11 ++++++ src/tools/rustfmt/tests/target/issue-2977/impl.rs | 44 ++++++++++++++++++++++ src/tools/rustfmt/tests/target/issue-2977/item.rs | 11 ++++++ src/tools/rustfmt/tests/target/issue-2977/trait.rs | 44 ++++++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 src/tools/rustfmt/tests/target/issue-2977/block.rs create mode 100644 src/tools/rustfmt/tests/target/issue-2977/impl.rs create mode 100644 src/tools/rustfmt/tests/target/issue-2977/item.rs create mode 100644 src/tools/rustfmt/tests/target/issue-2977/trait.rs (limited to 'src/tools/rustfmt/tests/target/issue-2977') diff --git a/src/tools/rustfmt/tests/target/issue-2977/block.rs b/src/tools/rustfmt/tests/target/issue-2977/block.rs new file mode 100644 index 000000000..d376e370c --- /dev/null +++ b/src/tools/rustfmt/tests/target/issue-2977/block.rs @@ -0,0 +1,11 @@ +macro_rules! atomic_bits { + ($ldrex:expr) => { + execute(|| { + asm!($ldrex + : "=r"(raw) + : "r"(address) + : + : "volatile"); + }) + }; +} 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 index 000000000..8d7bb9414 --- /dev/null +++ b/src/tools/rustfmt/tests/target/issue-2977/impl.rs @@ -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 + } + } +} diff --git a/src/tools/rustfmt/tests/target/issue-2977/item.rs b/src/tools/rustfmt/tests/target/issue-2977/item.rs new file mode 100644 index 000000000..857065ca9 --- /dev/null +++ b/src/tools/rustfmt/tests/target/issue-2977/item.rs @@ -0,0 +1,11 @@ +macro_rules! atomic_bits { + ($ldrex:expr) => { + some_macro!(pub fn foo() { + asm!($ldrex + : "=r"(raw) + : "r"(address) + : + : "volatile"); + }) + }; +} diff --git a/src/tools/rustfmt/tests/target/issue-2977/trait.rs b/src/tools/rustfmt/tests/target/issue-2977/trait.rs new file mode 100644 index 000000000..ae20668cd --- /dev/null +++ b/src/tools/rustfmt/tests/target/issue-2977/trait.rs @@ -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) => { + trait $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 + } + } +} -- cgit v1.2.3