1
Fork 0

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 @@ 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,