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 @@ -167,6 +167,9 @@ passes_doc_auto_cfg_expects_hide_or_show =
167
167
passes_doc_auto_cfg_hide_show_expects_list =
168
168
`#![doc(auto_cfg({ $attr_name } (...)))]` only expects a list of items
169
169
170
+ passes_doc_auto_cfg_hide_show_unexpected_item =
171
+ `#![doc(auto_cfg({ $attr_name } (...)))]` only accepts identifiers or key/values items
172
+
170
173
passes_doc_auto_cfg_wrong_literal =
171
174
`expected boolean for #[doc(auto_cfg = ...)]`
172
175
Original file line number Diff line number Diff line change @@ -1361,7 +1361,20 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1361
1361
meta. span ,
1362
1362
errors:: DocAutoCfgExpectsHideOrShow ,
1363
1363
) ;
1364
- } else if item. meta_item_list ( ) . is_none ( ) {
1364
+ } else if let Some ( list) = item. meta_item_list ( ) {
1365
+ for item in list {
1366
+ if item. meta_item_list ( ) . is_some ( ) {
1367
+ self . tcx . emit_node_span_lint (
1368
+ INVALID_DOC_ATTRIBUTES ,
1369
+ hir_id,
1370
+ item. span ( ) ,
1371
+ errors:: DocAutoCfgHideShowUnexpectedItem {
1372
+ attr_name : attr_name. as_str ( ) ,
1373
+ } ,
1374
+ ) ;
1375
+ }
1376
+ }
1377
+ } else {
1365
1378
self . tcx . emit_node_span_lint (
1366
1379
INVALID_DOC_ATTRIBUTES ,
1367
1380
hir_id,
Original file line number Diff line number Diff line change @@ -345,6 +345,12 @@ pub(crate) struct DocAutoCfgHideShowExpectsList<'a> {
345
345
pub attr_name : & ' a str ,
346
346
}
347
347
348
+ #[ derive( LintDiagnostic ) ]
349
+ #[ diag( passes_doc_auto_cfg_hide_show_unexpected_item) ]
350
+ pub ( crate ) struct DocAutoCfgHideShowUnexpectedItem < ' a > {
351
+ pub attr_name : & ' a str ,
352
+ }
353
+
348
354
#[ derive( LintDiagnostic ) ]
349
355
#[ diag( passes_doc_test_unknown_any) ]
350
356
pub ( crate ) struct DocTestUnknownAny {
Original file line number Diff line number Diff line change 78
78
#![ cfg_attr(
79
79
not( bootstrap) ,
80
80
doc( auto_cfg( hide(
81
- test,
82
81
no_global_oom_handling,
83
82
no_rc,
84
83
no_sync,
Original file line number Diff line number Diff line change 243
243
not( no_global_oom_handling)
244
244
) )
245
245
) ]
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) ) ) ) ]
253
247
// Don't link to std. We are std.
254
248
#![ no_std]
255
249
// Tell the compiler to link to either panic_abort or panic_unwind
Original file line number Diff line number Diff line change 1
1
#![ doc( auto_cfg( hide = "test" ) ) ] //~ ERROR
2
2
#![ 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
12
12
LL | #![doc(auto_cfg(hide))]
13
13
| ^^^^^^^^^^^^^^
14
14
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
16
22
You can’t perform that action at this time.
0 commit comments