Rollup merge of #128380 - folkertdev:naked-compatible-doc-comment, r=bjorn3
make `///` doc comments compatible with naked functions tracking issue: https://github.com/rust-lang/rust/issues/90957 reported in https://github.com/rust-lang/rust/pull/127853#issuecomment-2257323333 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``
This commit is contained in:
commit
e6a82d2878
@ -461,6 +461,12 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
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,
|
||||
|
@ -239,6 +239,9 @@ pub unsafe extern "C" fn compatible_target_feature() {
|
||||
}
|
||||
|
||||
#[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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user