Skip to content

Commit b40ae5f

Browse files
committed
Wire EnvSandbox into the ParseSess
1 parent 13904d5 commit b40ae5f

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

src/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc/session/mod.rs

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

1055-
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap);
1055+
let env_sb = Lrc::new(sopts.env_sb.clone());
1056+
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap, env_sb);
10561057
let default_sysroot = match sopts.maybe_sysroot {
10571058
Some(_) => None,
10581059
None => Some(filesearch::get_or_default_sysroot()),

src/libsyntax/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ syntax_pos = { path = "../libsyntax_pos" }
1717
rustc_cratesio_shim = { path = "../librustc_cratesio_shim" }
1818
rustc_errors = { path = "../librustc_errors" }
1919
rustc_data_structures = { path = "../librustc_data_structures" }
20+
env_sandbox = { path = "../librustc_env_sandbox" }

src/libsyntax/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub extern crate rustc_errors as errors;
4040
extern crate syntax_pos;
4141
extern crate rustc_data_structures;
4242
#[macro_use] extern crate scoped_tls;
43+
extern crate env_sandbox;
4344

4445
extern crate serialize as rustc_serialize; // used by deriving
4546

src/libsyntax/parse/lexer/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,6 +1787,7 @@ mod tests {
17871787
use diagnostics::plugin::ErrorMap;
17881788
use rustc_data_structures::sync::Lock;
17891789
use with_globals;
1790+
use env_sandbox::EnvSandbox;
17901791
fn mk_sess(cm: Lrc<CodeMap>) -> ParseSess {
17911792
let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()),
17921793
Some(cm.clone()),
@@ -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+
env_sandbox: Lrc::new(EnvSandbox::default()),
18051807
}
18061808
}
18071809

src/libsyntax/parse/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use str::char_at;
2222
use symbol::Symbol;
2323
use tokenstream::{TokenStream, TokenTree};
2424
use diagnostics::plugin::ErrorMap;
25+
use env_sandbox::EnvSandbox;
2526

2627
use std::collections::HashSet;
2728
use std::iter;
@@ -57,6 +58,7 @@ pub struct ParseSess {
5758
/// Used to determine and report recursive mod inclusions
5859
included_mod_stack: Lock<Vec<PathBuf>>,
5960
code_map: Lrc<CodeMap>,
61+
env_sandbox: Lrc<EnvSandbox>,
6062
}
6163

6264
impl ParseSess {
@@ -66,10 +68,12 @@ impl ParseSess {
6668
true,
6769
false,
6870
Some(cm.clone()));
69-
ParseSess::with_span_handler(handler, cm)
71+
let env_sb = Lrc::new(EnvSandbox::default());
72+
ParseSess::with_span_handler(handler, cm, env_sb)
7073
}
7174

72-
pub fn with_span_handler(handler: Handler, code_map: Lrc<CodeMap>) -> ParseSess {
75+
pub fn with_span_handler(handler: Handler, code_map: Lrc<CodeMap>, env_sandbox: Lrc<EnvSandbox>)
76+
-> ParseSess {
7377
ParseSess {
7478
span_diagnostic: handler,
7579
unstable_features: UnstableFeatures::from_environment(),
@@ -80,12 +84,17 @@ impl ParseSess {
8084
included_mod_stack: Lock::new(vec![]),
8185
code_map,
8286
non_modrs_mods: Lock::new(vec![]),
87+
env_sandbox,
8388
}
8489
}
8590

8691
pub fn codemap(&self) -> &CodeMap {
8792
&self.code_map
8893
}
94+
95+
pub fn env_sandbox(&self) -> &EnvSandbox {
96+
&self.env_sandbox
97+
}
8998
}
9099

91100
#[derive(Clone)]

0 commit comments

Comments
 (0)