Skip to content

Commit ec3d1dd

Browse files
authored
Unrolled build for rust-lang#128380
Rollup merge of rust-lang#128380 - folkertdev:naked-compatible-doc-comment, r=bjorn3 make `///` doc comments compatible with naked functions tracking issue: rust-lang#90957 reported in rust-lang#127853 (comment) it turns out `/// doc comment` and `#[doc = "doc comment"]` are represented differently, at least at the point where we perform the check for what should be allowed. The `///` style doc comment is now also allowed. r? ``@bjorn3`` cc ``@hsanzg``
2 parents f8060d2 + 58bfd98 commit ec3d1dd

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