File tree 3 files changed +30
-0
lines changed
rustc_error_messages/locales/en-US
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 =
145
145
passes_doc_primitive =
146
146
`doc(primitive)` should never have been stable
147
147
148
+ passes_doc_cfg_hide_takes_list =
149
+ `#[doc(cfg_hide(...)]` takes a list of attributes
150
+
148
151
passes_doc_test_unknown_any =
149
152
unknown `doc` attribute `{ $path } `
150
153
Original file line number Diff line number Diff line change @@ -934,6 +934,22 @@ impl CheckAttrVisitor<'_> {
934
934
is_valid
935
935
}
936
936
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
+
937
953
/// Runs various checks on `#[doc]` attributes. Returns `true` if valid.
938
954
///
939
955
/// `specified_inline` should be initialized to `None` and kept for the scope
@@ -987,6 +1003,13 @@ impl CheckAttrVisitor<'_> {
987
1003
is_valid = false ;
988
1004
}
989
1005
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
+
990
1013
sym:: inline | sym:: no_inline
991
1014
if !self . check_doc_inline (
992
1015
attr,
Original file line number Diff line number Diff line change @@ -271,6 +271,10 @@ pub struct DocTestUnknown {
271
271
#[ diag( passes:: doc_test_takes_list) ]
272
272
pub struct DocTestTakesList ;
273
273
274
+ #[ derive( LintDiagnostic ) ]
275
+ #[ diag( passes:: doc_cfg_hide_takes_list) ]
276
+ pub struct DocCfgHideTakesList ;
277
+
274
278
#[ derive( LintDiagnostic ) ]
275
279
#[ diag( passes:: doc_primitive) ]
276
280
pub struct DocPrimitive ;
You can’t perform that action at this time.
0 commit comments