Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: Tweak the std::env OsString/String interface #22188

Merged
merged 1 commit into from
Feb 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#![feature(collections)]
#![feature(int_uint)]
#![feature(io)]
#![feature(os)]
#![feature(path)]
#![feature(rustc_private)]
#![feature(slicing_syntax, unboxed_closures)]
Expand Down Expand Up @@ -48,8 +47,7 @@ pub mod common;
pub mod errors;

pub fn main() {
let args = env::args().map(|s| s.into_string().unwrap()).collect();;
let config = parse_config(args);
let config = parse_config(env::args().collect());

if config.valgrind_path.is_none() && config.force_valgrind {
panic!("Can't find Valgrind to run Valgrind tests");
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn make_new_path(path: &str) -> String {

// Windows just uses PATH as the library search path, so we have to
// maintain the current value while adding our own
match env::var_string(lib_path_env_var()) {
match env::var(lib_path_env_var()) {
Ok(curr) => {
format!("{}{}{}", path, path_div(), curr)
}
Expand Down
2 changes: 1 addition & 1 deletion src/liblog/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ fn enabled(level: u32,
/// This is not threadsafe at all, so initialization is performed through a
/// `Once` primitive (and this function is called from that primitive).
fn init() {
let (mut directives, filter) = match env::var_string("RUST_LOG") {
let (mut directives, filter) = match env::var("RUST_LOG") {
Ok(spec) => directive::parse_logging_spec(&spec[]),
Err(..) => (Vec::new(), None),
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static PATH_ENTRY_SEPARATOR: &'static str = ":";

/// Returns RUST_PATH as a string, without default paths added
pub fn get_rust_path() -> Option<String> {
env::var_string("RUST_PATH").ok()
env::var("RUST_PATH").ok()
}

/// Returns the value of RUST_PATH, as a list
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/infer/region_inference/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
}

let requested_node : Option<ast::NodeId> =
env::var_string("RUST_REGION_GRAPH_NODE").ok().and_then(|s| s.parse().ok());
env::var("RUST_REGION_GRAPH_NODE").ok().and_then(|s| s.parse().ok());

if requested_node.is_some() && requested_node != Some(subject_node) {
return;
}

let requested_output = env::var_string("RUST_REGION_GRAPH").ok();
let requested_output = env::var("RUST_REGION_GRAPH").ok();
debug!("requested_output: {:?} requested_node: {:?}",
requested_output, requested_node);

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ pub fn get_unstable_features_setting() -> UnstableFeatures {
// subverting the unstable features lints
let bootstrap_secret_key = option_env!("CFG_BOOTSTRAP_KEY");
// The matching key to the above, only known by the build system
let bootstrap_provided_key = env::var_string("RUSTC_BOOTSTRAP_KEY").ok();
let bootstrap_provided_key = env::var("RUSTC_BOOTSTRAP_KEY").ok();
match (disable_unstable_features, bootstrap_secret_key, bootstrap_provided_key) {
(_, Some(ref s), Some(ref p)) if s == p => UnstableFeatures::Cheat,
(true, _, _) => UnstableFeatures::Disallow,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ impl Target {
Path::new(target)
};

let target_path = env::var("RUST_TARGET_PATH")
let target_path = env::var_os("RUST_TARGET_PATH")
.unwrap_or(OsString::from_str(""));

// FIXME 16351: add a sane default search path?
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
// compiler, not for the target.
let mut _old_path = OsString::from_str("");
if cfg!(windows) {
_old_path = env::var("PATH").unwrap_or(_old_path);
_old_path = env::var_os("PATH").unwrap_or(_old_path);
let mut new_path = sess.host_filesearch(PathKind::All).get_dylib_search_paths();
new_path.extend(env::split_paths(&_old_path));
env::set_var("PATH", &env::join_paths(new_path.iter()).unwrap());
Expand Down Expand Up @@ -737,7 +737,7 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
pub fn phase_6_link_output(sess: &Session,
trans: &trans::CrateTranslation,
outputs: &OutputFilenames) {
let old_path = env::var("PATH").unwrap_or(OsString::from_str(""));
let old_path = env::var_os("PATH").unwrap_or(OsString::from_str(""));
let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths();
new_path.extend(env::split_paths(&old_path));
env::set_var("PATH", &env::join_paths(new_path.iter()).unwrap());
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ pub fn monitor<F:FnOnce()+Send>(f: F) {

// FIXME: Hacks on hacks. If the env is trying to override the stack size
// then *don't* set it explicitly.
if env::var("RUST_MIN_STACK").is_none() {
if env::var_os("RUST_MIN_STACK").is_none() {
cfg = cfg.stack_size(STACK_SIZE);
}

Expand Down Expand Up @@ -835,8 +835,7 @@ pub fn diagnostics_registry() -> diagnostics::registry::Registry {
}

pub fn main() {
let args = env::args().map(|s| s.into_string().unwrap());
let result = run(args.collect());
let result = run(env::args().collect());
std::env::set_exit_status(result as i32);
}

2 changes: 1 addition & 1 deletion src/librustc_trans/save/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,7 @@ pub fn process_crate(sess: &Session,
info!("Dumping crate {}", cratename);

// find a path to dump our data to
let mut root_path = match env::var_string("DXR_RUST_TEMP_FOLDER") {
let mut root_path = match env::var("DXR_RUST_TEMP_FOLDER") {
Ok(val) => Path::new(val),
Err(..) => match odir {
Some(val) => val.join("dxr"),
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ struct Output {
}

pub fn main() {
static STACK_SIZE: uint = 32000000; // 32MB
const STACK_SIZE: usize = 32000000; // 32MB
let res = std::thread::Builder::new().stack_size(STACK_SIZE).scoped(move || {
let s = env::args().map(|s| s.into_string().unwrap());
main_args(&s.collect::<Vec<_>>())
let s = env::args().collect::<Vec<_>>();
main_args(&s)
}).join();
env::set_exit_status(res.ok().unwrap() as i32);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/dynamic_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl DynamicLibrary {
/// Returns the current search path for dynamic libraries being used by this
/// process
pub fn search_path() -> Vec<Path> {
match env::var(DynamicLibrary::envvar()) {
match env::var_os(DynamicLibrary::envvar()) {
Some(var) => env::split_paths(&var).collect(),
None => Vec::new(),
}
Expand Down
Loading