Add missing checks for doc(cfg_hide(...))
attribute
This commit is contained in:
parent
1755c85302
commit
f528414e40
3 changed files with 30 additions and 0 deletions
compiler
|
@ -145,6 +145,9 @@ passes_doc_test_takes_list =
|
||||||
passes_doc_primitive =
|
passes_doc_primitive =
|
||||||
`doc(primitive)` should never have been stable
|
`doc(primitive)` should never have been stable
|
||||||
|
|
||||||
|
passes_doc_cfg_hide_takes_list =
|
||||||
|
`#[doc(cfg_hide(...)]` takes a list of attributes
|
||||||
|
|
||||||
passes_doc_test_unknown_any =
|
passes_doc_test_unknown_any =
|
||||||
unknown `doc` attribute `{$path}`
|
unknown `doc` attribute `{$path}`
|
||||||
|
|
||||||
|
|
|
@ -934,6 +934,22 @@ impl CheckAttrVisitor<'_> {
|
||||||
is_valid
|
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.
|
/// Runs various checks on `#[doc]` attributes. Returns `true` if valid.
|
||||||
///
|
///
|
||||||
/// `specified_inline` should be initialized to `None` and kept for the scope
|
/// `specified_inline` should be initialized to `None` and kept for the scope
|
||||||
|
@ -987,6 +1003,13 @@ impl CheckAttrVisitor<'_> {
|
||||||
is_valid = false;
|
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
|
sym::inline | sym::no_inline
|
||||||
if !self.check_doc_inline(
|
if !self.check_doc_inline(
|
||||||
attr,
|
attr,
|
||||||
|
|
|
@ -271,6 +271,10 @@ pub struct DocTestUnknown {
|
||||||
#[diag(passes::doc_test_takes_list)]
|
#[diag(passes::doc_test_takes_list)]
|
||||||
pub struct DocTestTakesList;
|
pub struct DocTestTakesList;
|
||||||
|
|
||||||
|
#[derive(LintDiagnostic)]
|
||||||
|
#[diag(passes::doc_cfg_hide_takes_list)]
|
||||||
|
pub struct DocCfgHideTakesList;
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(passes::doc_primitive)]
|
#[diag(passes::doc_primitive)]
|
||||||
pub struct DocPrimitive;
|
pub struct DocPrimitive;
|
||||||
|
|
Loading…
Add table
Reference in a new issue