diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-03-01 17:12:39 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-03-01 20:26:28 +0100 |
| commit | b0b330f143ba0d6769b0d7da6d9302eef33fca44 (patch) | |
| tree | 36129372ef56681153715d6de49c6797e10e00f8 | |
| parent | 94736c434ee154b30e2ec22ec112b79e3f6c5884 (diff) | |
| download | rust-b0b330f143ba0d6769b0d7da6d9302eef33fca44.tar.gz rust-b0b330f143ba0d6769b0d7da6d9302eef33fca44.zip | |
Validate meta items used in \#\[doc(...)\]
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index cf08881cd47..afd1642bbd5 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -544,6 +544,41 @@ impl CheckAttrVisitor<'tcx> { { return false; } + } else if let Some(i_meta) = meta.meta_item() { + if ![ + sym::cfg, + sym::hidden, + sym::html_favicon_url, + sym::html_logo_url, + sym::html_no_source, + sym::html_playground_url, + sym::html_root_url, + sym::include, + sym::inline, + sym::issue_tracker_base_url, + sym::masked, + sym::no_default_passes, // deprecated + sym::no_inline, + sym::passes, // deprecated + sym::primitive, + sym::spotlight, + sym::test, + ] + .iter() + .any(|m| i_meta.has_name(*m)) + { + self.tcx + .sess + .struct_span_err( + meta.span(), + &format!( + "unknown `doc` attribute `{}`", + i_meta.name_or_empty(), + ), + ) + .emit(); + return false; + } } } } |
