@@ -1251,35 +1251,20 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
1251
1251
// If there is no `doc(cfg())`, then we retrieve the `cfg()` attributes (because
1252
1252
// `doc(cfg())` overrides `cfg()`).
1253
1253
for attr in attrs {
1254
- let Some ( ident) = attr. ident ( ) else { continue } ;
1255
- match ident. name {
1256
- sym:: cfg | sym:: cfg_trace if !cfg_info. parent_is_doc_cfg => {
1257
- if let Some ( attr) = single ( attr. meta_item_list ( ) ?)
1258
- && let Ok ( new_cfg) = Cfg :: parse ( & attr)
1259
- {
1260
- cfg_info. current_cfg &= new_cfg;
1261
- }
1262
- }
1254
+ if let hir:: Attribute :: Parsed ( AttributeKind :: TargetFeature ( features, _) ) = attr {
1263
1255
// treat #[target_feature(enable = "feat")] attributes as if they were
1264
1256
// #[doc(cfg(target_feature = "feat"))] attributes as well
1265
- sym:: target_feature
1266
- if let Some ( attrs) = attr. meta_item_list ( ) =>
1267
- {
1268
- for attr in attrs {
1269
- if attr. has_name ( sym:: enable) && attr. value_str ( ) . is_some ( ) {
1270
- // Clone `enable = "feat"`, change to `target_feature = "feat"`.
1271
- // Unwrap is safe because `value_str` succeeded above.
1272
- let mut meta = attr. meta_item ( ) . unwrap ( ) . clone ( ) ;
1273
- meta. path =
1274
- ast:: Path :: from_ident ( Ident :: with_dummy_span ( sym:: target_feature) ) ;
1275
-
1276
- if let Ok ( feat_cfg) = Cfg :: parse ( & ast:: MetaItemInner :: MetaItem ( meta) ) {
1277
- cfg_info. current_cfg &= feat_cfg;
1278
- }
1279
- }
1280
- }
1257
+ for ( feature, _) in features {
1258
+ cfg_info. current_cfg &= Cfg :: Cfg ( sym:: target_feature, Some ( * feature) ) ;
1281
1259
}
1282
- _ => { }
1260
+ continue ;
1261
+ } else if !cfg_info. parent_is_doc_cfg
1262
+ && let Some ( ident) = attr. ident ( )
1263
+ && matches ! ( ident. name, sym:: cfg | sym:: cfg_trace)
1264
+ && let Some ( attr) = single ( attr. meta_item_list ( ) ?)
1265
+ && let Ok ( new_cfg) = Cfg :: parse ( & attr)
1266
+ {
1267
+ cfg_info. current_cfg &= new_cfg;
1283
1268
}
1284
1269
}
1285
1270
0 commit comments