From 3e39f0bc0e96f76610104918edaa5912f4f352df Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Thu, 29 Jan 2015 14:03:36 -0800 Subject: [PATCH] Rename std::path to std::old_path As part of [RFC 474](https://github.com/rust-lang/rfcs/pull/474), this commit renames `std::path` to `std::old_path`, leaving the existing path API in place to ease migration to the new one. Updating should be as simple as adjusting imports, and the prelude still maps to the old path APIs for now. [breaking-change] --- src/libcore/error.rs | 2 +- src/libgraphviz/maybe_owned_vec.rs | 2 +- src/librustc_back/target/mod.rs | 2 +- src/librustc_trans/trans/debuginfo.rs | 2 +- src/librustdoc/clean/mod.rs | 2 +- src/libserialize/serialize.rs | 18 +++++++++--------- src/libstd/env.rs | 2 +- src/libstd/lib.rs | 1 + src/libstd/old_io/fs.rs | 6 +++--- src/libstd/old_io/net/pipe.rs | 2 +- src/libstd/old_io/process.rs | 2 +- src/libstd/old_io/tempfile.rs | 2 +- src/libstd/{path => old_path}/mod.rs | 0 src/libstd/{path => old_path}/posix.rs | 2 +- src/libstd/{path => old_path}/windows.rs | 2 +- src/libstd/os.rs | 8 ++++---- src/libstd/prelude/v1.rs | 2 +- src/libstd/rand/os.rs | 2 +- src/libstd/sys/common/mod.rs | 2 +- src/libstd/sys/unix/process.rs | 2 +- src/libstd/sys/windows/backtrace.rs | 2 +- src/libstd/sys/windows/process.rs | 2 +- src/libsyntax/parse/token.rs | 2 +- src/test/compile-fail/range-3.rs | 2 +- src/test/compile-fail/range-4.rs | 2 +- src/test/debuginfo/associated-types.rs | 2 +- 26 files changed, 38 insertions(+), 37 deletions(-) rename src/libstd/{path => old_path}/mod.rs (100%) rename src/libstd/{path => old_path}/posix.rs (99%) rename src/libstd/{path => old_path}/windows.rs (99%) diff --git a/src/libcore/error.rs b/src/libcore/error.rs index 71d5e88cccff7..161f6c7892163 100644 --- a/src/libcore/error.rs +++ b/src/libcore/error.rs @@ -51,7 +51,7 @@ //! use std::error::FromError; //! use std::old_io::{File, IoError}; //! use std::os::{MemoryMap, MapError}; -//! use std::path::Path; +//! use std::old_path::Path; //! //! enum MyError { //! Io(IoError), diff --git a/src/libgraphviz/maybe_owned_vec.rs b/src/libgraphviz/maybe_owned_vec.rs index 71f117835935d..1c931856fa17c 100644 --- a/src/libgraphviz/maybe_owned_vec.rs +++ b/src/libgraphviz/maybe_owned_vec.rs @@ -17,7 +17,7 @@ use std::cmp::Ordering; use std::default::Default; use std::fmt; use std::iter::FromIterator; -use std::path::BytesContainer; +use std::old_path::BytesContainer; use std::slice; // Note 1: It is not clear whether the flexibility of providing both diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 4b3833b687c5b..bffee9d49334d 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -306,7 +306,7 @@ impl Target { use std::env; use std::ffi::OsString; use std::old_io::File; - use std::path::Path; + use std::old_path::Path; use serialize::json; fn load_file(path: &Path) -> Result { diff --git a/src/librustc_trans/trans/debuginfo.rs b/src/librustc_trans/trans/debuginfo.rs index 66bb299273d9f..0ced4066f625b 100644 --- a/src/librustc_trans/trans/debuginfo.rs +++ b/src/librustc_trans/trans/debuginfo.rs @@ -1590,7 +1590,7 @@ fn compile_unit_metadata(cx: &CrateContext) -> DIDescriptor { Some(ref p) if p.is_relative() => { // prepend "./" if necessary let dotdot = b".."; - let prefix: &[u8] = &[dotdot[0], ::std::path::SEP_BYTE]; + let prefix: &[u8] = &[dotdot[0], ::std::old_path::SEP_BYTE]; let mut path_bytes = p.as_vec().to_vec(); if &path_bytes[..2] != prefix && diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 07679480bfb39..57eaf042aa02e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -49,7 +49,7 @@ use rustc::middle::stability; use std::rc::Rc; use std::u32; use std::str::Str as StrTrait; // Conflicts with Str variant -use std::path::Path as FsPath; // Conflicts with Path struct +use std::old_path::Path as FsPath; // Conflicts with Path struct use core::DocContext; use doctree; diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 3d7c91ad18859..517907bcf58e3 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -14,7 +14,7 @@ Core encoding and decoding interfaces. */ -use std::path; +use std::old_path; use std::rc::Rc; use std::cell::{Cell, RefCell}; use std::sync::Arc; @@ -538,29 +538,29 @@ macro_rules! tuple { tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, } -impl Encodable for path::posix::Path { +impl Encodable for old_path::posix::Path { fn encode(&self, e: &mut S) -> Result<(), S::Error> { self.as_vec().encode(e) } } -impl Decodable for path::posix::Path { - fn decode(d: &mut D) -> Result { +impl Decodable for old_path::posix::Path { + fn decode(d: &mut D) -> Result { let bytes: Vec = try!(Decodable::decode(d)); - Ok(path::posix::Path::new(bytes)) + Ok(old_path::posix::Path::new(bytes)) } } -impl Encodable for path::windows::Path { +impl Encodable for old_path::windows::Path { fn encode(&self, e: &mut S) -> Result<(), S::Error> { self.as_vec().encode(e) } } -impl Decodable for path::windows::Path { - fn decode(d: &mut D) -> Result { +impl Decodable for old_path::windows::Path { + fn decode(d: &mut D) -> Result { let bytes: Vec = try!(Decodable::decode(d)); - Ok(path::windows::Path::new(bytes)) + Ok(old_path::windows::Path::new(bytes)) } } diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 5070f8c547ab0..559a68542efc8 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -57,7 +57,7 @@ pub fn current_dir() -> IoResult { /// /// ```rust /// use std::env; -/// use std::path::Path; +/// use std::old_path::Path; /// /// let root = Path::new("/"); /// assert!(env::set_current_dir(&root).is_ok()); diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 839983d336d76..bd4763d7bd475 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -251,6 +251,7 @@ pub mod old_io; pub mod os; pub mod env; pub mod path; +pub mod old_path; pub mod rand; pub mod time; diff --git a/src/libstd/old_io/fs.rs b/src/libstd/old_io/fs.rs index abf215988bb4b..88ca6667d55de 100644 --- a/src/libstd/old_io/fs.rs +++ b/src/libstd/old_io/fs.rs @@ -61,8 +61,8 @@ use old_io; use iter::{Iterator, Extend}; use option::Option; use option::Option::{Some, None}; -use path::{Path, GenericPath}; -use path; +use old_path::{Path, GenericPath}; +use old_path; use result::Result::{Err, Ok}; use slice::SliceExt; use string::String; @@ -782,7 +782,7 @@ pub trait PathExtensions { fn is_dir(&self) -> bool; } -impl PathExtensions for path::Path { +impl PathExtensions for old_path::Path { fn stat(&self) -> IoResult { stat(self) } fn lstat(&self) -> IoResult { lstat(self) } fn exists(&self) -> bool { diff --git a/src/libstd/old_io/net/pipe.rs b/src/libstd/old_io/net/pipe.rs index 0da7670c5b49c..8c4a10a55d489 100644 --- a/src/libstd/old_io/net/pipe.rs +++ b/src/libstd/old_io/net/pipe.rs @@ -23,7 +23,7 @@ use prelude::v1::*; use ffi::CString; -use path::BytesContainer; +use old_path::BytesContainer; use old_io::{Listener, Acceptor, IoResult, TimedOut, standard_error}; use sys::pipe::UnixAcceptor as UnixAcceptorImp; use sys::pipe::UnixListener as UnixListenerImp; diff --git a/src/libstd/old_io/process.rs b/src/libstd/old_io/process.rs index 61a07bc8208ed..27af957e18e18 100644 --- a/src/libstd/old_io/process.rs +++ b/src/libstd/old_io/process.rs @@ -25,7 +25,7 @@ use old_io::{IoResult, IoError}; use old_io; use libc; use os; -use path::BytesContainer; +use old_path::BytesContainer; use sync::mpsc::{channel, Receiver}; use sys::fs::FileDesc; use sys::process::Process as ProcessImp; diff --git a/src/libstd/old_io/tempfile.rs b/src/libstd/old_io/tempfile.rs index 83a42549424d6..a227116dfae99 100644 --- a/src/libstd/old_io/tempfile.rs +++ b/src/libstd/old_io/tempfile.rs @@ -17,7 +17,7 @@ use old_io; use ops::Drop; use option::Option::{None, Some}; use option::Option; -use path::{Path, GenericPath}; +use old_path::{Path, GenericPath}; use rand::{Rng, thread_rng}; use result::Result::{Ok, Err}; use str::StrExt; diff --git a/src/libstd/path/mod.rs b/src/libstd/old_path/mod.rs similarity index 100% rename from src/libstd/path/mod.rs rename to src/libstd/old_path/mod.rs diff --git a/src/libstd/path/posix.rs b/src/libstd/old_path/posix.rs similarity index 99% rename from src/libstd/path/posix.rs rename to src/libstd/old_path/posix.rs index 69f815e3f8b77..8bcdd89623d8f 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/old_path/posix.rs @@ -445,7 +445,7 @@ mod tests { use clone::Clone; use iter::IteratorExt; use option::Option::{self, Some, None}; - use path::GenericPath; + use old_path::GenericPath; use slice::{AsSlice, SliceExt}; use str::{self, Str, StrExt}; use string::ToString; diff --git a/src/libstd/path/windows.rs b/src/libstd/old_path/windows.rs similarity index 99% rename from src/libstd/path/windows.rs rename to src/libstd/old_path/windows.rs index fcdebaf2cd3eb..2e25403220d82 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/old_path/windows.rs @@ -1124,7 +1124,7 @@ mod tests { use clone::Clone; use iter::IteratorExt; use option::Option::{self, Some, None}; - use path::GenericPath; + use old_path::GenericPath; use slice::{AsSlice, SliceExt}; use str::Str; use string::ToString; diff --git a/src/libstd/os.rs b/src/libstd/os.rs index d92f361af0bf2..36122b16ea078 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -48,7 +48,7 @@ use old_io::{IoResult, IoError}; use ops::{Drop, FnOnce}; use option::Option::{Some, None}; use option::Option; -use path::{Path, GenericPath, BytesContainer}; +use old_path::{Path, GenericPath, BytesContainer}; use ptr::PtrExt; use ptr; use result::Result::{Err, Ok}; @@ -267,7 +267,7 @@ pub fn split_paths(unparsed: T) -> Vec { /// /// ```rust /// use std::os; -/// use std::path::Path; +/// use std::old_path::Path; /// /// let key = "PATH"; /// let mut paths = os::getenv_as_bytes(key).map_or(Vec::new(), os::split_paths); @@ -470,7 +470,7 @@ pub fn tmpdir() -> Path { /// # Example /// ```rust /// use std::os; -/// use std::path::Path; +/// use std::old_path::Path; /// /// // Assume we're in a path like /home/someuser /// let rel_path = Path::new(".."); @@ -500,7 +500,7 @@ pub fn make_absolute(p: &Path) -> IoResult { /// # Example /// ```rust /// use std::os; -/// use std::path::Path; +/// use std::old_path::Path; /// /// let root = Path::new("/"); /// assert!(os::change_dir(&root).is_ok()); diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs index 2398485afefb7..d2dc33451200f 100644 --- a/src/libstd/prelude/v1.rs +++ b/src/libstd/prelude/v1.rs @@ -56,7 +56,7 @@ #[doc(no_inline)] pub use vec::Vec; // NB: remove when path reform lands -#[doc(no_inline)] pub use path::{Path, GenericPath}; +#[doc(no_inline)] pub use old_path::{Path, GenericPath}; // NB: remove when I/O reform lands #[doc(no_inline)] pub use old_io::{Buffer, Writer, Reader, Seek, BufferPrelude}; // NB: remove when range syntax lands diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index 4b45d5501c235..797b9332f17dc 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -20,7 +20,7 @@ mod imp { use self::OsRngInner::*; use old_io::{IoResult, File}; - use path::Path; + use old_path::Path; use rand::Rng; use rand::reader::ReaderRng; use result::Result::Ok; diff --git a/src/libstd/sys/common/mod.rs b/src/libstd/sys/common/mod.rs index ae01586c7039e..6f6b4c5871748 100644 --- a/src/libstd/sys/common/mod.rs +++ b/src/libstd/sys/common/mod.rs @@ -16,7 +16,7 @@ use prelude::v1::*; use sys::{last_error, retry}; use ffi::CString; use num::Int; -use path::BytesContainer; +use old_path::BytesContainer; use collections; pub mod backtrace; diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 7e117b10a347c..20f86227e8eaf 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -20,7 +20,7 @@ use old_io::{self, IoResult, IoError, EndOfFile}; use libc::{self, pid_t, c_void, c_int}; use mem; use os; -use path::BytesContainer; +use old_path::BytesContainer; use ptr; use sync::mpsc::{channel, Sender, Receiver}; use sys::fs::FileDesc; diff --git a/src/libstd/sys/windows/backtrace.rs b/src/libstd/sys/windows/backtrace.rs index 66712b9e3a1e6..92e309da34bef 100644 --- a/src/libstd/sys/windows/backtrace.rs +++ b/src/libstd/sys/windows/backtrace.rs @@ -32,7 +32,7 @@ use libc; use mem; use ops::Drop; use option::Option::{Some}; -use path::Path; +use old_path::Path; use ptr; use result::Result::{Ok, Err}; use slice::SliceExt; diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index 3ca735f7fdfd3..315c41e779a36 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -23,7 +23,7 @@ use old_io::process::{ProcessExit, ExitStatus}; use old_io::{IoResult, IoError}; use old_io; use os; -use path::BytesContainer; +use old_path::BytesContainer; use ptr; use str; use sync::{StaticMutex, MUTEX_INIT}; diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 5c3892e49c058..129c1d20bc04c 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -25,7 +25,7 @@ use serialize::{Decodable, Decoder, Encodable, Encoder}; use std::fmt; use std::mem; use std::ops::Deref; -use std::path::BytesContainer; +use std::old_path::BytesContainer; use std::rc::Rc; #[allow(non_camel_case_types)] diff --git a/src/test/compile-fail/range-3.rs b/src/test/compile-fail/range-3.rs index fe79165236f8b..78c575d33bad0 100644 --- a/src/test/compile-fail/range-3.rs +++ b/src/test/compile-fail/range-3.rs @@ -13,4 +13,4 @@ pub fn main() { let r = 1..2..3; //~^ ERROR expected one of `.`, `;`, or an operator, found `..` -} \ No newline at end of file +} diff --git a/src/test/compile-fail/range-4.rs b/src/test/compile-fail/range-4.rs index bbd6ae289cce9..a3e27fbbe9aa3 100644 --- a/src/test/compile-fail/range-4.rs +++ b/src/test/compile-fail/range-4.rs @@ -13,4 +13,4 @@ pub fn main() { let r = ..1..2; //~^ ERROR expected one of `.`, `;`, or an operator, found `..` -} \ No newline at end of file +} diff --git a/src/test/debuginfo/associated-types.rs b/src/test/debuginfo/associated-types.rs index 6a624e39e3267..0f6f0ac6ae756 100644 --- a/src/test/debuginfo/associated-types.rs +++ b/src/test/debuginfo/associated-types.rs @@ -149,4 +149,4 @@ fn main() { assoc_enum(Enum::Variant2(8i64, 9i32)); } -fn zzz() { () } \ No newline at end of file +fn zzz() { () }