@@ -1224,35 +1224,20 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
12241224 // If there is no `doc(cfg())`, then we retrieve the `cfg()` attributes (because
12251225 // `doc(cfg())` overrides `cfg()`).
12261226 for attr in attrs {
1227- let Some ( ident) = attr. ident ( ) else { continue } ;
1228- match ident. name {
1229- sym:: cfg | sym:: cfg_trace if !cfg_info. parent_is_doc_cfg => {
1230- if let Some ( attr) = single ( attr. meta_item_list ( ) ?)
1231- && let Ok ( new_cfg) = Cfg :: parse ( & attr)
1232- {
1233- cfg_info. current_cfg &= new_cfg;
1234- }
1235- }
1227+ if let hir:: Attribute :: Parsed ( AttributeKind :: TargetFeature ( features, _) ) = attr {
12361228 // treat #[target_feature(enable = "feat")] attributes as if they were
12371229 // #[doc(cfg(target_feature = "feat"))] attributes as well
1238- sym:: target_feature
1239- if let Some ( attrs) = attr. meta_item_list ( ) =>
1240- {
1241- for attr in attrs {
1242- if attr. has_name ( sym:: enable) && attr. value_str ( ) . is_some ( ) {
1243- // Clone `enable = "feat"`, change to `target_feature = "feat"`.
1244- // Unwrap is safe because `value_str` succeeded above.
1245- let mut meta = attr. meta_item ( ) . unwrap ( ) . clone ( ) ;
1246- meta. path =
1247- ast:: Path :: from_ident ( Ident :: with_dummy_span ( sym:: target_feature) ) ;
1248-
1249- if let Ok ( feat_cfg) = Cfg :: parse ( & ast:: MetaItemInner :: MetaItem ( meta) ) {
1250- cfg_info. current_cfg &= feat_cfg;
1251- }
1252- }
1253- }
1230+ for ( feature, _) in features {
1231+ cfg_info. current_cfg &= Cfg :: Cfg ( sym:: target_feature, Some ( * feature) ) ;
12541232 }
1255- _ => { }
1233+ continue ;
1234+ } else if !cfg_info. parent_is_doc_cfg
1235+ && let Some ( ident) = attr. ident ( )
1236+ && matches ! ( ident. name, sym:: cfg | sym:: cfg_trace)
1237+ && let Some ( attr) = single ( attr. meta_item_list ( ) ?)
1238+ && let Ok ( new_cfg) = Cfg :: parse ( & attr)
1239+ {
1240+ cfg_info. current_cfg &= new_cfg;
12561241 }
12571242 }
12581243
0 commit comments