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:
Alex Crichton 2015-02-26 21:00:43 -08:00
parent 3b3bb0e682
commit 95d904625b
80 changed files with 1430 additions and 1209 deletions

View file

@ -9,6 +9,6 @@
// except according to those terms.
// compile-flags: --extern std=
// error-pattern: is not a file
// error-pattern: can't find crate for `std`
fn main() {}

View file

@ -9,10 +9,10 @@
// except according to those terms.
#[path = "circular_modules_hello.rs"]
mod circular_modules_hello; //~ERROR: circular modules
mod circular_modules_hello; //~ ERROR: circular modules
pub fn hi_str() -> String {
"Hi!".to_string()
"Hi!".to_string()
}
fn main() {

View file

@ -8,15 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-windows
// ignore-freebsd
#[path = "../compile-fail"]
mod foo; //~ ERROR: a directory

View file

@ -18,6 +18,8 @@ use rustc::session::config::{basic_options, build_configuration, Input, OutputTy
use rustc_driver::driver::{compile_input, CompileController};
use syntax::diagnostics::registry::Registry;
use std::path::PathBuf;
fn main() {
let src = r#"
fn main() {}
@ -29,9 +31,9 @@ fn main() {
panic!("expected rustc path");
}
let tmpdir = Path::new(&args[1]);
let tmpdir = PathBuf::new(&args[1]);
let mut sysroot = Path::new(&args[3]);
let mut sysroot = PathBuf::new(&args[3]);
sysroot.pop();
sysroot.pop();
@ -40,7 +42,7 @@ fn main() {
compile(src.to_string(), tmpdir.join("out"), sysroot.clone());
}
fn basic_sess(sysroot: Path) -> Session {
fn basic_sess(sysroot: PathBuf) -> Session {
let mut opts = basic_options();
opts.output_types = vec![OutputTypeExe];
opts.maybe_sysroot = Some(sysroot);
@ -51,7 +53,7 @@ fn basic_sess(sysroot: Path) -> Session {
sess
}
fn compile(code: String, output: Path, sysroot: Path) {
fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
let sess = basic_sess(sysroot);
let cfg = build_configuration(&sess);
let control = CompileController::basic();

View file

@ -25,6 +25,7 @@ use rustc::session::config::{self, Input};
use rustc_driver::{driver, CompilerCalls, Compilation};
use syntax::diagnostics;
use std::path::PathBuf;
struct TestCalls {
count: u32
@ -43,14 +44,15 @@ impl<'a> CompilerCalls<'a> for TestCalls {
_: &getopts::Matches,
_: &Session,
_: &Input,
_: &Option<Path>,
_: &Option<Path>)
_: &Option<PathBuf>,
_: &Option<PathBuf>)
-> Compilation {
self.count *= 3;
Compilation::Stop
}
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>) {
self.count *= 5;
(input, input_path)
}
@ -58,10 +60,10 @@ impl<'a> CompilerCalls<'a> for TestCalls {
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>)> {
panic!("This shouldn't happen");
}