diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-10-15 15:45:32 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-15 15:45:32 +0530 |
| commit | 59e0af68ab42c2c0b98b7e943ecfe01a36d90a94 (patch) | |
| tree | e6a30631c1c2baf953d84061b2314daa672e5234 /compiler/rustc_passes/src | |
| parent | 39ff2a60d610934cd37e7d6ec785f114446e2cbd (diff) | |
| parent | 6f0c2470dbc3eeff7aa243965ec8c3dc7b64e254 (diff) | |
| download | rust-59e0af68ab42c2c0b98b7e943ecfe01a36d90a94.tar.gz rust-59e0af68ab42c2c0b98b7e943ecfe01a36d90a94.zip | |
Rollup merge of #102954 - GuillaumeGomez:cfg-hide-attr-checks, r=Manishearth
Add missing checks for `doc(cfg_hide(...))` Part of #43781. The `doc(cfg_hide(...))` attribute can only be used at the crate level and takes a list of attributes as argument. r? ```@Manishearth```
Diffstat (limited to 'compiler/rustc_passes/src')
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 23 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/errors.rs | 4 |
2 files changed, 27 insertions, 0 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index dab8ae47779..3c684fffac8 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -934,6 +934,22 @@ impl CheckAttrVisitor<'_> { is_valid } + /// Check that the `#![doc(cfg_hide(...))]` attribute only contains a list of attributes. + /// Returns `true` if valid. + fn check_doc_cfg_hide(&self, meta: &NestedMetaItem, hir_id: HirId) -> bool { + if meta.meta_item_list().is_some() { + true + } else { + self.tcx.emit_spanned_lint( + INVALID_DOC_ATTRIBUTES, + hir_id, + meta.span(), + errors::DocCfgHideTakesList, + ); + false + } + } + /// Runs various checks on `#[doc]` attributes. Returns `true` if valid. /// /// `specified_inline` should be initialized to `None` and kept for the scope @@ -987,6 +1003,13 @@ impl CheckAttrVisitor<'_> { is_valid = false; } + sym::cfg_hide + if !self.check_attr_crate_level(attr, meta, hir_id) + || !self.check_doc_cfg_hide(meta, hir_id) => + { + is_valid = false; + } + sym::inline | sym::no_inline if !self.check_doc_inline( attr, diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 1cc81a9ab98..ed548341344 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -272,6 +272,10 @@ pub struct DocTestUnknown { pub struct DocTestTakesList; #[derive(LintDiagnostic)] +#[diag(passes::doc_cfg_hide_takes_list)] +pub struct DocCfgHideTakesList; + +#[derive(LintDiagnostic)] #[diag(passes::doc_primitive)] pub struct DocPrimitive; |
