Skip to content

Commit 7991c0d

Browse files
committed
Merge pull request #26371 from alexcrichton/beta-backport
Backport accepted PRs to beta
2 parents 6aa2d50 + 684b5fb commit 7991c0d

File tree

33 files changed

+746
-262
lines changed

33 files changed

+746
-262
lines changed

RELEASES.md

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
Version 1.1.0 (July 2015)
2+
========================
3+
4+
* NNNN changes, numerous bugfixes
5+
6+
Libraries
7+
---------
8+
9+
* The [`std::fs` module has been expanded][fs-expand] to expand the set of
10+
functionality exposed:
11+
* `DirEntry` now supports optimizations like `file_type` and `metadata` which
12+
don't incur a syscall on some platforms.
13+
* A `symlink_metadata` function has been added.
14+
* The `fs::Metadata` structure now lowers to its OS counterpart, providing
15+
access to all underlying information.
16+
17+
[fs-expand]: https://github.com/rust-lang/rust/pull/25844
18+
119
Version 1.0.0 (May 2015)
220
========================
321

configure

+1
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ valopt musl-root "/usr/local" "MUSL root installation directory"
593593
opt_nosave manage-submodules 1 "let the build manage the git submodules"
594594
opt_nosave clang 0 "prefer clang to gcc for building the runtime"
595595
opt_nosave jemalloc 1 "build liballoc with jemalloc"
596+
opt elf-tls 1 "elf thread local storage on platforms where supported"
596597

597598
valopt_nosave prefix "/usr/local" "set installation prefix"
598599
valopt_nosave local-rust-root "/usr/local" "set prefix for local rust binary"

mk/crates.mk

+4
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,7 @@ TOOL_INPUTS_$(1) := $$(call rwildcard,$$(dir $$(TOOL_SOURCE_$(1))),*.rs)
153153
endef
154154

