Skip to content

Commit

Permalink
Pass down edition to ParseSess
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Apr 10, 2018
1 parent b2a7b94 commit 4607cc6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,8 @@ pub fn build_session_(
};
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);

let p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap);
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap,
sopts.debugging_opts.edition);
let default_sysroot = match sopts.maybe_sysroot {
Some(_) => None,
None => Some(filesearch::get_or_default_sysroot()),
Expand Down
2 changes: 2 additions & 0 deletions src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,7 @@ mod tests {
use symbol::Symbol;
use syntax_pos::{BytePos, Span, NO_EXPANSION};
use codemap::CodeMap;
use edition::Edition;
use errors;
use feature_gate::UnstableFeatures;
use parse::token;
Expand All @@ -1802,6 +1803,7 @@ mod tests {
raw_identifier_spans: Lock::new(Vec::new()),
registered_diagnostics: Lock::new(ErrorMap::new()),
non_modrs_mods: Lock::new(vec![]),
edition: Edition::Edition2015,
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/libsyntax/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use rustc_data_structures::sync::{Lrc, Lock};
use ast::{self, CrateConfig};
use codemap::{CodeMap, FilePathMapping};
use syntax_pos::{self, Span, FileMap, NO_EXPANSION, FileName};
use edition::Edition;
use errors::{Handler, ColorConfig, DiagnosticBuilder};
use feature_gate::UnstableFeatures;
use parse::parser::Parser;
Expand Down Expand Up @@ -54,6 +55,7 @@ pub struct ParseSess {
// Spans where a `mod foo;` statement was included in a non-mod.rs file.
// These are used to issue errors if the non_modrs_mods feature is not enabled.
pub non_modrs_mods: Lock<Vec<(ast::Ident, Span)>>,
pub edition: Edition,
/// Used to determine and report recursive mod inclusions
included_mod_stack: Lock<Vec<PathBuf>>,
code_map: Lrc<CodeMap>,
Expand All @@ -66,10 +68,11 @@ impl ParseSess {
true,
false,
Some(cm.clone()));
ParseSess::with_span_handler(handler, cm)
ParseSess::with_span_handler(handler, cm, Edition::Edition2015)
}

pub fn with_span_handler(handler: Handler, code_map: Lrc<CodeMap>) -> ParseSess {
pub fn with_span_handler(handler: Handler, code_map: Lrc<CodeMap>,
edition: Edition) -> ParseSess {
ParseSess {
span_diagnostic: handler,
unstable_features: UnstableFeatures::from_environment(),
Expand All @@ -80,6 +83,7 @@ impl ParseSess {
included_mod_stack: Lock::new(vec![]),
code_map,
non_modrs_mods: Lock::new(vec![]),
edition,
}
}

Expand Down

0 comments on commit 4607cc6

Please sign in to comment.