Skip to content

Commit 58bfd98

Browse files
committed
make /// doc comments compatible with naked functions
1 parent 3954398 commit 58bfd98

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

compiler/rustc_passes/src/check_attr.rs

+6
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,12 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
460460
Target::Fn
461461
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => {
462462
for other_attr in attrs {
463+
// this covers "sugared doc comments" of the form `/// ...`
464+
// it does not cover `#[doc = "..."]`, which is handled below
465+
if other_attr.is_doc_comment() {
466+
continue;
467+
}
468+
463469
if !ALLOW_LIST.iter().any(|name| other_attr.has_name(*name)) {
464470
self.dcx().emit_err(errors::NakedFunctionIncompatibleAttribute {
465471
span: other_attr.span,

tests/ui/asm/naked-functions.rs

+3
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ pub unsafe extern "C" fn compatible_target_feature() {
239239
}
240240

241241
#[doc = "foo bar baz"]
242+
/// a doc comment
243+
// a normal comment
244+
#[doc(alias = "ADocAlias")]
242245
#[naked]
243246
pub unsafe extern "C" fn compatible_doc_attributes() {
244247
asm!("", options(noreturn, raw));

0 commit comments

Comments
 (0)