@@ -1153,35 +1153,20 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
11531153 // If there is no `doc(cfg())`, then we retrieve the `cfg()` attributes (because
11541154 // `doc(cfg())` overrides `cfg()`).
11551155 for attr in attrs {
1156- let Some ( ident) = attr. ident ( ) else { continue } ;
1157- match ident. name {
1158- sym:: cfg | sym:: cfg_trace if !cfg_info. parent_is_doc_cfg => {
1159- if let Some ( attr) = single ( attr. meta_item_list ( ) ?)
1160- && let Ok ( new_cfg) = Cfg :: parse ( & attr)
1161- {
1162- cfg_info. current_cfg &= new_cfg;
1163- }
1164- }
1156+ if let hir:: Attribute :: Parsed ( AttributeKind :: TargetFeature { features, .. } ) = attr {
11651157 // treat #[target_feature(enable = "feat")] attributes as if they were
11661158 // #[doc(cfg(target_feature = "feat"))] attributes as well
1167- sym:: target_feature
1168- if let Some ( attrs) = attr. meta_item_list ( ) =>
1169- {
1170- for attr in attrs {
1171- if attr. has_name ( sym:: enable) && attr. value_str ( ) . is_some ( ) {
1172- // Clone `enable = "feat"`, change to `target_feature = "feat"`.
1173- // Unwrap is safe because `value_str` succeeded above.
1174- let mut meta = attr. meta_item ( ) . unwrap ( ) . clone ( ) ;
1175- meta. path =
1176- ast:: Path :: from_ident ( Ident :: with_dummy_span ( sym:: target_feature) ) ;
1177-
1178- if let Ok ( feat_cfg) = Cfg :: parse ( & ast:: MetaItemInner :: MetaItem ( meta) ) {
1179- cfg_info. current_cfg &= feat_cfg;
1180- }
1181- }
1182- }
1159+ for ( feature, _) in features {
1160+ cfg_info. current_cfg &= Cfg :: Cfg ( sym:: target_feature, Some ( * feature) ) ;
11831161 }
1184- _ => { }
1162+ continue ;
1163+ } else if !cfg_info. parent_is_doc_cfg
1164+ && let Some ( ident) = attr. ident ( )
1165+ && matches ! ( ident. name, sym:: cfg | sym:: cfg_trace)
1166+ && let Some ( attr) = single ( attr. meta_item_list ( ) ?)
1167+ && let Ok ( new_cfg) = Cfg :: parse ( & attr)
1168+ {
1169+ cfg_info. current_cfg &= new_cfg;
11851170 }
11861171 }
11871172
0 commit comments