@@ -1004,7 +1004,6 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
10041004 tcx : TyCtxt < ' _ > ,
10051005 hidden_cfg : & FxHashSet < Cfg > ,
10061006) -> Option < Arc < Cfg > > {
1007- let sess = tcx. sess ;
10081007 let doc_cfg_active = tcx. features ( ) . doc_cfg ( ) ;
10091008 let doc_auto_cfg_active = tcx. features ( ) . doc_auto_cfg ( ) ;
10101009
@@ -1025,9 +1024,14 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
10251024 . filter ( |attr| attr. has_name ( sym:: cfg) )
10261025 . peekable ( ) ;
10271026 if doc_cfg. peek ( ) . is_some ( ) && doc_cfg_active {
1028- doc_cfg
1029- . filter_map ( |attr| Cfg :: parse ( & attr) . ok ( ) )
1030- . fold ( Cfg :: True , |cfg, new_cfg| cfg & new_cfg)
1027+ doc_cfg. fold ( Cfg :: True , |mut cfg, attr| {
1028+ for attr in attr. meta_item_list ( ) . unwrap_or_default ( ) {
1029+ if let Ok ( new_cfg) = Cfg :: parse ( & attr) {
1030+ cfg &= new_cfg;
1031+ }
1032+ }
1033+ cfg
1034+ } )
10311035 } else if doc_auto_cfg_active {
10321036 // If there is no `doc(cfg())`, then we retrieve the `cfg()` attributes (because
10331037 // `doc(cfg())` overrides `cfg()`).
@@ -1044,33 +1048,6 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
10441048 Cfg :: True
10451049 } ;
10461050
1047- for attr in attrs. clone ( ) {
1048- // #[doc]
1049- if attr. doc_str ( ) . is_none ( ) && attr. has_name ( sym:: doc) {
1050- // #[doc(...)]
1051- if let Some ( list) = attr. meta_item_list ( ) {
1052- for item in list {
1053- // #[doc(hidden)]
1054- if !item. has_name ( sym:: cfg) {
1055- continue ;
1056- }
1057- // #[doc(cfg(...))]
1058- if let Some ( cfg_mi) = item
1059- . meta_item ( )
1060- . and_then ( |item| rustc_expand:: config:: parse_cfg ( item, sess) )
1061- {
1062- match Cfg :: parse ( cfg_mi) {
1063- Ok ( new_cfg) => cfg &= new_cfg,
1064- Err ( e) => {
1065- sess. dcx ( ) . span_err ( e. span , e. msg ) ;
1066- }
1067- }
1068- }
1069- }
1070- }
1071- }
1072- }
1073-
10741051 // treat #[target_feature(enable = "feat")] attributes as if they were
10751052 // #[doc(cfg(target_feature = "feat"))] attributes as well
10761053 for attr in hir_attr_lists ( attrs, sym:: target_feature) {
0 commit comments