155155
$(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
156+
157+
ifdef CFG_DISABLE_ELF_TLS
158+
RUSTFLAGS_std := --cfg no_elf_tls
159+
endif

src/libcollections/borrow.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use core::ops::Deref;
2121
use core::option::Option;
2222

2323
use fmt;
24-
use alloc::{rc, arc};
24+
use alloc::{boxed, rc, arc};
2525

2626
use self::Cow::*;
2727

@@ -116,6 +116,14 @@ impl<'a, T: ?Sized> BorrowMut<T> for &'a mut T {
116116
fn borrow_mut(&mut self) -> &mut T { &mut **self }
117117
}
118118

119+
impl<T: ?Sized> Borrow<T> for boxed::Box<T> {
120+
fn borrow(&self) -> &T { &**self }
121+
}
122+
123+
impl<T: ?Sized> BorrowMut<T> for boxed::Box<T> {
124+
fn borrow_mut(&mut self) -> &mut T { &mut **self }
125+
}
126+
119127
impl<T> Borrow<T> for rc::Rc<T> {
120128
fn borrow(&self) -> &T { &**self }
121129
}

src/libcollectionstest/btree/map.rs

+29
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::collections::BTreeMap;
1212
use std::collections::Bound::{Excluded, Included, Unbounded, self};
1313
use std::collections::btree_map::Entry::{Occupied, Vacant};
1414
use std::iter::range_inclusive;
15+
use std::rc::Rc;
1516

1617
#[test]
1718
fn test_basic_large() {
@@ -198,6 +199,34 @@ fn test_range() {
198199
}
199200
}
200201

202+
#[test]
203+
fn test_borrow() {
204+
// make sure these compile -- using the Borrow trait
205+
{
206+
let mut map = BTreeMap::new();
207+
map.insert("0".to_string(), 1);
208+
assert_eq!(map["0"], 1);
209+
}
210+
211+
{
212+
let mut map = BTreeMap::new();
213+
map.insert(Box::new(0), 1);
214+
assert_eq!(map[&0], 1);
215+
}
216+
217+
{
218+
let mut map = BTreeMap::new();
219+
map.insert(Box::new([0, 1]) as Box<[i32]>, 1);
220+
assert_eq!(map[&[0, 1][..]], 1);
221+
}
222+
223+
{
224+
let mut map = BTreeMap::new();
225+
map.insert(Rc::new(0), 1);
226+
assert_eq!(map[&0], 1);
227+
}
228+
}
229+
201230
#[test]
202231
fn test_entry(){
203232
let xs = [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)];

src/librustc_trans/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#![feature(staged_api)]
3838
#![feature(unicode)]
3939
#![feature(path_ext)]
40-
#![feature(fs)]
4140
#![feature(path_relative_from)]
4241

4342
#![allow(trivial_casts)]

src/libstd/fs.rs

+31-57
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub struct OpenOptions(fs_imp::OpenOptions);
148148
pub struct Permissions(fs_imp::FilePermissions);
149149

150150
/// An structure representing a type of file with accessors for each file type.
151-
#[unstable(feature = "file_type", reason = "recently added API")]
151+
#[stable(feature = "file_type", since = "1.1.0")]
152152
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
153153
pub struct FileType(fs_imp::FileType);
154154

@@ -208,14 +208,6 @@ impl File {
208208
OpenOptions::new().write(true).create(true).truncate(true).open(path)
209209
}
210210

211-
/// Returns `None`.
212-
#[unstable(feature = "file_path",
213-
reason = "this abstraction was imposed by this library and was removed")]
214-
#[deprecated(since = "1.0.0", reason = "abstraction was removed")]
215-
pub fn path(&self) -> Option<&Path> {
216-
None
217-
}
218-
219211
/// Attempts to sync all OS-internal metadata to disk.
220212
///
221213
/// This function will attempt to ensure that all in-core data reaches the
@@ -501,7 +493,7 @@ impl AsInnerMut<fs_imp::OpenOptions> for OpenOptions {
501493

502494
impl Metadata {
503495
/// Returns the file type for this metadata.
504-
#[unstable(feature = "file_type", reason = "recently added API")]
496+
#[stable(feature = "file_type", since = "1.1.0")]
505497
pub fn file_type(&self) -> FileType {
506498
FileType(self.0.file_type())
507499
}
@@ -575,38 +567,6 @@ impl Metadata {
575567
pub fn permissions(&self) -> Permissions {
576568
Permissions(self.0.perm())
577569
}
578-
579-
/// Returns the most recent access time for a file.
580-
///
581-
/// The return value is in milliseconds since the epoch.
582-
#[unstable(feature = "fs_time",
583-
reason = "the return type of u64 is not quite appropriate for \
584-
this method and may change if the standard library \
585-
gains a type to represent a moment in time")]
586-
#[deprecated(since = "1.1.0",
587-
reason = "use os::platform::fs::MetadataExt extension traits")]
588-
pub fn accessed(&self) -> u64 {
589-
self.adjust_time(self.0.accessed())
590-
}
591-
592-
/// Returns the most recent modification time for a file.
593-
///
594-
/// The return value is in milliseconds since the epoch.
595-
#[unstable(feature = "fs_time",
596-
reason = "the return type of u64 is not quite appropriate for \
597-
this method and may change if the standard library \
598-
gains a type to represent a moment in time")]
599-
#[deprecated(since = "1.1.0",
600-
reason = "use os::platform::fs::MetadataExt extension traits")]
601-
pub fn modified(&self) -> u64 {
602-
self.adjust_time(self.0.modified())
603-
}
604-
605-
fn adjust_time(&self, val: u64) -> u64 {
606-
// FILETIME (what `val` represents) is in 100ns intervals and there are
607-
// 10000 intervals in a millisecond.
608-
if cfg!(windows) {val / 10000} else {val}
609-
}
610570
}
611571

612572
impl AsInner<fs_imp::FileAttr> for Metadata {
@@ -663,15 +623,17 @@ impl Permissions {
663623
}
664624
}
665625

666-
#[unstable(feature = "file_type", reason = "recently added API")]
667626
impl FileType {
668627
/// Test whether this file type represents a directory.
628+
#[stable(feature = "file_type", since = "1.1.0")]
669629
pub fn is_dir(&self) -> bool { self.0.is_dir() }
670630

671631
/// Test whether this file type represents a regular file.
632+
#[stable(feature = "file_type", since = "1.1.0")]
672633
pub fn is_file(&self) -> bool { self.0.is_file() }
673634

674635
/// Test whether this file type represents a symbolic link.
636+
#[stable(feature = "file_type", since = "1.1.0")]
675637
pub fn is_symlink(&self) -> bool { self.0.is_symlink() }
676638
}
677639

