@@ -1004,7 +1004,6 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
1004
1004
tcx : TyCtxt < ' _ > ,
1005
1005
hidden_cfg : & FxHashSet < Cfg > ,
1006
1006
) -> Option < Arc < Cfg > > {
1007
- let sess = tcx. sess ;
1008
1007
let doc_cfg_active = tcx. features ( ) . doc_cfg ( ) ;
1009
1008
let doc_auto_cfg_active = tcx. features ( ) . doc_auto_cfg ( ) ;
1010
1009
@@ -1025,9 +1024,14 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
1025
1024
. filter ( |attr| attr. has_name ( sym:: cfg) )
1026
1025
. peekable ( ) ;
1027
1026
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
+ } )
1031
1035
} else if doc_auto_cfg_active {
1032
1036
// If there is no `doc(cfg())`, then we retrieve the `cfg()` attributes (because
1033
1037
// `doc(cfg())` overrides `cfg()`).
@@ -1044,33 +1048,6 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
1044
1048
Cfg :: True
1045
1049
} ;
1046
1050
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
-
1074
1051
// treat #[target_feature(enable = "feat")] attributes as if they were
1075
1052
// #[doc(cfg(target_feature = "feat"))] attributes as well
1076
1053
for attr in hir_attr_lists ( attrs, sym:: target_feature) {
0 commit comments