Closed
Description
The following code:
#![warn(unsafe_attr_outside_unsafe)]
macro_rules! m {
() => {
#[cfg_attr(all(), link_section = ".text.startup")]
unsafe extern "C" fn __ctor() {}
};
}
m! {}
generates a suggestion which when applied looks like:
#[cfg_attr(all(), liunsafe(nk_section = ".text.startup)")]
Somehow the span is off by two bytes on both the start and end.
This doesn't happen outside of a macro expansion, and it seems to also require the cfg_attr.
Meta
rustc --version --verbose
:
rustc 1.84.0-nightly (143ce0920 2024-11-10)
binary: rustc
commit-hash: 143ce0920a2307b19831160a01f06f107610f1b2
commit-date: 2024-11-10
host: aarch64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: The 2024 editionArea: Lints (warnings about flaws in source code) such as unused_mut.Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Diagnostics: An error or lint that should account for edition differences.Diagnostics: A structured suggestion resulting in incorrect code.Lint: unsafe_attr_outside_unsafeHigh priorityRelevant to the compiler team, which will review and decide on the PR/issue.