Skip to content

Commit 432528c

Browse files
committed
make /// doc comments compatible with naked functions
1 parent 3954398 commit 432528c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

compiler/rustc_passes/src/check_attr.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,11 @@ 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 both `#[doc = "..."]` and `/// ...`
464+
if other_attr.is_doc_comment() {
465+
continue;
466+
}
467+
463468
if !ALLOW_LIST.iter().any(|name| other_attr.has_name(*name)) {
464469
self.dcx().emit_err(errors::NakedFunctionIncompatibleAttribute {
465470
span: other_attr.span,

tests/ui/asm/naked-functions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ pub unsafe extern "C" fn compatible_target_feature() {
239239
}
240240

241241
#[doc = "foo bar baz"]
242+
/// a doc comment
243+
// a normal comment
242244
#[naked]
243245
pub unsafe extern "C" fn compatible_doc_attributes() {
244246
asm!("", options(noreturn, raw));

0 commit comments

Comments
 (0)