File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
rustc_error_messages/locales/en-US Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,9 @@ passes_doc_test_takes_list =
145145passes_doc_primitive =
146146 `doc(primitive)` should never have been stable
147147
148+ passes_doc_cfg_hide_takes_list =
149+ `#[doc(cfg_hide(...)]` takes a list of attributes
150+
148151passes_doc_test_unknown_any =
149152 unknown `doc` attribute `{ $path } `
150153
Original file line number Diff line number Diff line change @@ -934,6 +934,22 @@ impl CheckAttrVisitor<'_> {
934934 is_valid
935935 }
936936
937+ /// Check that the `#![doc(cfg_hide(...))]` attribute only contains a list of attributes.
938+ /// Returns `true` if valid.
939+ fn check_doc_cfg_hide ( & self , meta : & NestedMetaItem , hir_id : HirId ) -> bool {
940+ if meta. meta_item_list ( ) . is_some ( ) {
941+ true
942+ } else {
943+ self . tcx . emit_spanned_lint (
944+ INVALID_DOC_ATTRIBUTES ,
945+ hir_id,
946+ meta. span ( ) ,
947+ errors:: DocCfgHideTakesList ,
948+ ) ;
949+ false
950+ }
951+ }
952+
937953 /// Runs various checks on `#[doc]` attributes. Returns `true` if valid.
938954 ///
939955 /// `specified_inline` should be initialized to `None` and kept for the scope
@@ -987,6 +1003,13 @@ impl CheckAttrVisitor<'_> {
9871003 is_valid = false ;
9881004 }
9891005
1006+ sym:: cfg_hide
1007+ if !self . check_attr_crate_level ( attr, meta, hir_id)
1008+ || !self . check_doc_cfg_hide ( meta, hir_id) =>
1009+ {
1010+ is_valid = false ;
1011+ }
1012+
9901013 sym:: inline | sym:: no_inline
9911014 if !self . check_doc_inline (
9921015 attr,
Original file line number Diff line number Diff line change @@ -271,6 +271,10 @@ pub struct DocTestUnknown {
271271#[ diag( passes:: doc_test_takes_list) ]
272272pub struct DocTestTakesList ;
273273
274+ #[ derive( LintDiagnostic ) ]
275+ #[ diag( passes:: doc_cfg_hide_takes_list) ]
276+ pub struct DocCfgHideTakesList ;
277+
274278#[ derive( LintDiagnostic ) ]
275279#[ diag( passes:: doc_primitive) ]
276280pub struct DocPrimitive ;
You can’t perform that action at this time.
0 commit comments