@@ -736,7 +698,7 @@ impl DirEntry {
736698
/// On Windows this function is cheap to call (no extra system calls
737699
/// needed), but on Unix platforms this function is the equivalent of
738700
/// calling `symlink_metadata` on the path.
739-
#[unstable(feature = "dir_entry_ext", reason = "recently added API")]
701+
#[stable(feature = "dir_entry_ext", since = "1.1.0")]
740702
pub fn metadata(&self) -> io::Result<Metadata> {
741703
self.0.metadata().map(Metadata)
742704
}
@@ -751,14 +713,14 @@ impl DirEntry {
751713
/// On Windows and most Unix platforms this function is free (no extra
752714
/// system calls needed), but some Unix platforms may require the equivalent
753715
/// call to `symlink_metadata` to learn about the target file type.
754-
#[unstable(feature = "dir_entry_ext", reason = "recently added API")]
716+
#[stable(feature = "dir_entry_ext", since = "1.1.0")]
755717
pub fn file_type(&self) -> io::Result<FileType> {
756718
self.0.file_type().map(FileType)
757719
}
758720

759721
/// Returns the bare file name of this directory entry without any other
760722
/// leading path component.
761-
#[unstable(feature = "dir_entry_ext", reason = "recently added API")]
723+
#[stable(feature = "dir_entry_ext", since = "1.1.0")]
762724
pub fn file_name(&self) -> OsString {
763725
self.0.file_name()
764726
}
@@ -828,7 +790,6 @@ pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
828790
/// # Examples
829791
///
830792
/// ```rust
831-
/// #![feature(symlink_metadata)]
832793
/// # fn foo() -> std::io::Result<()> {
833794
/// use std::fs;
834795
///
@@ -837,7 +798,7 @@ pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
837798
/// # Ok(())
838799
/// # }
839800
/// ```
840-
#[unstable(feature = "symlink_metadata", reason = "recently added API")]
801+
#[stable(feature = "symlink_metadata", since = "1.1.0")]
841802
pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
842803
fs_imp::lstat(path.as_ref()).map(Metadata)
843804
}
@@ -1268,7 +1229,6 @@ pub fn set_file_times<P: AsRef<Path>>(path: P, accessed: u64,
12681229
/// # Examples
12691230
///
12701231
/// ```
1271-
/// # #![feature(fs)]
12721232
/// # fn foo() -> std::io::Result<()> {
12731233
/// use std::fs;
12741234
///
@@ -1284,14 +1244,13 @@ pub fn set_file_times<P: AsRef<Path>>(path: P, accessed: u64,
12841244
/// This function will return an error if the provided `path` doesn't exist, if
12851245
/// the process lacks permissions to change the attributes of the file, or if
12861246
/// some other I/O error is encountered.
1287-
#[unstable(feature = "fs",
1288-
reason = "a more granual ability to set specific permissions may \
1289-
be exposed on the Permissions structure itself and this \
1290-
method may not always exist")]
1291-
pub fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions) -> io::Result<()> {
1247+
#[stable(feature = "set_permissions", since = "1.1.0")]
1248+
pub fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions)
1249+
-> io::Result<()> {
12921250
fs_imp::set_perm(path.as_ref(), perm.0)
12931251
}
12941252

1253+
#[unstable(feature = "dir_builder", reason = "recently added API")]
12951254
impl DirBuilder {
12961255
/// Creates a new set of options with default mode/security settings for all
12971256
/// platforms and also non-recursive.
@@ -2064,9 +2023,24 @@ mod tests {
20642023
// These numbers have to be bigger than the time in the day to account
20652024
// for timezones Windows in particular will fail in certain timezones
20662025
// with small enough values
2067-
check!(fs::set_file_times(&path, 100000, 200000));
2068-
assert_eq!(check!(path.metadata()).accessed(), 100000);
2069-
assert_eq!(check!(path.metadata()).modified(), 200000);
2026+
check!(fs::set_file_times(&path, 100_000, 200_000));
2027+
2028+
check(&check!(path.metadata()));
2029+
2030+
#[cfg(unix)]
2031+
fn check(metadata: &fs::Metadata) {
2032+
use os::unix::prelude::*;
2033+
assert_eq!(metadata.atime(), 100);
2034+
assert_eq!(metadata.atime_nsec(), 0);
2035+
assert_eq!(metadata.mtime(), 200);
2036+
assert_eq!(metadata.mtime_nsec(), 0);
2037+
}
2038+
#[cfg(windows)]
2039+
fn check(metadata: &fs::Metadata) {
2040+
use os::windows::prelude::*;
2041+
assert_eq!(metadata.last_access_time(), 100_000 * 10_000);
2042+
assert_eq!(metadata.last_write_time(), 200_000 * 10_000);
2043+
}
20702044
}
20712045

20722046
#[test]

src/libstd/os/android/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010

1111
//! Android-specific definitions
1212
13-
#![unstable(feature = "raw_ext", reason = "recently added API")]
13+
#![stable(feature = "raw_ext", since = "1.1.0")]
1414

1515
pub mod raw;
1616

1717
pub mod fs {
18+
#![stable(feature = "raw_ext", since = "1.1.0")]
1819
pub use sys::fs::MetadataExt;
1920
}

src/libstd/os/android/raw.rs

+30
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,67 @@
1010

1111
//! Android-specific raw type definitions
1212
13+
#![stable(feature = "raw_ext", since = "1.1.0")]
14+
1315
use os::raw::{c_uint, c_uchar, c_ulonglong, c_longlong, c_ulong};
1416
use os::unix::raw::{uid_t, gid_t};
1517

18+
#[stable(feature = "raw_ext", since = "1.1.0")]
1619
pub type blkcnt_t = u32;
20+
#[stable(feature = "raw_ext", since = "1.1.0")]
1721
pub type blksize_t = u32;
22+
#[stable(feature = "raw_ext", since = "1.1.0")]
1823
pub type dev_t = u32;
24+
#[stable(feature = "raw_ext", since = "1.1.0")]
1925
pub type ino_t = u32;
26+
#[stable(feature = "raw_ext", since = "1.1.0")]
2027
pub type mode_t = u16;
28+
#[stable(feature = "raw_ext", since = "1.1.0")]
2129
pub type nlink_t = u16;
30+
#[stable(feature = "raw_ext", since = "1.1.0")]
2231
pub type off_t = i32;
32+
#[stable(feature = "raw_ext", since = "1.1.0")]
2333
pub type time_t = i32;
2434

2535
#[repr(C)]
36+
#[stable(feature = "raw_ext", since = "1.1.0")]
2637
pub struct stat {
38+
#[stable(feature = "raw_ext", since = "1.1.0")]
2739
pub st_dev: c_ulonglong,
40+
#[stable(feature = "raw_ext", since = "1.1.0")]
2841
pub __pad0: [c_uchar; 4],
42+
#[stable(feature = "raw_ext", since = "1.1.0")]
2943
pub __st_ino: ino_t,
44+
#[stable(feature = "raw_ext", since = "1.1.0")]
3045
pub st_mode: c_uint,
46+
#[stable(feature = "raw_ext", since = "1.1.0")]
3147
pub st_nlink: c_uint,
48+
#[stable(feature = "raw_ext", since = "1.1.0")]
3249
pub st_uid: uid_t,
50+
#[stable(feature = "raw_ext", since = "1.1.0")]
3351
pub st_gid: gid_t,
52+
#[stable(feature = "raw_ext", since = "1.1.0")]
3453
pub st_rdev: c_ulonglong,
54+
#[stable(feature = "raw_ext", since = "1.1.0")]
3555
pub __pad3: [c_uchar; 4],
56+
#[stable(feature = "raw_ext", since = "1.1.0")]
3657
pub st_size: c_longlong,
58+
#[stable(feature = "raw_ext", since = "1.1.0")]
3759
pub st_blksize: blksize_t,
60+
#[stable(feature = "raw_ext", since = "1.1.0")]
3861
pub st_blocks: c_ulonglong,
62+
#[stable(feature = "raw_ext", since = "1.1.0")]
3963
pub st_atime: time_t,
64+
#[stable(feature = "raw_ext", since = "1.1.0")]
4065
pub st_atime_nsec: c_ulong,
66+
#[stable(feature = "raw_ext", since = "1.1.0")]
4167
pub st_mtime: time_t,
68+
#[stable(feature = "raw_ext", since = "1.1.0")]
4269
pub st_mtime_nsec: c_ulong,
70+
#[stable(feature = "raw_ext", since = "1.1.0")]
4371
pub st_ctime: time_t,
72+
#[stable(feature = "raw_ext", since = "1.1.0")]
4473
pub st_ctime_nsec: c_ulong,
74+
#[stable(feature = "raw_ext", since = "1.1.0")]
4575
pub st_ino: c_ulonglong,
4676
}

src/libstd/os/bitrig/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010

1111
//! Bitrig-specific definitions
1212
13-
#![unstable(feature = "raw_ext", reason = "recently added API")]
13+
#![stable(feature = "raw_ext", since = "1.1.0")]
1414

1515
pub mod raw;
1616

1717
pub mod fs {
18+
#![stable(feature = "raw_ext", since = "1.1.0")]
1819
pub use sys::fs::MetadataExt;
1920
}

0 commit comments

Comments
 (0)