Skip to content

Commit

Permalink
rollup merge of rust-lang#21759: aturon/new-path
Browse files Browse the repository at this point in the history
This PR implements [path reform](rust-lang/rfcs#474), and motivation and details for the change can be found there.

For convenience, the old path API is being kept as `old_path` for the time being. Updating after this PR is just a matter of changing imports to `old_path` (which is likely not needed, since the prelude entries still export the old path API).

This initial PR does not include additional normalization or platform-specific path extensions. These will be done in follow up commits or PRs.

[breaking-change]

Closes rust-lang#20034
Closes rust-lang#12056
Closes rust-lang#11594
Closes rust-lang#14028
Closes rust-lang#14049
Closes rust-lang#10035
  • Loading branch information
alexcrichton committed Feb 3, 2015
2 parents 3b2ed14 + 45ddf50 commit 8550bf7
Show file tree
Hide file tree
Showing 34 changed files with 2,614 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/libcore/error.rs
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/libgraphviz/maybe_owned_vec.rs
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mod.rs
Expand Up @@ -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<Target, String> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/trans/debuginfo.rs
Expand Up @@ -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 &&
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions src/libserialize/serialize.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
self.as_vec().encode(e)
}
}

impl Decodable for path::posix::Path {
fn decode<D: Decoder>(d: &mut D) -> Result<path::posix::Path, D::Error> {
impl Decodable for old_path::posix::Path {
fn decode<D: Decoder>(d: &mut D) -> Result<old_path::posix::Path, D::Error> {
let bytes: Vec<u8> = 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<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
self.as_vec().encode(e)
}
}

impl Decodable for path::windows::Path {
fn decode<D: Decoder>(d: &mut D) -> Result<path::windows::Path, D::Error> {
impl Decodable for old_path::windows::Path {
fn decode<D: Decoder>(d: &mut D) -> Result<old_path::windows::Path, D::Error> {
let bytes: Vec<u8> = try!(Decodable::decode(d));
Ok(path::windows::Path::new(bytes))
Ok(old_path::windows::Path::new(bytes))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/env.rs
Expand Up @@ -57,7 +57,7 @@ pub fn current_dir() -> IoResult<Path> {
///
/// ```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());
Expand Down
1 change: 1 addition & 0 deletions src/libstd/ffi/mod.rs
Expand Up @@ -24,6 +24,7 @@ pub use self::os_str::OsStr;
mod c_str;
mod os_str;

// FIXME (#21670): these should be defined in the os_str module
/// Freely convertible to an `&OsStr` slice.
pub trait AsOsStr {
/// Convert to an `&OsStr` slice.
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/ffi/os_str.rs
Expand Up @@ -41,7 +41,7 @@ use string::{String, CowString};
use ops;
use cmp;
use hash::{Hash, Hasher, Writer};
use path::{Path, GenericPath};
use old_path::{Path, GenericPath};

use sys::os_str::{Buf, Slice};
use sys_common::{AsInner, IntoInner, FromInner};
Expand Down
1 change: 1 addition & 0 deletions src/libstd/lib.rs
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/libstd/old_io/fs.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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<FileStat> { stat(self) }
fn lstat(&self) -> IoResult<FileStat> { lstat(self) }
fn exists(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/old_io/net/pipe.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/old_io/process.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/old_io/tempfile.rs
Expand Up @@ -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;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/libstd/path/posix.rs → src/libstd/old_path/posix.rs
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/libstd/os.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -267,7 +267,7 @@ pub fn split_paths<T: BytesContainer>(unparsed: T) -> Vec<Path> {
///
/// ```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);
Expand Down Expand Up @@ -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("..");
Expand Down Expand Up @@ -500,7 +500,7 @@ pub fn make_absolute(p: &Path) -> IoResult<Path> {
/// # 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());
Expand Down

0 comments on commit 8550bf7

Please sign in to comment.