@@ -1030,34 +1030,20 @@ impl Default for CfgInfo {
10301030 }
10311031}
10321032
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 ) {
10391034 if let MetaItemInner :: MetaItem ( item) = sub_attr
10401035 && let MetaItemKind :: List ( items) = & item. kind
10411036 {
10421037 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) ;
10561044 }
10571045 }
10581046 }
1059- } else {
1060- tcx. sess . dcx ( ) . struct_span_err ( sub_attr. span ( ) , "unexpected `auto_cfg` value kind" ) . emit ( ) ;
10611047 }
10621048}
10631049
@@ -1143,14 +1129,7 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
11431129 sym:: doc if let Some ( attrs) = attr. meta_item_list ( ) => {
11441130 for attr in attrs. iter ( ) . filter ( |attr| attr. has_name ( sym:: auto_cfg) ) {
11451131 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 ;
11541133 } ;
11551134 match & attr. kind {
11561135 MetaItemKind :: Word => {
@@ -1175,14 +1154,6 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
11751154 changed_auto_active_status = Some ( attr. span ) ;
11761155 }
11771156 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 ( ) ;
11861157 }
11871158 }
11881159 MetaItemKind :: List ( sub_attrs) => {
@@ -1197,34 +1168,14 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
11971168 // Whatever happens next, the feature is enabled again.
11981169 cfg_info. doc_auto_cfg_active = true ;
11991170 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+ {
12111174 handle_auto_cfg_hide_show (
1212- tcx,
12131175 cfg_info,
12141176 & sub_attr,
12151177 ident. name == sym:: show,
12161178 ) ;
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 ( ) ;
12281179 }
12291180 }
12301181 }
0 commit comments