]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/sess.rs
Move BufferedEarlyLint to librustc_session
[rust.git] / src / libsyntax / sess.rs
index 953f0d1d190bbb3bbd5229b30d4bbc1ec87c9c94..555e8a134f7835bb70aed2abf1c8a84633c79bad 100644 (file)
@@ -1,17 +1,17 @@
 //! Contains `ParseSess` which holds state living beyond what one `Parser` might.
 //! It also serves as an input to the parser itself.
 
-use crate::ast::{CrateConfig, NodeId, Attribute};
-use crate::early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId};
-use crate::source_map::{SourceMap, FilePathMapping};
-use crate::feature_gate::UnstableFeatures;
+use crate::ast::{CrateConfig, NodeId};
+use crate::early_buffered_lints::BufferedEarlyLint;
 
 use errors::{Applicability, emitter::SilentEmitter, Handler, ColorConfig, DiagnosticBuilder};
 use rustc_data_structures::fx::{FxHashSet, FxHashMap};
 use rustc_data_structures::sync::{Lrc, Lock, Once};
+use rustc_feature::UnstableFeatures;
 use syntax_pos::{Symbol, Span, MultiSpan};
 use syntax_pos::edition::Edition;
 use syntax_pos::hygiene::ExpnId;
+use syntax_pos::source_map::{SourceMap, FilePathMapping};
 
 use std::path::PathBuf;
 use std::str;
@@ -89,22 +89,10 @@ pub struct ParseSess {
     pub gated_spans: GatedSpans,
     /// The parser has reached `Eof` due to an unclosed brace. Used to silence unnecessary errors.
     pub reached_eof: Lock<bool>,
-    /// Process the potential `cfg` attributes on a module.
-    /// Also determine if the module should be included in this configuration.
-    ///
-    /// HACK(Centril): This is used to break a cyclic dependency between
-    /// the parser and cfg-stripping as defined in `syntax_expand::config`.
-    /// The dependency edge from the parser comes from `parse_item_mod`.
-    /// A principled solution to this hack would be to implement [#64197].
-    ///
-    /// [#64197]: https://github.com/rust-lang/rust/issues/64197
-    pub process_cfg_mod: ProcessCfgMod,
 }
 
-pub type ProcessCfgMod = fn(&ParseSess, bool, &[Attribute]) -> (bool, Vec<Attribute>);
-
 impl ParseSess {
-    pub fn new(file_path_mapping: FilePathMapping, process_cfg_mod: ProcessCfgMod) -> Self {
+    pub fn new(file_path_mapping: FilePathMapping) -> Self {
         let cm = Lrc::new(SourceMap::new(file_path_mapping));
         let handler = Handler::with_tty_emitter(
             ColorConfig::Auto,
@@ -112,17 +100,15 @@ pub fn new(file_path_mapping: FilePathMapping, process_cfg_mod: ProcessCfgMod) -
             None,
             Some(cm.clone()),
         );
-        ParseSess::with_span_handler(handler, cm, process_cfg_mod)
+        ParseSess::with_span_handler(handler, cm)
     }
 
     pub fn with_span_handler(
         handler: Handler,
         source_map: Lrc<SourceMap>,
-        process_cfg_mod: ProcessCfgMod,
     ) -> Self {
         Self {
             span_diagnostic: handler,
-            process_cfg_mod,
             unstable_features: UnstableFeatures::from_environment(),
             config: FxHashSet::default(),
             edition: ExpnId::root().expn_data().edition,
@@ -138,10 +124,10 @@ pub fn with_span_handler(
         }
     }
 
-    pub fn with_silent_emitter(process_cfg_mod: ProcessCfgMod) -> Self {
+    pub fn with_silent_emitter() -> Self {
         let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
         let handler = Handler::with_emitter(false, None, Box::new(SilentEmitter));
-        ParseSess::with_span_handler(handler, cm, process_cfg_mod)
+        ParseSess::with_span_handler(handler, cm)
     }
 
     #[inline]
@@ -151,7 +137,7 @@ pub fn source_map(&self) -> &SourceMap {
 
     pub fn buffer_lint(
         &self,
-        lint_id: BufferedEarlyLintId,
+        lint_id: &'static rustc_session::lint::Lint,
         span: impl Into<MultiSpan>,
         id: NodeId,
         msg: &str,