Skip to content

#[rustfmt::skip] attribute incompatible with #[unsafe(naked)] #140623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Amanieu opened this issue May 3, 2025 · 0 comments · Fixed by #140626
Closed

#[rustfmt::skip] attribute incompatible with #[unsafe(naked)] #140623

Amanieu opened this issue May 3, 2025 · 0 comments · Fixed by #140626
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Amanieu
Copy link
Member

Amanieu commented May 3, 2025

The following code fails to compile due to attribute checks on naked functions being too strict.

#[rustfmt::skip]
#[unsafe(naked)]
extern "C" fn naked() {
    core::arch::naked_asm!("");
}
error[E0736]: attribute incompatible with `#[unsafe(naked)]`
 --> src/lib.rs:1:1
  |
1 | #[rustfmt::skip]
  | ^^^^^^^^^^^^^^^^ the `rustfmt::skip` attribute is incompatible with `#[unsafe(naked)]`
2 | #[unsafe(naked)]
  | ---------------- function marked with `#[unsafe(naked)]` here

For more information about this error, try `rustc --explain E0736`.
error: could not compile `playground` (lib) due to 1 previous error

cc @folkertdev

@Amanieu Amanieu added the C-bug Category: This is a bug. label May 3, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 3, 2025
@jieyouxu jieyouxu added A-attributes Area: Attributes (`#[…]`, `#![…]`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 3, 2025
@bors bors closed this as completed in 1239f49 May 4, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 4, 2025
Rollup merge of rust-lang#140626 - folkertdev:naked-rustfmt-skip, r=Amanieu

allow `#[rustfmt::skip]` in combination with `#[naked]`

fixes rust-lang#140623

We very deliberately use an allowlist to prevent weird interactions with `#[naked]`, hopefully we've now found all of the useful combinations.

cc `@Amanieu`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants