Skip to content

Commit 585aa98

Browse files
committed
---
yaml --- r: 193791 b: refs/heads/beta c: 0b01a9b h: refs/heads/master i: 193789: 4e53ed2 193787: 735ce33 193783: a98e7ac 193775: df0f8ef 193759: 7c2b740 193727: 25287cb 193663: 980a132 193535: dba2ce2 v: v3
1 parent bac0953 commit 585aa98

File tree

6 files changed

+45
-41
lines changed

6 files changed

+45
-41
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: 54660fc392343e4ddee8a0ea1ca196ffc533585b
34+
refs/heads/beta: 0b01a9bb4b93e3f763b4ab924179462b415991d4
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: de8a23bbc3a7b9cbd7574b5b91a34af59bf030e6

branches/beta/src/libstd/fs/mod.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl File {
124124
/// This function will return an error if `path` does not already exist.
125125
/// Other errors may also be returned according to `OpenOptions::open`.
126126
#[stable(feature = "rust1", since = "1.0.0")]
127-
pub fn open<P: AsPath>(path: P) -> io::Result<File> {
127+
pub fn open<P: AsPath + ?Sized>(path: &P) -> io::Result<File> {
128128
OpenOptions::new().read(true).open(path)
129129
}
130130

@@ -135,7 +135,7 @@ impl File {
135135
///
136136
/// See the `OpenOptions::open` function for more details.
137137
#[stable(feature = "rust1", since = "1.0.0")]
138-
pub fn create<P: AsPath>(path: P) -> io::Result<File> {
138+
pub fn create<P: AsPath + ?Sized>(path: &P) -> io::Result<File> {
139139
OpenOptions::new().write(true).create(true).truncate(true).open(path)
140140
}
141141

@@ -297,7 +297,7 @@ impl OpenOptions {
297297
/// permissions for
298298
/// * Filesystem-level errors (full disk, etc)
299299
#[stable(feature = "rust1", since = "1.0.0")]
300-
pub fn open<P: AsPath>(&self, path: P) -> io::Result<File> {
300+
pub fn open<P: AsPath + ?Sized>(&self, path: &P) -> io::Result<File> {
301301
let path = path.as_path();
302302
let inner = try!(fs_imp::File::open(path, &self.0));
303303
Ok(File { path: path.to_path_buf(), inner: inner })
@@ -410,7 +410,7 @@ impl DirEntry {
410410
/// user lacks permissions to remove the file, or if some other filesystem-level
411411
/// error occurs.
412412
#[stable(feature = "rust1", since = "1.0.0")]
413-
pub fn remove_file<P: AsPath>(path: P) -> io::Result<()> {
413+
pub fn remove_file<P: AsPath + ?Sized>(path: &P) -> io::Result<()> {
414414
fs_imp::unlink(path.as_path())
415415
}
416416

@@ -438,7 +438,7 @@ pub fn remove_file<P: AsPath>(path: P) -> io::Result<()> {
438438
/// permissions to perform a `metadata` call on the given `path` or if there
439439
/// is no entry in the filesystem at the provided path.
440440
#[stable(feature = "rust1", since = "1.0.0")]
441-
pub fn metadata<P: AsPath>(path: P) -> io::Result<Metadata> {
441+
pub fn metadata<P: AsPath + ?Sized>(path: &P) -> io::Result<Metadata> {
442442
fs_imp::stat(path.as_path()).map(Metadata)
443443
}
444444

@@ -459,7 +459,8 @@ pub fn metadata<P: AsPath>(path: P) -> io::Result<Metadata> {
459459
/// reside on separate filesystems, or if some other intermittent I/O error
460460
/// occurs.
461461
#[stable(feature = "rust1", since = "1.0.0")]
462-
pub fn rename<P: AsPath, Q: AsPath>(from: P, to: Q) -> io::Result<()> {
462+
pub fn rename<P: AsPath + ?Sized, Q: AsPath + ?Sized>(from: &P, to: &Q)
463+
-> io::Result<()> {
463464
fs_imp::rename(from.as_path(), to.as_path())
464465
}
465466

@@ -489,9 +490,9 @@ pub fn rename<P: AsPath, Q: AsPath>(from: P, to: Q) -> io::Result<()> {
489490
/// * The current process does not have the permission rights to access
490491
/// `from` or write `to`
491492
#[stable(feature = "rust1", since = "1.0.0")]
492-
pub fn copy<P: AsPath, Q: AsPath>(from: P, to: Q) -> io::Result<u64> {
493+
pub fn copy<P: AsPath + ?Sized, Q: AsPath + ?Sized>(from: &P, to: &Q)
494+
-> io::Result<u64> {
493495
let from = from.as_path();
494-
let to = to.as_path();
495496
if !from.is_file() {
496497
return Err(Error::new(ErrorKind::MismatchedFileTypeForOperation,
497498
"the source path is not an existing file",
@@ -512,15 +513,17 @@ pub fn copy<P: AsPath, Q: AsPath>(from: P, to: Q) -> io::Result<u64> {
512513
/// The `dst` path will be a link pointing to the `src` path. Note that systems
513514
/// often require these two paths to both be located on the same filesystem.
514515
#[stable(feature = "rust1", since = "1.0.0")]
515-
pub fn hard_link<P: AsPath, Q: AsPath>(src: P, dst: Q) -> io::Result<()> {
516+
pub fn hard_link<P: AsPath + ?Sized, Q: AsPath + ?Sized>(src: &P, dst: &Q)
517+
-> io::Result<()> {
516518
fs_imp::link(src.as_path(), dst.as_path())
517519
}
518520

519521
/// Creates a new soft link on the filesystem.
520522
///
521523
/// The `dst` path will be a soft link pointing to the `src` path.
522524
#[stable(feature = "rust1", since = "1.0.0")]
523-
pub fn soft_link<P: AsPath, Q: AsPath>(src: P, dst: Q) -> io::Result<()> {
525+
pub fn soft_link<P: AsPath + ?Sized, Q: AsPath + ?Sized>(src: &P, dst: &Q)
526+
-> io::Result<()> {
524527
fs_imp::symlink(src.as_path(), dst.as_path())
525528
}
526529

@@ -532,7 +535,7 @@ pub fn soft_link<P: AsPath, Q: AsPath>(src: P, dst: Q) -> io::Result<()> {
532535
/// reading a file that does not exist or reading a file that is not a soft
533536
/// link.
534537
#[stable(feature = "rust1", since = "1.0.0")]
535-
pub fn read_link<P: AsPath>(path: P) -> io::Result<PathBuf> {
538+
pub fn read_link<P: AsPath + ?Sized>(path: &P) -> io::Result<PathBuf> {
536539
fs_imp::readlink(path.as_path())
537540
}
538541

@@ -551,7 +554,7 @@ pub fn read_link<P: AsPath>(path: P) -> io::Result<PathBuf> {
551554
/// This function will return an error if the user lacks permissions to make a
552555
/// new directory at the provided `path`, or if the directory already exists.
553556
#[stable(feature = "rust1", since = "1.0.0")]
554-
pub fn create_dir<P: AsPath>(path: P) -> io::Result<()> {
557+
pub fn create_dir<P: AsPath + ?Sized>(path: &P) -> io::Result<()> {
555558
fs_imp::mkdir(path.as_path())
556559
}
557560

@@ -565,7 +568,7 @@ pub fn create_dir<P: AsPath>(path: P) -> io::Result<()> {
565568
/// error conditions for when a directory is being created (after it is
566569
/// determined to not exist) are outlined by `fs::create_dir`.
567570
#[stable(feature = "rust1", since = "1.0.0")]
568-
pub fn create_dir_all<P: AsPath>(path: P) -> io::Result<()> {
571+
pub fn create_dir_all<P: AsPath + ?Sized>(path: &P) -> io::Result<()> {
569572
let path = path.as_path();
570573
if path.is_dir() { return Ok(()) }
571574
if let Some(p) = path.parent() { try!(create_dir_all(p)) }
@@ -587,7 +590,7 @@ pub fn create_dir_all<P: AsPath>(path: P) -> io::Result<()> {
587590
/// This function will return an error if the user lacks permissions to remove
588591
/// the directory at the provided `path`, or if the directory isn't empty.
589592
#[stable(feature = "rust1", since = "1.0.0")]
590-
pub fn remove_dir<P: AsPath>(path: P) -> io::Result<()> {
593+
pub fn remove_dir<P: AsPath + ?Sized>(path: &P) -> io::Result<()> {
591594
fs_imp::rmdir(path.as_path())
592595
}
593596

@@ -601,7 +604,7 @@ pub fn remove_dir<P: AsPath>(path: P) -> io::Result<()> {
601604
///
602605
/// See `file::remove_file` and `fs::remove_dir`
603606
#[stable(feature = "rust1", since = "1.0.0")]
604-
pub fn remove_dir_all<P: AsPath>(path: P) -> io::Result<()> {
607+
pub fn remove_dir_all<P: AsPath + ?Sized>(path: &P) -> io::Result<()> {
605608
let path = path.as_path();
606609
for child in try!(read_dir(path)) {
607610
let child = try!(child).path();
@@ -654,7 +657,7 @@ pub fn remove_dir_all<P: AsPath>(path: P) -> io::Result<()> {
654657
/// the process lacks permissions to view the contents or if the `path` points
655658
/// at a non-directory file
656659
#[stable(feature = "rust1", since = "1.0.0")]
657-
pub fn read_dir<P: AsPath>(path: P) -> io::Result<ReadDir> {
660+
pub fn read_dir<P: AsPath + ?Sized>(path: &P) -> io::Result<ReadDir> {
658661
fs_imp::readdir(path.as_path()).map(ReadDir)
659662
}
660663

@@ -670,7 +673,7 @@ pub fn read_dir<P: AsPath>(path: P) -> io::Result<ReadDir> {
670673
reason = "the precise semantics and defaults for a recursive walk \
671674
may change and this may end up accounting for files such \
672675
as symlinks differently")]
673-
pub fn walk_dir<P: AsPath>(path: P) -> io::Result<WalkDir> {
676+
pub fn walk_dir<P: AsPath + ?Sized>(path: &P) -> io::Result<WalkDir> {
674677
let start = try!(read_dir(path));
675678
Ok(WalkDir { cur: Some(start), stack: Vec::new() })
676679
}
@@ -756,8 +759,8 @@ impl PathExt for Path {
756759
reason = "the argument type of u64 is not quite appropriate for \
757760
this function and may change if the standard library \
758761
gains a type to represent a moment in time")]
759-
pub fn set_file_times<P: AsPath>(path: P, accessed: u64,
760-
modified: u64) -> io::Result<()> {
762+
pub fn set_file_times<P: AsPath + ?Sized>(path: &P, accessed: u64,
763+
modified: u64) -> io::Result<()> {
761764
fs_imp::utimes(path.as_path(), accessed, modified)
762765
}
763766

@@ -785,7 +788,8 @@ pub fn set_file_times<P: AsPath>(path: P, accessed: u64,
785788
reason = "a more granual ability to set specific permissions may \
786789
be exposed on the Permissions structure itself and this \
787790
method may not always exist")]
788-
pub fn set_permissions<P: AsPath>(path: P, perm: Permissions) -> io::Result<()> {
791+
pub fn set_permissions<P: AsPath + ?Sized>(path: &P, perm: Permissions)
792+
-> io::Result<()> {
789793
fs_imp::set_perm(path.as_path(), perm.0)
790794
}
791795

branches/beta/src/libstd/path.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ impl PathBuf {
877877
/// Allocate a `PathBuf` with initial contents given by the
878878
/// argument.
879879
#[stable(feature = "rust1", since = "1.0.0")]
880-
pub fn new<S: AsOsStr>(s: S) -> PathBuf {
880+
pub fn new<S: ?Sized + AsOsStr>(s: &S) -> PathBuf {
881881
PathBuf { inner: s.as_os_str().to_os_string() }
882882
}
883883

@@ -891,7 +891,7 @@ impl PathBuf {
891891
/// replaces everything except for the prefix (if any) of `self`.
892892
/// * if `path` has a prefix but no root, it replaces `self.
893893
#[stable(feature = "rust1", since = "1.0.0")]
894-
pub fn push<P: AsPath>(&mut self, path: P) {
894+
pub fn push<P: ?Sized>(&mut self, path: &P) where P: AsPath {
895895
let path = path.as_path();
896896

897897
// in general, a separator is needed if the rightmost byte is not a separator
@@ -959,7 +959,7 @@ impl PathBuf {
959959
/// assert!(buf == PathBuf::new("/baz.txt"));
960960
/// ```
961961
#[stable(feature = "rust1", since = "1.0.0")]
962-
pub fn set_file_name<S: AsOsStr>(&mut self, file_name: S) {
962+
pub fn set_file_name<S: ?Sized>(&mut self, file_name: &S) where S: AsOsStr {
963963
if self.file_name().is_some() {
964964
let popped = self.pop();
965965
debug_assert!(popped);
@@ -974,7 +974,7 @@ impl PathBuf {
974974
/// Otherwise, returns `true`; if `self.extension()` is `None`, the extension
975975
/// is added; otherwise it is replaced.
976976
#[stable(feature = "rust1", since = "1.0.0")]
977-
pub fn set_extension<S: AsOsStr>(&mut self, extension: S) -> bool {
977+
pub fn set_extension<S: ?Sized + AsOsStr>(&mut self, extension: &S) -> bool {
978978
if self.file_name().is_none() { return false; }
979979

980980
let mut stem = match self.file_stem() {
@@ -1000,17 +1000,17 @@ impl PathBuf {
10001000
}
10011001

10021002
#[stable(feature = "rust1", since = "1.0.0")]
1003-
impl<P: AsPath> iter::FromIterator<P> for PathBuf {
1004-
fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> PathBuf {
1003+
impl<'a, P: ?Sized + 'a> iter::FromIterator<&'a P> for PathBuf where P: AsPath {
1004+
fn from_iter<I: IntoIterator<Item = &'a P>>(iter: I) -> PathBuf {
10051005
let mut buf = PathBuf::new("");
10061006
buf.extend(iter);
10071007
buf
10081008
}
10091009
}
10101010

10111011
#[stable(feature = "rust1", since = "1.0.0")]
1012-
impl<P: AsPath> iter::Extend<P> for PathBuf {
1013-
fn extend<I: IntoIterator<Item = P>>(&mut self, iter: I) {
1012+
impl<'a, P: ?Sized + 'a> iter::Extend<&'a P> for PathBuf where P: AsPath {
1013+
fn extend<I: IntoIterator<Item = &'a P>>(&mut self, iter: I) {
10141014
for p in iter {
10151015
self.push(p)
10161016
}
@@ -1253,13 +1253,13 @@ impl Path {
12531253

12541254
/// Determines whether `base` is a prefix of `self`.
12551255
#[stable(feature = "rust1", since = "1.0.0")]
1256-
pub fn starts_with<P: AsPath>(&self, base: P) -> bool {
1256+
pub fn starts_with<P: ?Sized>(&self, base: &P) -> bool where P: AsPath {
12571257
iter_after(self.components(), base.as_path().components()).is_some()
12581258
}
12591259

12601260
/// Determines whether `child` is a suffix of `self`.
12611261
#[stable(feature = "rust1", since = "1.0.0")]
1262-
pub fn ends_with<P: AsPath>(&self, child: P) -> bool {
1262+
pub fn ends_with<P: ?Sized>(&self, child: &P) -> bool where P: AsPath {
12631263
iter_after(self.components().rev(), child.as_path().components().rev()).is_some()
12641264
}
12651265

@@ -1293,7 +1293,7 @@ impl Path {
12931293
///
12941294
/// See `PathBuf::push` for more details on what it means to adjoin a path.
12951295
#[stable(feature = "rust1", since = "1.0.0")]
1296-
pub fn join<P: AsPath>(&self, path: P) -> PathBuf {
1296+
pub fn join<P: ?Sized>(&self, path: &P) -> PathBuf where P: AsPath {
12971297
let mut buf = self.to_path_buf();
12981298
buf.push(path);
12991299
buf
@@ -1303,7 +1303,7 @@ impl Path {
13031303
///
13041304
/// See `PathBuf::set_file_name` for more details.
13051305
#[stable(feature = "rust1", since = "1.0.0")]
1306-
pub fn with_file_name<S: AsOsStr>(&self, file_name: S) -> PathBuf {
1306+
pub fn with_file_name<S: ?Sized>(&self, file_name: &S) -> PathBuf where S: AsOsStr {
13071307
let mut buf = self.to_path_buf();
13081308
buf.set_file_name(file_name);
13091309
buf
@@ -1313,7 +1313,7 @@ impl Path {
13131313
///
13141314
/// See `PathBuf::set_extension` for more details.
13151315
#[stable(feature = "rust1", since = "1.0.0")]
1316-
pub fn with_extension<S: AsOsStr>(&self, extension: S) -> PathBuf {
1316+
pub fn with_extension<S: ?Sized>(&self, extension: &S) -> PathBuf where S: AsOsStr {
13171317
let mut buf = self.to_path_buf();
13181318
buf.set_extension(extension);
13191319
buf

branches/beta/src/libstd/process.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl Command {
147147
/// Builder methods are provided to change these defaults and
148148
/// otherwise configure the process.
149149
#[stable(feature = "process", since = "1.0.0")]
150-
pub fn new<S: AsOsStr>(program: S) -> Command {
150+
pub fn new<S: AsOsStr + ?Sized>(program: &S) -> Command {
151151
Command {
152152
inner: CommandImp::new(program.as_os_str()),
153153
stdin: None,
@@ -158,7 +158,7 @@ impl Command {
158158

159159
/// Add an argument to pass to the program.
160160
#[stable(feature = "process", since = "1.0.0")]
161-
pub fn arg<S: AsOsStr>(&mut self, arg: S) -> &mut Command {
161+
pub fn arg<S: AsOsStr + ?Sized>(&mut self, arg: &S) -> &mut Command {
162162
self.inner.arg(arg.as_os_str());
163163
self
164164
}
@@ -175,7 +175,7 @@ impl Command {
175175
/// Note that environment variable names are case-insensitive (but case-preserving) on Windows,
176176
/// and case-sensitive on all other platforms.
177177
#[stable(feature = "process", since = "1.0.0")]
178-
pub fn env<K, V>(&mut self, key: K, val: V) -> &mut Command
178+
pub fn env<K: ?Sized, V: ?Sized>(&mut self, key: &K, val: &V) -> &mut Command
179179
where K: AsOsStr, V: AsOsStr
180180
{
181181
self.inner.env(key.as_os_str(), val.as_os_str());
@@ -184,7 +184,7 @@ impl Command {
184184

185185
/// Removes an environment variable mapping.
186186
#[stable(feature = "process", since = "1.0.0")]
187-
pub fn env_remove<K: AsOsStr>(&mut self, key: K) -> &mut Command {
187+
pub fn env_remove<K: ?Sized + AsOsStr>(&mut self, key: &K) -> &mut Command {
188188
self.inner.env_remove(key.as_os_str());
189189
self
190190
}
@@ -198,7 +198,7 @@ impl Command {
198198

199199
/// Set the working directory for the child process.
200200
#[stable(feature = "process", since = "1.0.0")]
201-
pub fn current_dir<P: AsPath>(&mut self, dir: P) -> &mut Command {
201+
pub fn current_dir<P: AsPath + ?Sized>(&mut self, dir: &P) -> &mut Command {
202202
self.inner.cwd(dir.as_path().as_os_str());
203203
self
204204
}

branches/beta/src/libstd/sys/unix/backtrace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub fn write(w: &mut Write) -> io::Result<()> {
118118
// local, it still displays much nicer backtraces when a
119119
// couple of tasks panic simultaneously
120120
static LOCK: StaticMutex = MUTEX_INIT;
121-
let _g = unsafe { LOCK.lock() };
121+
let _g = LOCK.lock();
122122

123123
try!(writeln!(w, "stack backtrace:"));
124124
// 100 lines should be enough

branches/beta/src/libstd/sys/unix/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
253253
let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz);
254254
if err != 0 { return Err(io::Error::last_os_error()); }
255255
v.set_len(sz as uint - 1); // chop off trailing NUL
256-
Ok(PathBuf::new(OsString::from_vec(v)))
256+
Ok(PathBuf::new::<OsString>(&OsStringExt::from_vec(v)))
257257
}
258258
}
259259

0 commit comments

Comments
 (0)