@@ -12,9 +12,8 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
1212use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
1313use rustc_hir:: def_id:: { CrateNum , DefId , LOCAL_CRATE , LocalDefId } ;
1414use rustc_hir:: lang_items:: LangItem ;
15- use rustc_hir:: { BodyId , HirId , Mutability } ;
15+ use rustc_hir:: { BodyId , Mutability } ;
1616use rustc_index:: IndexVec ;
17- use rustc_lint_defs:: { BuiltinLintDiag , Lint } ;
1817use rustc_metadata:: rendered_const;
1918use rustc_middle:: span_bug;
2019use rustc_middle:: ty:: fast_reject:: SimplifiedType ;
@@ -478,12 +477,7 @@ impl Item {
478477 name,
479478 kind,
480479 Attributes :: from_hir ( hir_attrs) ,
481- extract_cfg_from_attrs (
482- hir_attrs. iter ( ) ,
483- cx. tcx ,
484- def_id. as_local ( ) . map ( |did| cx. tcx . local_def_id_to_hir_id ( did) ) ,
485- & cx. cache . hidden_cfg ,
486- ) ,
480+ extract_cfg_from_attrs ( hir_attrs. iter ( ) , cx. tcx , & cx. cache . hidden_cfg ) ,
487481 )
488482 }
489483
@@ -1039,7 +1033,6 @@ pub(crate) fn hir_attr_lists<'a, I: IntoIterator<Item = &'a hir::Attribute>>(
10391033pub ( crate ) fn extract_cfg_from_attrs < ' a , I : Iterator < Item = & ' a hir:: Attribute > + Clone > (
10401034 attrs : I ,
10411035 tcx : TyCtxt < ' _ > ,
1042- hir_id : Option < HirId > ,
10431036 hidden_cfg : & FxHashSet < Cfg > ,
10441037) -> Option < Arc < Cfg > > {
10451038 let doc_cfg_active = tcx. features ( ) . doc_cfg ( ) ;
@@ -1064,42 +1057,10 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
10641057 if doc_cfg. peek ( ) . is_some ( ) && doc_cfg_active {
10651058 let sess = tcx. sess ;
10661059
1067- struct RustdocCfgMatchesLintEmitter < ' a > ( TyCtxt < ' a > , Option < HirId > ) ;
1068-
1069- impl < ' a > rustc_attr_parsing:: CfgMatchesLintEmitter for RustdocCfgMatchesLintEmitter < ' a > {
1070- fn emit_span_lint (
1071- & self ,
1072- sess : & Session ,
1073- lint : & ' static Lint ,
1074- sp : rustc_span:: Span ,
1075- builtin_diag : BuiltinLintDiag ,
1076- ) {
1077- if let Some ( hir_id) = self . 1 {
1078- self . 0 . node_span_lint ( lint, hir_id, sp, |diag| {
1079- rustc_lint:: decorate_builtin_lint (
1080- sess,
1081- Some ( self . 0 ) ,
1082- builtin_diag,
1083- diag,
1084- )
1085- } ) ;
1086- } else {
1087- // No HIR id. Probably in another crate. Don't lint.
1088- }
1089- }
1090- }
1091-
10921060 doc_cfg. fold ( Cfg :: True , |mut cfg, item| {
10931061 if let Some ( cfg_mi) =
10941062 item. meta_item ( ) . and_then ( |item| rustc_expand:: config:: parse_cfg ( item, sess) )
10951063 {
1096- // The result is unused here but we can gate unstable predicates
1097- rustc_attr_parsing:: cfg_matches (
1098- cfg_mi,
1099- tcx. sess ,
1100- RustdocCfgMatchesLintEmitter ( tcx, hir_id) ,
1101- Some ( tcx. features ( ) ) ,
1102- ) ;
11031064 match Cfg :: parse ( cfg_mi) {
11041065 Ok ( new_cfg) => cfg &= new_cfg,
11051066 Err ( e) => {
0 commit comments