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