make /// doc comments compatible with naked functions

This commit is contained in:
Folkert 2024-07-30 09:55:36 +02:00
parent 3954398882
commit 58bfd98baf
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C
2 changed files with 9 additions and 0 deletions

View File

@ -460,6 +460,12 @@ fn check_naked(
Target::Fn
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => {
for other_attr in attrs {
// this covers "sugared doc comments" of the form `/// ...`
// it does not cover `#[doc = "..."]`, which is handled below
if other_attr.is_doc_comment() {
continue;
}
if !ALLOW_LIST.iter().any(|name| other_attr.has_name(*name)) {
self.dcx().emit_err(errors::NakedFunctionIncompatibleAttribute {
span: other_attr.span,

View File

@ -239,6 +239,9 @@ pub extern "C" fn valid_b() {
}
#[doc = "foo bar baz"]
/// a doc comment
// a normal comment
#[doc(alias = "ADocAlias")]
#[naked]
pub unsafe extern "C" fn compatible_doc_attributes() {
asm!("", options(noreturn, raw));