Skip to content

Commit 8550bf7

Browse files
committed
rollup merge of rust-lang#21759: aturon/new-path
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
2 parents 3b2ed14 + 45ddf50 commit 8550bf7

File tree

34 files changed

+2614
-46
lines changed

34 files changed

+2614
-46
lines changed

src/libcore/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
//! use std::error::FromError;
5252
//! use std::old_io::{File, IoError};
5353
//! use std::os::{MemoryMap, MapError};
54-
//! use std::path::Path;
54+
//! use std::old_path::Path;
5555
//!
5656
//! enum MyError {
5757
//! Io(IoError),

src/libgraphviz/maybe_owned_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::cmp::Ordering;
1717
use std::default::Default;
1818
use std::fmt;
1919
use std::iter::FromIterator;
20-
use std::path::BytesContainer;
20+
use std::old_path::BytesContainer;
2121
use std::slice;
2222

2323
// Note 1: It is not clear whether the flexibility of providing both

src/librustc_back/target/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl Target {
306306
use std::env;
307307
use std::ffi::OsString;
308308
use std::old_io::File;
309-
use std::path::Path;
309+
use std::old_path::Path;
310310
use serialize::json;
311311

312312
fn load_file(path: &Path) -> Result<Target, String> {

src/librustc_trans/trans/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ fn compile_unit_metadata(cx: &CrateContext) -> DIDescriptor {
15901590
Some(ref p) if p.is_relative() => {
15911591
// prepend "./" if necessary
15921592
let dotdot = b"..";
1593-
let prefix: &[u8] = &[dotdot[0], ::std::path::SEP_BYTE];
1593+
let prefix: &[u8] = &[dotdot[0], ::std::old_path::SEP_BYTE];
15941594
let mut path_bytes = p.as_vec().to_vec();
15951595

15961596
if &path_bytes[..2] != prefix &&

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use rustc::middle::stability;
4949
use std::rc::Rc;
5050
use std::u32;
5151
use std::str::Str as StrTrait; // Conflicts with Str variant
52-
use std::path::Path as FsPath; // Conflicts with Path struct
52+
use std::old_path::Path as FsPath; // Conflicts with Path struct
5353

5454
use core::DocContext;
5555
use doctree;

src/libserialize/serialize.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
Core encoding and decoding interfaces.
1515
*/
1616

17-
use std::path;
17+
use std::old_path;
1818
use std::rc::Rc;
1919
use std::cell::{Cell, RefCell};
2020
use std::sync::Arc;
@@ -538,29 +538,29 @@ macro_rules! tuple {
538538

539539
tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }
540540

541-
impl Encodable for path::posix::Path {
541+
impl Encodable for old_path::posix::Path {
542542
fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
543543
self.as_vec().encode(e)
544544
}
545545
}
546546

547-
impl Decodable for path::posix::Path {
548-
fn decode<D: Decoder>(d: &mut D) -> Result<path::posix::Path, D::Error> {
547+
impl Decodable for old_path::posix::Path {
548+
fn decode<D: Decoder>(d: &mut D) -> Result<old_path::posix::Path, D::Error> {
549549
let bytes: Vec<u8> = try!(Decodable::decode(d));
550-
Ok(path::posix::Path::new(bytes))
550+
Ok(old_path::posix::Path::new(bytes))
551551
}
552552
}
553553

554-
impl Encodable for path::windows::Path {
554+
impl Encodable for old_path::windows::Path {
555555
fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
556556
self.as_vec().encode(e)
557557
}
558558
}
559559

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

src/libstd/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn current_dir() -> IoResult<Path> {
5757
///
5858
/// ```rust
5959
/// use std::env;
60-
/// use std::path::Path;
60+
/// use std::old_path::Path;
6161
///
6262
/// let root = Path::new("/");
6363
/// assert!(env::set_current_dir(&root).is_ok());

src/libstd/ffi/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub use self::os_str::OsStr;
2424
mod c_str;
2525
mod os_str;
2626

27+
// FIXME (#21670): these should be defined in the os_str module
2728
/// Freely convertible to an `&OsStr` slice.
2829
pub trait AsOsStr {
2930
/// Convert to an `&OsStr` slice.

src/libstd/ffi/os_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use string::{String, CowString};
4141
use ops;
4242
use cmp;
4343
use hash::{Hash, Hasher, Writer};
44-
use path::{Path, GenericPath};
44+
use old_path::{Path, GenericPath};
4545

4646
use sys::os_str::{Buf, Slice};
4747
use sys_common::{AsInner, IntoInner, FromInner};

src/libstd/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ pub mod old_io;
251251
pub mod os;
252252
pub mod env;
253253
pub mod path;
254+
pub mod old_path;
254255
pub mod rand;
255256
pub mod time;
256257

src/libstd/old_io/fs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ use old_io;
6161
use iter::{Iterator, Extend};
6262
use option::Option;
6363
use option::Option::{Some, None};
64-
use path::{Path, GenericPath};
65-
use path;
64+
use old_path::{Path, GenericPath};
65+
use old_path;
6666
use result::Result::{Err, Ok};
6767
use slice::SliceExt;
6868
use string::String;
@@ -782,7 +782,7 @@ pub trait PathExtensions {
782782
fn is_dir(&self) -> bool;
783783
}
784784

785-
impl PathExtensions for path::Path {
785+
impl PathExtensions for old_path::Path {
786786
fn stat(&self) -> IoResult<FileStat> { stat(self) }
787787
fn lstat(&self) -> IoResult<FileStat> { lstat(self) }
788788
fn exists(&self) -> bool {

src/libstd/old_io/net/pipe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use prelude::v1::*;
2424

2525
use ffi::CString;
26-
use path::BytesContainer;
26+
use old_path::BytesContainer;
2727
use old_io::{Listener, Acceptor, IoResult, TimedOut, standard_error};
2828
use sys::pipe::UnixAcceptor as UnixAcceptorImp;
2929
use sys::pipe::UnixListener as UnixListenerImp;

src/libstd/old_io/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use old_io::{IoResult, IoError};
2525
use old_io;
2626
use libc;
2727
use os;
28-
use path::BytesContainer;
28+
use old_path::BytesContainer;
2929
use sync::mpsc::{channel, Receiver};
3030
use sys::fs::FileDesc;
3131
use sys::process::Process as ProcessImp;

src/libstd/old_io/tempfile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use old_io;
1717
use ops::Drop;
1818
use option::Option::{None, Some};
1919
use option::Option;
20-
use path::{Path, GenericPath};
20+
use old_path::{Path, GenericPath};
2121
use rand::{Rng, thread_rng};
2222
use result::Result::{Ok, Err};
2323
use str::StrExt;
File renamed without changes.

src/libstd/path/posix.rs renamed to src/libstd/old_path/posix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ mod tests {
445445
use clone::Clone;
446446
use iter::IteratorExt;
447447
use option::Option::{self, Some, None};
448-
use path::GenericPath;
448+
use old_path::GenericPath;
449449
use slice::{AsSlice, SliceExt};
450450
use str::{self, Str, StrExt};
451451
use string::ToString;

src/libstd/path/windows.rs renamed to src/libstd/old_path/windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ mod tests {
11241124
use clone::Clone;
11251125
use iter::IteratorExt;
11261126
use option::Option::{self, Some, None};
1127-
use path::GenericPath;
1127+
use old_path::GenericPath;
11281128
use slice::{AsSlice, SliceExt};
11291129
use str::Str;
11301130
use string::ToString;

src/libstd/os.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use old_io::{IoResult, IoError};
4848
use ops::{Drop, FnOnce};
4949
use option::Option::{Some, None};
5050
use option::Option;
51-
use path::{Path, GenericPath, BytesContainer};
51+
use old_path::{Path, GenericPath, BytesContainer};
5252
use ptr::PtrExt;
5353
use ptr;
5454
use result::Result::{Err, Ok};
@@ -267,7 +267,7 @@ pub fn split_paths<T: BytesContainer>(unparsed: T) -> Vec<Path> {
267267
///
268268
/// ```rust
269269
/// use std::os;
270-
/// use std::path::Path;
270+
/// use std::old_path::Path;
271271
///
272272
/// let key = "PATH";
273273
/// let mut paths = os::getenv_as_bytes(key).map_or(Vec::new(), os::split_paths);
@@ -470,7 +470,7 @@ pub fn tmpdir() -> Path {
470470
/// # Example
471471
/// ```rust
472472
/// use std::os;
473-
/// use std::path::Path;
473+
/// use std::old_path::Path;
474474
///
475475
/// // Assume we're in a path like /home/someuser
476476
/// let rel_path = Path::new("..");
@@ -500,7 +500,7 @@ pub fn make_absolute(p: &Path) -> IoResult<Path> {
500500
/// # Example
501501
/// ```rust
502502
/// use std::os;
503-
/// use std::path::Path;
503+
/// use std::old_path::Path;
504504
///
505505
/// let root = Path::new("/");
506506
/// assert!(os::change_dir(&root).is_ok());

0 commit comments

Comments
 (0)