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.
This commit is contained in:
parent
3b3bb0e682
commit
95d904625b
80 changed files with 1430 additions and 1209 deletions
|
@ -34,6 +34,10 @@
|
|||
#![feature(test)]
|
||||
#![feature(unicode)]
|
||||
#![feature(str_words)]
|
||||
#![feature(io)]
|
||||
#![feature(fs)]
|
||||
#![feature(path)]
|
||||
#![feature(tempdir)]
|
||||
|
||||
extern crate arena;
|
||||
extern crate getopts;
|
||||
|
@ -53,10 +57,12 @@ extern crate "serialize" as rustc_serialize; // used by deriving
|
|||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::old_io::File;
|
||||
use std::old_io;
|
||||
use std::fs::File;
|
||||
use std::io::{self, Read, Write};
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
use std::sync::mpsc::channel;
|
||||
|
||||
use externalfiles::ExternalHtml;
|
||||
use serialize::Decodable;
|
||||
use serialize::json::{self, Json};
|
||||
|
@ -242,7 +248,7 @@ pub fn main_args(args: &[String]) -> int {
|
|||
let should_test = matches.opt_present("test");
|
||||
let markdown_input = input.ends_with(".md") || input.ends_with(".markdown");
|
||||
|
||||
let output = matches.opt_str("o").map(|s| Path::new(s));
|
||||
let output = matches.opt_str("o").map(|s| PathBuf::new(&s));
|
||||
let cfgs = matches.opt_strs("cfg");
|
||||
|
||||
let external_html = match ExternalHtml::load(
|
||||
|
@ -261,7 +267,8 @@ pub fn main_args(args: &[String]) -> int {
|
|||
(true, false) => {
|
||||
return test::run(input, cfgs, libs, externs, test_args, crate_name)
|
||||
}
|
||||
(false, true) => return markdown::render(input, output.unwrap_or(Path::new("doc")),
|
||||
(false, true) => return markdown::render(input,
|
||||
output.unwrap_or(PathBuf::new("doc")),
|
||||
&matches, &external_html,
|
||||
!matches.opt_present("markdown-no-toc")),
|
||||
(false, false) => {}
|
||||
|
@ -278,7 +285,8 @@ pub fn main_args(args: &[String]) -> int {
|
|||
info!("going to format");
|
||||
match matches.opt_str("w").as_ref().map(|s| &**s) {
|
||||
Some("html") | None => {
|
||||
match html::render::run(krate, &external_html, output.unwrap_or(Path::new("doc")),
|
||||
match html::render::run(krate, &external_html,
|
||||
output.unwrap_or(PathBuf::new("doc")),
|
||||
passes.into_iter().collect()) {
|
||||
Ok(()) => {}
|
||||
Err(e) => panic!("failed to generate documentation: {}", e),
|
||||
|
@ -286,7 +294,7 @@ pub fn main_args(args: &[String]) -> int {
|
|||
}
|
||||
Some("json") => {
|
||||
match json_output(krate, json_plugins,
|
||||
output.unwrap_or(Path::new("doc.json"))) {
|
||||
output.unwrap_or(PathBuf::new("doc.json"))) {
|
||||
Ok(()) => {}
|
||||
Err(e) => panic!("failed to write json: {}", e),
|
||||
}
|
||||
|
@ -364,15 +372,15 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
|
|||
let cfgs = matches.opt_strs("cfg");
|
||||
let triple = matches.opt_str("target");
|
||||
|
||||
let cr = Path::new(cratefile);
|
||||
let cr = PathBuf::new(cratefile);
|
||||
info!("starting to run rustc");
|
||||
|
||||
let (tx, rx) = channel();
|
||||
std::thread::spawn(move || {
|
||||
use rustc::session::config::Input;
|
||||
|
||||
let cr = cr;
|
||||
tx.send(core::run_core(paths, cfgs, externs, Input::File(cr), triple)).unwrap();
|
||||
tx.send(core::run_core(paths, cfgs, externs, Input::File(cr),
|
||||
triple)).unwrap();
|
||||
}).join().map_err(|_| "rustc failed").unwrap();
|
||||
let (mut krate, analysis) = rx.recv().unwrap();
|
||||
info!("finished with rustc");
|
||||
|
@ -451,13 +459,12 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
|
|||
/// This input format purely deserializes the json output file. No passes are
|
||||
/// run over the deserialized output.
|
||||
fn json_input(input: &str) -> Result<Output, String> {
|
||||
let mut input = match File::open(&Path::new(input)) {
|
||||
Ok(f) => f,
|
||||
Err(e) => {
|
||||
return Err(format!("couldn't open {}: {}", input, e))
|
||||
}
|
||||
let mut bytes = Vec::new();
|
||||
match File::open(input).and_then(|mut f| f.read_to_end(&mut bytes)) {
|
||||
Ok(()) => {}
|
||||
Err(e) => return Err(format!("couldn't open {}: {}", input, e)),
|
||||
};
|
||||
match json::from_reader(&mut input) {
|
||||
match json::from_reader(&mut &bytes[..]) {
|
||||
Err(s) => Err(format!("{:?}", s)),
|
||||
Ok(Json::Object(obj)) => {
|
||||
let mut obj = obj;
|
||||
|
@ -495,7 +502,7 @@ fn json_input(input: &str) -> Result<Output, String> {
|
|||
/// Outputs the crate/plugin json as a giant json blob at the specified
|
||||
/// destination.
|
||||
fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
|
||||
dst: Path) -> old_io::IoResult<()> {
|
||||
dst: PathBuf) -> io::Result<()> {
|
||||
// {
|
||||
// "schema": version,
|
||||
// "crate": { parsed crate ... },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue