diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-26 21:00:43 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-04 15:59:30 -0800 |
| commit | 95d904625b4d45af80b4e40d51a3a0fde1abaa8a (patch) | |
| tree | b0872e63b8d75543ce5141ceba44c12c459474f2 /src/librustc_driver/lib.rs | |
| parent | 3b3bb0e682c2d252e9f62dd9df5cff9552af91ad (diff) | |
| download | rust-95d904625b4d45af80b4e40d51a3a0fde1abaa8a.tar.gz rust-95d904625b4d45af80b4e40d51a3a0fde1abaa8a.zip | |
std: Deprecate std::old_io::fs
This commit deprecates the majority of std::old_io::fs in favor of std::fs and its new functionality. Some functions remain non-deprecated but are now behind a feature gate called `old_fs`. These functions will be deprecated once suitable replacements have been implemented. The compiler has been migrated to new `std::fs` and `std::path` APIs where appropriate as part of this change.
Diffstat (limited to 'src/librustc_driver/lib.rs')
| -rw-r--r-- | src/librustc_driver/lib.rs | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 15fae351ddb..aa8b7c7785d 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -30,7 +30,6 @@ #![feature(old_io)] #![feature(libc)] #![feature(os)] -#![feature(old_path)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] @@ -38,6 +37,9 @@ #![feature(staged_api)] #![feature(unicode)] #![feature(exit_status)] +#![feature(path)] +#![feature(io)] +#![feature(fs)] extern crate arena; extern crate flate; @@ -73,9 +75,10 @@ use rustc::metadata; use rustc::util::common::time; use std::cmp::Ordering::Equal; -use std::old_io::{self, stdio}; -use std::iter::repeat; use std::env; +use std::iter::repeat; +use std::old_io::{self, stdio}; +use std::path::PathBuf; use std::sync::mpsc::channel; use std::thread; @@ -159,14 +162,14 @@ pub fn run_compiler<'a>(args: &[String], } // Extract output directory and file from matches. -fn make_output(matches: &getopts::Matches) -> (Option<Path>, Option<Path>) { - let odir = matches.opt_str("out-dir").map(|o| Path::new(o)); - let ofile = matches.opt_str("o").map(|o| Path::new(o)); +fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>) { + let odir = matches.opt_str("out-dir").map(|o| PathBuf::new(&o)); + let ofile = matches.opt_str("o").map(|o| PathBuf::new(&o)); (odir, ofile) } // Extract input (string or file and optional path) from matches. -fn make_input(free_matches: &[String]) -> Option<(Input, Option<Path>)> { +fn make_input(free_matches: &[String]) -> Option<(Input, Option<PathBuf>)> { if free_matches.len() == 1 { let ifile = &free_matches[0][..]; if ifile == "-" { @@ -174,7 +177,7 @@ fn make_input(free_matches: &[String]) -> Option<(Input, Option<Path>)> { let src = String::from_utf8(contents).unwrap(); Some((Input::Str(src), None)) } else { - Some((Input::File(Path::new(ifile)), Some(Path::new(ifile)))) + Some((Input::File(PathBuf::new(ifile)), Some(PathBuf::new(ifile)))) } } else { None @@ -215,14 +218,15 @@ pub trait CompilerCalls<'a> { &getopts::Matches, &Session, &Input, - &Option<Path>, - &Option<Path>) + &Option<PathBuf>, + &Option<PathBuf>) -> Compilation; // Called after we extract the input from the arguments. Gives the implementer // an opportunity to change the inputs or to add some custom input handling. // The default behaviour is to simply pass through the inputs. - fn some_input(&mut self, input: Input, input_path: Option<Path>) -> (Input, Option<Path>) { + fn some_input(&mut self, input: Input, input_path: Option<PathBuf>) + -> (Input, Option<PathBuf>) { (input, input_path) } @@ -234,10 +238,10 @@ pub trait CompilerCalls<'a> { fn no_input(&mut self, &getopts::Matches, &config::Options, - &Option<Path>, - &Option<Path>, + &Option<PathBuf>, + &Option<PathBuf>, &diagnostics::registry::Registry) - -> Option<(Input, Option<Path>)>; + -> Option<(Input, Option<PathBuf>)>; // Parse pretty printing information from the arguments. The implementer can // choose to ignore this (the default will return None) which will skip pretty @@ -293,10 +297,10 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls { fn no_input(&mut self, matches: &getopts::Matches, sopts: &config::Options, - odir: &Option<Path>, - ofile: &Option<Path>, + odir: &Option<PathBuf>, + ofile: &Option<PathBuf>, descriptions: &diagnostics::registry::Registry) - -> Option<(Input, Option<Path>)> { + -> Option<(Input, Option<PathBuf>)> { match matches.free.len() { 0 => { if sopts.describe_lints { @@ -346,8 +350,8 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls { matches: &getopts::Matches, sess: &Session, input: &Input, - odir: &Option<Path>, - ofile: &Option<Path>) + odir: &Option<PathBuf>, + ofile: &Option<PathBuf>) -> Compilation { RustcDefaultCalls::print_crate_info(sess, Some(input), odir, ofile).and_then( || RustcDefaultCalls::list_metadata(sess, matches, input)) @@ -400,11 +404,12 @@ impl RustcDefaultCalls { if r.contains(&("ls".to_string())) { match input { &Input::File(ref ifile) => { - let mut stdout = old_io::stdout(); let path = &(*ifile); + let mut v = Vec::new(); metadata::loader::list_file_metadata(sess.target.target.options.is_like_osx, path, - &mut stdout).unwrap(); + &mut v).unwrap(); + println!("{}", String::from_utf8(v).unwrap()); } &Input::Str(_) => { early_error("cannot list metadata for stdin"); @@ -419,8 +424,8 @@ impl RustcDefaultCalls { fn print_crate_info(sess: &Session, input: Option<&Input>, - odir: &Option<Path>, - ofile: &Option<Path>) + odir: &Option<PathBuf>, + ofile: &Option<PathBuf>) -> Compilation { if sess.opts.prints.len() == 0 { return Compilation::Continue; @@ -457,7 +462,8 @@ impl RustcDefaultCalls { style, &id, &t_outputs.with_extension("")); - println!("{}", fname.filename_display()); + println!("{}", fname.file_name().unwrap() + .to_string_lossy()); } } } |
