Skip to content

Commit 4607cc6

Browse files
committed
Pass down edition to ParseSess
1 parent b2a7b94 commit 4607cc6

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/librustc/session/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,8 @@ pub fn build_session_(
10961096
};
10971097
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
10981098

1099-
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap);
1099+
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap,
1100+
sopts.debugging_opts.edition);
11001101
let default_sysroot = match sopts.maybe_sysroot {
11011102
Some(_) => None,
11021103
None => Some(filesearch::get_or_default_sysroot()),

src/libsyntax/parse/lexer/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,6 +1778,7 @@ mod tests {
17781778
use symbol::Symbol;
17791779
use syntax_pos::{BytePos, Span, NO_EXPANSION};
17801780
use codemap::CodeMap;
1781+
use edition::Edition;
17811782
use errors;
17821783
use feature_gate::UnstableFeatures;
17831784
use parse::token;
@@ -1802,6 +1803,7 @@ mod tests {
18021803
raw_identifier_spans: Lock::new(Vec::new()),
18031804
registered_diagnostics: Lock::new(ErrorMap::new()),
18041805
non_modrs_mods: Lock::new(vec![]),
1806+
edition: Edition::Edition2015,
18051807
}
18061808
}
18071809

src/libsyntax/parse/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_data_structures::sync::{Lrc, Lock};
1414
use ast::{self, CrateConfig};
1515
use codemap::{CodeMap, FilePathMapping};
1616
use syntax_pos::{self, Span, FileMap, NO_EXPANSION, FileName};
17+
use edition::Edition;
1718
use errors::{Handler, ColorConfig, DiagnosticBuilder};
1819
use feature_gate::UnstableFeatures;
1920
use parse::parser::Parser;
@@ -54,6 +55,7 @@ pub struct ParseSess {
5455
// Spans where a `mod foo;` statement was included in a non-mod.rs file.
5556
// These are used to issue errors if the non_modrs_mods feature is not enabled.
5657
pub non_modrs_mods: Lock<Vec<(ast::Ident, Span)>>,
58+
pub edition: Edition,
5759
/// Used to determine and report recursive mod inclusions
5860
included_mod_stack: Lock<Vec<PathBuf>>,
5961
code_map: Lrc<CodeMap>,
@@ -66,10 +68,11 @@ impl ParseSess {
6668
true,
6769
false,
6870
Some(cm.clone()));
69-
ParseSess::with_span_handler(handler, cm)
71+
ParseSess::with_span_handler(handler, cm, Edition::Edition2015)
7072
}
7173

72-
pub fn with_span_handler(handler: Handler, code_map: Lrc<CodeMap>) -> ParseSess {
74+
pub fn with_span_handler(handler: Handler, code_map: Lrc<CodeMap>,
75+
edition: Edition) -> ParseSess {
7376
ParseSess {
7477
span_diagnostic: handler,
7578
unstable_features: UnstableFeatures::from_environment(),
@@ -80,6 +83,7 @@ impl ParseSess {
8083
included_mod_stack: Lock::new(vec![]),
8184
code_map,
8285
non_modrs_mods: Lock::new(vec![]),
86+
edition,
8387
}
8488
}
8589

0 commit comments

Comments
 (0)