about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFolkert de Vries <folkert@folkertdev.nl>2025-05-03 19:10:43 +0200
committerFolkert de Vries <folkert@folkertdev.nl>2025-05-03 19:15:19 +0200
commit9aee0aa453a83f8bee6dc32037e0389f3a9188fe (patch)
treefdda2346e5548ae81821d32a42f2ffb8a5b69234
parent097cd98869cf07a2860bef16c0d4a2b3b019b23a (diff)
downloadrust-9aee0aa453a83f8bee6dc32037e0389f3a9188fe.tar.gz
rust-9aee0aa453a83f8bee6dc32037e0389f3a9188fe.zip
allow `#[rustfmt::skip]` in combination with `#[naked]`
-rw-r--r--compiler/rustc_passes/src/check_attr.rs4
-rw-r--r--tests/ui/asm/naked-functions.rs6
2 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index f04b167889f..e5b20901c0c 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -683,7 +683,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
                         }
                     }
 
-                    if !other_attr.has_any_name(ALLOW_LIST) {
+                    if !other_attr.has_any_name(ALLOW_LIST)
+                        && !matches!(other_attr.path().as_slice(), [sym::rustfmt, ..])
+                    {
                         let path = other_attr.path();
                         let path: Vec<_> = path.iter().map(|s| s.as_str()).collect();
                         let other_attr_name = path.join("::");
diff --git a/tests/ui/asm/naked-functions.rs b/tests/ui/asm/naked-functions.rs
index cb5fde9a80b..a6f41698b41 100644
--- a/tests/ui/asm/naked-functions.rs
+++ b/tests/ui/asm/naked-functions.rs
@@ -231,3 +231,9 @@ pub extern "C" fn compatible_linkage() {
 pub extern "C" fn rustc_std_internal_symbol() {
     naked_asm!("", options(raw));
 }
+
+#[rustfmt::skip]
+#[unsafe(naked)]
+pub extern "C" fn rustfmt_skip() {
+    naked_asm!("", options(raw));
+}