11//! Contains `ParseSess` which holds state living beyond what one `Parser` might.
22//! It also serves as an input to the parser itself.
33
4- use crate :: ast:: { CrateConfig , NodeId , Attribute } ;
4+ use crate :: ast:: { CrateConfig , NodeId } ;
55use crate :: early_buffered_lints:: { BufferedEarlyLint , BufferedEarlyLintId } ;
66use crate :: source_map:: { SourceMap , FilePathMapping } ;
77use crate :: feature_gate:: UnstableFeatures ;
@@ -89,40 +89,26 @@ pub struct ParseSess {
8989 pub gated_spans : GatedSpans ,
9090 /// The parser has reached `Eof` due to an unclosed brace. Used to silence unnecessary errors.
9191 pub reached_eof : Lock < bool > ,
92- /// Process the potential `cfg` attributes on a module.
93- /// Also determine if the module should be included in this configuration.
94- ///
95- /// HACK(Centril): This is used to break a cyclic dependency between
96- /// the parser and cfg-stripping as defined in `syntax_expand::config`.
97- /// The dependency edge from the parser comes from `parse_item_mod`.
98- /// A principled solution to this hack would be to implement [#64197].
99- ///
100- /// [#64197]: https://github.com/rust-lang/rust/issues/64197
101- pub process_cfg_mod : ProcessCfgMod ,
10292}
10393
104- pub type ProcessCfgMod = fn ( & ParseSess , bool , & [ Attribute ] ) -> ( bool , Vec < Attribute > ) ;
105-
10694impl ParseSess {
107- pub fn new ( file_path_mapping : FilePathMapping , process_cfg_mod : ProcessCfgMod ) -> Self {
95+ pub fn new ( file_path_mapping : FilePathMapping ) -> Self {
10896 let cm = Lrc :: new ( SourceMap :: new ( file_path_mapping) ) ;
10997 let handler = Handler :: with_tty_emitter (
11098 ColorConfig :: Auto ,
11199 true ,
112100 None ,
113101 Some ( cm. clone ( ) ) ,
114102 ) ;
115- ParseSess :: with_span_handler ( handler, cm, process_cfg_mod )
103+ ParseSess :: with_span_handler ( handler, cm)
116104 }
117105
118106 pub fn with_span_handler (
119107 handler : Handler ,
120108 source_map : Lrc < SourceMap > ,
121- process_cfg_mod : ProcessCfgMod ,
122109 ) -> Self {
123110 Self {
124111 span_diagnostic : handler,
125- process_cfg_mod,
126112 unstable_features : UnstableFeatures :: from_environment ( ) ,
127113 config : FxHashSet :: default ( ) ,
128114 edition : ExpnId :: root ( ) . expn_data ( ) . edition ,
@@ -138,10 +124,10 @@ impl ParseSess {
138124 }
139125 }
140126
141- pub fn with_silent_emitter ( process_cfg_mod : ProcessCfgMod ) -> Self {
127+ pub fn with_silent_emitter ( ) -> Self {
142128 let cm = Lrc :: new ( SourceMap :: new ( FilePathMapping :: empty ( ) ) ) ;
143129 let handler = Handler :: with_emitter ( false , None , Box :: new ( SilentEmitter ) ) ;
144- ParseSess :: with_span_handler ( handler, cm, process_cfg_mod )
130+ ParseSess :: with_span_handler ( handler, cm)
145131 }
146132
147133 #[ inline]
0 commit comments