@@ -1030,34 +1030,20 @@ impl Default for CfgInfo {
1030
1030
}
1031
1031
}
1032
1032
1033
- fn handle_auto_cfg_hide_show (
1034
- tcx : TyCtxt < ' _ > ,
1035
- cfg_info : & mut CfgInfo ,
1036
- sub_attr : & MetaItemInner ,
1037
- is_show : bool ,
1038
- ) {
1033
+ fn handle_auto_cfg_hide_show ( cfg_info : & mut CfgInfo , sub_attr : & MetaItemInner , is_show : bool ) {
1039
1034
if let MetaItemInner :: MetaItem ( item) = sub_attr
1040
1035
&& let MetaItemKind :: List ( items) = & item. kind
1041
1036
{
1042
1037
for item in items {
1043
- match Cfg :: parse ( item) {
1044
- Ok ( cfg) => {
1045
- if is_show {
1046
- cfg_info. hidden_cfg . remove ( & cfg) ;
1047
- } else {
1048
- cfg_info. hidden_cfg . insert ( cfg) ;
1049
- }
1050
- }
1051
- Err ( _) => {
1052
- tcx. sess
1053
- . dcx ( )
1054
- . struct_span_err ( sub_attr. span ( ) , "unexpected `auto_cfg` value" )
1055
- . emit ( ) ;
1038
+ // Errors should already have been reported in `rustc_passes::check_attr`.
1039
+ if let Ok ( cfg) = Cfg :: parse ( item) {
1040
+ if is_show {
1041
+ cfg_info. hidden_cfg . remove ( & cfg) ;
1042
+ } else {
1043
+ cfg_info. hidden_cfg . insert ( cfg) ;
1056
1044
}
1057
1045
}
1058
1046
}
1059
- } else {
1060
- tcx. sess . dcx ( ) . struct_span_err ( sub_attr. span ( ) , "unexpected `auto_cfg` value kind" ) . emit ( ) ;
1061
1047
}
1062
1048
}
1063
1049
@@ -1143,14 +1129,7 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
1143
1129
sym:: doc if let Some ( attrs) = attr. meta_item_list ( ) => {
1144
1130
for attr in attrs. iter ( ) . filter ( |attr| attr. has_name ( sym:: auto_cfg) ) {
1145
1131
let MetaItemInner :: MetaItem ( attr) = attr else {
1146
- tcx. sess
1147
- . dcx ( )
1148
- . struct_span_err (
1149
- attr. span ( ) ,
1150
- "unexpected value in `auto_cfg` attribute" ,
1151
- )
1152
- . emit ( ) ;
1153
- break ' main;
1132
+ continue ;
1154
1133
} ;
1155
1134
match & attr. kind {
1156
1135
MetaItemKind :: Word => {
@@ -1175,14 +1154,6 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
1175
1154
changed_auto_active_status = Some ( attr. span ) ;
1176
1155
}
1177
1156
cfg_info. doc_auto_cfg_active = value;
1178
- } else {
1179
- tcx. sess
1180
- . dcx ( )
1181
- . struct_span_err (
1182
- attr. span ,
1183
- "unexpected value for `auto_cfg` attribute" ,
1184
- )
1185
- . emit ( ) ;
1186
1157
}
1187
1158
}
1188
1159
MetaItemKind :: List ( sub_attrs) => {
@@ -1197,34 +1168,14 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
1197
1168
// Whatever happens next, the feature is enabled again.
1198
1169
cfg_info. doc_auto_cfg_active = true ;
1199
1170
for sub_attr in sub_attrs. iter ( ) {
1200
- let Some ( ident) = sub_attr. ident ( ) else {
1201
- tcx. sess
1202
- . dcx ( )
1203
- . struct_span_err (
1204
- attr. span ,
1205
- "unexpected value for `auto_cfg` attribute" ,
1206
- )
1207
- . emit ( ) ;
1208
- continue ;
1209
- } ;
1210
- if ident. name == sym:: show || ident. name == sym:: hide {
1171
+ if let Some ( ident) = sub_attr. ident ( )
1172
+ && ( ident. name == sym:: show || ident. name == sym:: hide)
1173
+ {
1211
1174
handle_auto_cfg_hide_show (
1212
- tcx,
1213
1175
cfg_info,
1214
1176
& sub_attr,
1215
1177
ident. name == sym:: show,
1216
1178
) ;
1217
- } else {
1218
- tcx. sess
1219
- . dcx ( )
1220
- . struct_span_err (
1221
- attr. span ,
1222
- format ! (
1223
- "unknown value `{}` for `auto_cfg` attribute" ,
1224
- ident. name
1225
- ) ,
1226
- )
1227
- . emit ( ) ;
1228
1179
}
1229
1180
}
1230
1181
}
0 commit comments