diff options
| author | mark <markm@cs.wisc.edu> | 2018-07-11 20:54:12 -0500 |
|---|---|---|
| committer | mark <markm@cs.wisc.edu> | 2018-07-23 21:54:43 -0500 |
| commit | 2a7ae04a6872edd8a1bffa620fde53a2eb2964e1 (patch) | |
| tree | 1bac89ee27dfd99f1f5e88fed3182d8d0884e657 /src/libsyntax/parse | |
| parent | 6a1c0637ce44aeea6c60527f4c0e7fb33f2bcd0d (diff) | |
| download | rust-2a7ae04a6872edd8a1bffa620fde53a2eb2964e1.tar.gz rust-2a7ae04a6872edd8a1bffa620fde53a2eb2964e1.zip | |
Extend ParseSess to support buffering lints
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 1754e5f1b9a..5dbf569766e 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -11,9 +11,10 @@ //! The main parser interface use rustc_data_structures::sync::{Lrc, Lock}; -use ast::{self, CrateConfig}; +use ast::{self, CrateConfig, NodeId}; +use early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId}; use codemap::{CodeMap, FilePathMapping}; -use syntax_pos::{Span, FileMap, FileName}; +use syntax_pos::{Span, FileMap, FileName, MultiSpan}; use errors::{Handler, ColorConfig, DiagnosticBuilder}; use feature_gate::UnstableFeatures; use parse::parser::Parser; @@ -57,6 +58,7 @@ pub struct ParseSess { /// Used to determine and report recursive mod inclusions included_mod_stack: Lock<Vec<PathBuf>>, code_map: Lrc<CodeMap>, + pub buffered_lints: Lock<Vec<BufferedEarlyLint>>, } impl ParseSess { @@ -80,12 +82,29 @@ impl ParseSess { included_mod_stack: Lock::new(vec![]), code_map, non_modrs_mods: Lock::new(vec![]), + buffered_lints: Lock::new(vec![]), } } pub fn codemap(&self) -> &CodeMap { &self.code_map } + + pub fn buffer_lint<S: Into<MultiSpan>>(&self, + lint_id: BufferedEarlyLintId, + span: S, + id: NodeId, + msg: &str, + ) { + self.buffered_lints + .borrow_mut() + .push(BufferedEarlyLint{ + span: span.into(), + id, + msg: msg.into(), + lint_id, + }); + } } #[derive(Clone)] |
