Allow (but don't require) #[unsafe(naked)] so that compiler-builtins can upgrade to it

This commit is contained in:
Folkert de Vries 2025-04-14 14:36:53 +02:00
parent 5961e5ba3d
commit cb22c1d5e9
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 34 additions and 28 deletions

View file

@ -194,6 +194,12 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr:
}
}
} else if let Safety::Unsafe(unsafe_span) = attr_item.unsafety {
// Allow (but don't require) `#[unsafe(naked)]` so that compiler-builtins can upgrade to it.
// FIXME(#139797): remove this special case when compiler-builtins has upgraded.
if attr.has_name(sym::naked) {
return;
}
psess.dcx().emit_err(errors::InvalidAttrUnsafe {
span: unsafe_span,
name: attr_item.path.clone(),