1
1
//! Contains `ParseSess` which holds state living beyond what one `Parser` might.
2
2
//! It also serves as an input to the parser itself.
3
3
4
- use crate :: ast:: { CrateConfig , NodeId , Attribute } ;
4
+ use crate :: ast:: { CrateConfig , NodeId } ;
5
5
use crate :: early_buffered_lints:: { BufferedEarlyLint , BufferedEarlyLintId } ;
6
6
use crate :: source_map:: { SourceMap , FilePathMapping } ;
7
7
use crate :: feature_gate:: UnstableFeatures ;
@@ -89,40 +89,26 @@ pub struct ParseSess {
89
89
pub gated_spans : GatedSpans ,
90
90
/// The parser has reached `Eof` due to an unclosed brace. Used to silence unnecessary errors.
91
91
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 ,
102
92
}
103
93
104
- pub type ProcessCfgMod = fn ( & ParseSess , bool , & [ Attribute ] ) -> ( bool , Vec < Attribute > ) ;
105
-
106
94
impl ParseSess {
107
- pub fn new ( file_path_mapping : FilePathMapping , process_cfg_mod : ProcessCfgMod ) -> Self {
95
+ pub fn new ( file_path_mapping : FilePathMapping ) -> Self {
108
96
let cm = Lrc :: new ( SourceMap :: new ( file_path_mapping) ) ;
109
97
let handler = Handler :: with_tty_emitter (
110
98
ColorConfig :: Auto ,
111
99
true ,
112
100
None ,
113
101
Some ( cm. clone ( ) ) ,
114
102
) ;
115
- ParseSess :: with_span_handler ( handler, cm, process_cfg_mod )
103
+ ParseSess :: with_span_handler ( handler, cm)
116
104
}
117
105
118
106
pub fn with_span_handler (
119
107
handler : Handler ,
120
108
source_map : Lrc < SourceMap > ,
121
- process_cfg_mod : ProcessCfgMod ,
122
109
) -> Self {
123
110
Self {
124
111
span_diagnostic : handler,
125
- process_cfg_mod,
126
112
unstable_features : UnstableFeatures :: from_environment ( ) ,
127
113
config : FxHashSet :: default ( ) ,
128
114
edition : ExpnId :: root ( ) . expn_data ( ) . edition ,
@@ -138,10 +124,10 @@ impl ParseSess {
138
124
}
139
125
}
140
126
141
- pub fn with_silent_emitter ( process_cfg_mod : ProcessCfgMod ) -> Self {
127
+ pub fn with_silent_emitter ( ) -> Self {
142
128
let cm = Lrc :: new ( SourceMap :: new ( FilePathMapping :: empty ( ) ) ) ;
143
129
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)
145
131
}
146
132
147
133
#[ inline]
0 commit comments