File tree Expand file tree Collapse file tree 7 files changed +32
-10
lines changed Expand file tree Collapse file tree 7 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,9 @@ passes_doc_auto_cfg_expects_hide_or_show =
149149passes_doc_auto_cfg_hide_show_expects_list =
150150 `#![doc(auto_cfg({ $attr_name } (...)))]` only expects a list of items
151151
152+ passes_doc_auto_cfg_hide_show_unexpected_item =
153+ `#![doc(auto_cfg({ $attr_name } (...)))]` only accepts identifiers or key/values items
154+
152155passes_doc_auto_cfg_wrong_literal =
153156 `expected boolean for #[doc(auto_cfg = ...)]`
154157
Original file line number Diff line number Diff line change @@ -1187,7 +1187,20 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
11871187 meta. span ,
11881188 errors:: DocAutoCfgExpectsHideOrShow ,
11891189 ) ;
1190- } else if item. meta_item_list ( ) . is_none ( ) {
1190+ } else if let Some ( list) = item. meta_item_list ( ) {
1191+ for item in list {
1192+ if item. meta_item_list ( ) . is_some ( ) {
1193+ self . tcx . emit_node_span_lint (
1194+ INVALID_DOC_ATTRIBUTES ,
1195+ hir_id,
1196+ item. span ( ) ,
1197+ errors:: DocAutoCfgHideShowUnexpectedItem {
1198+ attr_name : attr_name. as_str ( ) ,
1199+ } ,
1200+ ) ;
1201+ }
1202+ }
1203+ } else {
11911204 self . tcx . emit_node_span_lint (
11921205 INVALID_DOC_ATTRIBUTES ,
11931206 hir_id,
Original file line number Diff line number Diff line change @@ -322,6 +322,12 @@ pub(crate) struct DocAutoCfgHideShowExpectsList<'a> {
322322 pub attr_name : & ' a str ,
323323}
324324
325+ #[ derive( LintDiagnostic ) ]
326+ #[ diag( passes_doc_auto_cfg_hide_show_unexpected_item) ]
327+ pub ( crate ) struct DocAutoCfgHideShowUnexpectedItem < ' a > {
328+ pub attr_name : & ' a str ,
329+ }
330+
325331#[ derive( LintDiagnostic ) ]
326332#[ diag( passes_doc_test_unknown_any) ]
327333pub ( crate ) struct DocTestUnknownAny {
Original file line number Diff line number Diff line change 7878#![ cfg_attr(
7979 not( bootstrap) ,
8080 doc( auto_cfg( hide(
81- test,
8281 no_global_oom_handling,
8382 no_rc,
8483 no_sync,
Original file line number Diff line number Diff line change 243243 not( no_global_oom_handling)
244244 ) )
245245) ]
246- #![ cfg_attr(
247- not( bootstrap) ,
248- doc( auto_cfg( hide(
249- test,
250- no_global_oom_handling,
251- ) ) )
252- ) ]
246+ #![ cfg_attr( not( bootstrap) , doc( auto_cfg( hide( no_global_oom_handling) ) ) ) ]
253247// Don't link to std. We are std.
254248#![ no_std]
255249// Tell the compiler to link to either panic_abort or panic_unwind
Original file line number Diff line number Diff line change 11#![ doc( auto_cfg( hide = "test" ) ) ] //~ ERROR
22#![ doc( auto_cfg( hide) ) ] //~ ERROR
3+ #![ doc( auto_cfg( hide( not( windows) ) ) ) ] //~ ERROR
Original file line number Diff line number Diff line change @@ -12,5 +12,11 @@ error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
1212LL | #![doc(auto_cfg(hide))]
1313 | ^^^^^^^^^^^^^^
1414
15- error: aborting due to 2 previous errors
15+ error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/values items
16+ --> $DIR/doc_cfg_hide.rs:3:22
17+ |
18+ LL | #![doc(auto_cfg(hide(not(windows))))]
19+ | ^^^^^^^^^^^^
20+
21+ error: aborting due to 3 previous errors
1622
You can’t perform that action at this time.
0 commit comments