Skip to content

Commit b0b330f

Browse files
Validate meta items used in \#\[doc(...)\]
1 parent 94736c4 commit b0b330f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

compiler/rustc_passes/src/check_attr.rs

+35
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,41 @@ impl CheckAttrVisitor<'tcx> {
544544
{
545545
return false;
546546
}
547+
} else if let Some(i_meta) = meta.meta_item() {
548+
if ![
549+
sym::cfg,
550+
sym::hidden,
551+
sym::html_favicon_url,
552+
sym::html_logo_url,
553+
sym::html_no_source,
554+
sym::html_playground_url,
555+
sym::html_root_url,
556+
sym::include,
557+
sym::inline,
558+
sym::issue_tracker_base_url,
559+
sym::masked,
560+
sym::no_default_passes, // deprecated
561+
sym::no_inline,
562+
sym::passes, // deprecated
563+
sym::primitive,
564+
sym::spotlight,
565+
sym::test,
566+
]
567+
.iter()
568+
.any(|m| i_meta.has_name(*m))
569+
{
570+
self.tcx
571+
.sess
572+
.struct_span_err(
573+
meta.span(),
574+
&format!(
575+
"unknown `doc` attribute `{}`",
576+
i_meta.name_or_empty(),
577+
),
578+
)
579+
.emit();
580+
return false;
581+
}
547582
}
548583
}
549584
}

0 commit comments

Comments
 (0)