about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-06-23 13:46:43 +0000
committerbors <bors@rust-lang.org>2017-06-23 13:46:43 +0000
commit229d0d3266002d343cdd2f4a3bf7f2fe9da15f38 (patch)
tree013df87f8b1813e88368ac8c1728bc4c9b6bfb76 /src/libstd
parentbd32b1ba0d2d51a7e8505c1d3e37d17d3ba12843 (diff)
parent9037ef2c782c9890e84285e81a183109ef1293f0 (diff)
downloadrust-229d0d3266002d343cdd2f4a3bf7f2fe9da15f38.tar.gz
rust-229d0d3266002d343cdd2f4a3bf7f2fe9da15f38.zip
Auto merge of #42856 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 8 pull requests

- Successful merges: #42777, #42783, #42787, #42821, #42822, #42825, #42829, #42833
- Failed merges:
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/macros.rs8
-rw-r--r--src/libstd/memchr.rs4
-rw-r--r--src/libstd/prelude/mod.rs5
-rw-r--r--src/libstd/primitive_docs.rs6
-rw-r--r--src/libstd/process.rs8
-rw-r--r--src/libstd/sync/mutex.rs7
-rw-r--r--src/libstd/sync/rwlock.rs14
-rw-r--r--src/libstd/sys/redox/ext/fs.rs52
-rw-r--r--src/libstd/sys/redox/os.rs2
-rw-r--r--src/libstd/sys/unix/ext/fs.rs22
-rw-r--r--src/libstd/sys/windows/ext/fs.rs8
-rw-r--r--src/libstd/sys_common/thread_local.rs8
12 files changed, 98 insertions, 46 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs
index 82c4f0830a6..9a4c5ec8f6b 100644
--- a/src/libstd/macros.rs
+++ b/src/libstd/macros.rs
@@ -444,7 +444,7 @@ pub mod builtin {
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```ignore (cannot-doctest-external-file-dependency)
     /// let secret_key = include_str!("secret-key.ascii");
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -461,7 +461,7 @@ pub mod builtin {
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```ignore (cannot-doctest-external-file-dependency)
     /// let secret_key = include_bytes!("secret-key.bin");
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -530,13 +530,13 @@ pub mod builtin {
     ///
     /// File 'my_str.in':
     ///
-    /// ```ignore
+    /// ```ignore (only-for-syntax-highlight)
     /// "Hello World!"
     /// ```
     ///
     /// File 'main.rs':
     ///
-    /// ```ignore
+    /// ```ignore (cannot-doctest-external-file-dependency)
     /// fn main() {
     ///     let my_str = include!("my_str.in");
     ///     println!("{}", my_str);
diff --git a/src/libstd/memchr.rs b/src/libstd/memchr.rs
index 7c8c97a6caf..98642f86f4d 100644
--- a/src/libstd/memchr.rs
+++ b/src/libstd/memchr.rs
@@ -24,7 +24,7 @@
 ///
 /// This shows how to find the first position of a byte in a byte string.
 ///
-/// ```rust,ignore
+/// ```ignore (cannot-doctest-private-modules)
 /// use memchr::memchr;
 ///
 /// let haystack = b"the quick brown fox";
@@ -44,7 +44,7 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
 ///
 /// This shows how to find the last position of a byte in a byte string.
 ///
-/// ```rust,ignore
+/// ```ignore (cannot-doctest-private-modules)
 /// use memchr::memrchr;
 ///
 /// let haystack = b"the quick brown fox";
diff --git a/src/libstd/prelude/mod.rs b/src/libstd/prelude/mod.rs
index 195662637f0..49cdba21a1d 100644
--- a/src/libstd/prelude/mod.rs
+++ b/src/libstd/prelude/mod.rs
@@ -22,13 +22,14 @@
 //!
 //! On a technical level, Rust inserts
 //!
-//! ```ignore
+//! ```
 //! extern crate std;
 //! ```
 //!
 //! into the crate root of every crate, and
 //!
-//! ```ignore
+//! ```
+//! # #[allow(unused_imports)]
 //! use std::prelude::v1::*;
 //! ```
 //!
diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs
index 61ff8daddf0..869299e2144 100644
--- a/src/libstd/primitive_docs.rs
+++ b/src/libstd/primitive_docs.rs
@@ -320,7 +320,7 @@ mod prim_pointer { }
 ///
 /// An array itself is not iterable:
 ///
-/// ```ignore
+/// ```compile_fail,E0277
 /// let array: [i32; 3] = [0; 3];
 ///
 /// for x in array { }
@@ -480,8 +480,10 @@ mod prim_str { }
 /// Tuples are *heterogeneous*. This means that each element of the tuple can
 /// have a different type. In that tuple above, it has the type:
 ///
-/// ```rust,ignore
+/// ```
+/// # let _:
 /// (&'static str, i32, char)
+/// # = ("hello", 5, 'c');
 /// ```
 ///
 /// Tuples are a *sequence*. This means that they can be accessed by position;
diff --git a/src/libstd/process.rs b/src/libstd/process.rs
index 4632c8a918e..df6a648b7b1 100644
--- a/src/libstd/process.rs
+++ b/src/libstd/process.rs
@@ -349,15 +349,19 @@ impl Command {
     ///
     /// Only one argument can be passed per use. So instead of:
     ///
-    /// ```ignore
+    /// ```no_run
+    /// # std::process::Command::new("sh")
     /// .arg("-C /path/to/repo")
+    /// # ;
     /// ```
     ///
     /// usage would be:
     ///
-    /// ```ignore
+    /// ```no_run
+    /// # std::process::Command::new("sh")
     /// .arg("-C")
     /// .arg("/path/to/repo")
+    /// # ;
     /// ```
     ///
     /// To pass multiple arguments see [`args`].
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs
index 9a242a96d46..fc6c7de9ef0 100644
--- a/src/libstd/sync/mutex.rs
+++ b/src/libstd/sync/mutex.rs
@@ -440,6 +440,13 @@ impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> {
     }
 }
 
+#[stable(feature = "std_guard_impls", since = "1.20")]
+impl<'a, T: ?Sized + fmt::Display> fmt::Display for MutexGuard<'a, T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        (**self).fmt(f)
+    }
+}
+
 pub fn guard_lock<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a sys::Mutex {
     &guard.__lock.inner
 }
diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs
index 95bc8d30932..944801e8a3b 100644
--- a/src/libstd/sync/rwlock.rs
+++ b/src/libstd/sync/rwlock.rs
@@ -370,6 +370,13 @@ impl<'a, T: fmt::Debug> fmt::Debug for RwLockReadGuard<'a, T> {
     }
 }
 
+#[stable(feature = "std_guard_impls", since = "1.20")]
+impl<'a, T: ?Sized + fmt::Display> fmt::Display for RwLockReadGuard<'a, T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        (**self).fmt(f)
+    }
+}
+
 #[stable(feature = "std_debug", since = "1.16.0")]
 impl<'a, T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'a, T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -379,6 +386,13 @@ impl<'a, T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'a, T> {
     }
 }
 
+#[stable(feature = "std_guard_impls", since = "1.20")]
+impl<'a, T: ?Sized + fmt::Display> fmt::Display for RwLockWriteGuard<'a, T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        (**self).fmt(f)
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'rwlock, T: ?Sized> Deref for RwLockReadGuard<'rwlock, T> {
     type Target = T;
diff --git a/src/libstd/sys/redox/ext/fs.rs b/src/libstd/sys/redox/ext/fs.rs
index fc81cc737d9..4437cf43920 100644
--- a/src/libstd/sys/redox/ext/fs.rs
+++ b/src/libstd/sys/redox/ext/fs.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Unix-specific extensions to primitives in the `std::fs` module.
+//! Redox-specific extensions to primitives in the `std::fs` module.
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
@@ -18,23 +18,25 @@ use path::Path;
 use sys;
 use sys_common::{FromInner, AsInner, AsInnerMut};
 
-/// Unix-specific extensions to `Permissions`
+/// Redox-specific extensions to `Permissions`
 #[stable(feature = "fs_ext", since = "1.1.0")]
 pub trait PermissionsExt {
-    /// Returns the underlying raw `mode_t` bits that are the standard Unix
+    /// Returns the underlying raw `mode_t` bits that are the standard Redox
     /// permissions for this file.
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```no_run
     /// use std::fs::File;
-    /// use std::os::unix::fs::PermissionsExt;
+    /// use std::os::redox::fs::PermissionsExt;
     ///
+    /// # fn run() -> std::io::Result<()> {
     /// let f = File::create("foo.txt")?;
     /// let metadata = f.metadata()?;
     /// let permissions = metadata.permissions();
     ///
     /// println!("permissions: {}", permissions.mode());
+    /// # Ok(()) }
     /// ```
     #[stable(feature = "fs_ext", since = "1.1.0")]
     fn mode(&self) -> u32;
@@ -43,28 +45,30 @@ pub trait PermissionsExt {
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```no_run
     /// use std::fs::File;
-    /// use std::os::unix::fs::PermissionsExt;
+    /// use std::os::redox::fs::PermissionsExt;
     ///
+    /// # fn run() -> std::io::Result<()> {
     /// let f = File::create("foo.txt")?;
     /// let metadata = f.metadata()?;
     /// let mut permissions = metadata.permissions();
     ///
     /// permissions.set_mode(0o644); // Read/write for owner and read for others.
     /// assert_eq!(permissions.mode(), 0o644);
+    /// # Ok(()) }
     /// ```
     #[stable(feature = "fs_ext", since = "1.1.0")]
     fn set_mode(&mut self, mode: u32);
 
-    /// Creates a new instance of `Permissions` from the given set of Unix
+    /// Creates a new instance of `Permissions` from the given set of Redox
     /// permission bits.
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```
     /// use std::fs::Permissions;
-    /// use std::os::unix::fs::PermissionsExt;
+    /// use std::os::redox::fs::PermissionsExt;
     ///
     /// // Read/write for owner and read for others.
     /// let permissions = Permissions::from_mode(0o644);
@@ -89,7 +93,7 @@ impl PermissionsExt for Permissions {
     }
 }
 
-/// Unix-specific extensions to `OpenOptions`
+/// Redox-specific extensions to `OpenOptions`
 #[stable(feature = "fs_ext", since = "1.1.0")]
 pub trait OpenOptionsExt {
     /// Sets the mode bits that a new file will be created with.
@@ -102,14 +106,17 @@ pub trait OpenOptionsExt {
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```no_run
+    /// # #![feature(libc)]
     /// extern crate libc;
     /// use std::fs::OpenOptions;
-    /// use std::os::unix::fs::OpenOptionsExt;
+    /// use std::os::redox::fs::OpenOptionsExt;
     ///
+    /// # fn main() {
     /// let mut options = OpenOptions::new();
     /// options.mode(0o644); // Give read/write for owner and read for others.
     /// let file = options.open("foo.txt");
+    /// # }
     /// ```
     #[stable(feature = "fs_ext", since = "1.1.0")]
     fn mode(&mut self, mode: u32) -> &mut Self;
@@ -124,17 +131,20 @@ pub trait OpenOptionsExt {
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```no_run
+    /// # #![feature(libc)]
     /// extern crate libc;
     /// use std::fs::OpenOptions;
-    /// use std::os::unix::fs::OpenOptionsExt;
+    /// use std::os::redox::fs::OpenOptionsExt;
     ///
+    /// # fn main() {
     /// let mut options = OpenOptions::new();
     /// options.write(true);
-    /// if cfg!(unix) {
+    /// if cfg!(target_os = "redox") {
     ///     options.custom_flags(libc::O_NOFOLLOW);
     /// }
     /// let file = options.open("foo.txt");
+    /// # }
     /// ```
     #[stable(feature = "open_options_ext", since = "1.10.0")]
     fn custom_flags(&mut self, flags: i32) -> &mut Self;
@@ -226,7 +236,7 @@ impl MetadataExt for fs::Metadata {
     }
 }
 
-/// Add special unix types (block/char device, fifo and socket)
+/// Add special Redox types (block/char device, fifo and socket)
 #[stable(feature = "file_type_ext", since = "1.5.0")]
 pub trait FileTypeExt {
     /// Returns whether this file type is a block device.
@@ -267,7 +277,7 @@ impl FileTypeExt for fs::FileType {
 /// # Examples
 ///
 /// ```
-/// use std::os::unix::fs;
+/// use std::os::redox::fs;
 ///
 /// # fn foo() -> std::io::Result<()> {
 /// fs::symlink("a.txt", "b.txt")?;
@@ -281,16 +291,16 @@ pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()>
 }
 
 #[stable(feature = "dir_builder", since = "1.6.0")]
-/// An extension trait for `fs::DirBuilder` for unix-specific options.
+/// An extension trait for `fs::DirBuilder` for Redox-specific options.
 pub trait DirBuilderExt {
     /// Sets the mode to create new directories with. This option defaults to
     /// 0o777.
     ///
     /// # Examples
     ///
-    /// ```ignore
+    /// ```no_run
     /// use std::fs::DirBuilder;
-    /// use std::os::unix::fs::DirBuilderExt;
+    /// use std::os::redox::fs::DirBuilderExt;
     ///
     /// let mut builder = DirBuilder::new();
     /// builder.mode(0o755);
diff --git a/src/libstd/sys/redox/os.rs b/src/libstd/sys/redox/os.rs
index 9d459581dd4..e38b7b29f48 100644
--- a/src/libstd/sys/redox/os.rs
+++ b/src/libstd/sys/redox/os.rs
@@ -179,7 +179,7 @@ pub fn getenv(key: &OsStr) -> io::Result<Option<OsString>> {
 
 pub fn setenv(key: &OsStr, value: &OsStr) -> io::Result<()> {
     if ! key.is_empty() {
-        let mut file = ::fs::File::open(&("env:".to_owned() + key.to_str().unwrap()))?;
+        let mut file = ::fs::File::create(&("env:".to_owned() + key.to_str().unwrap()))?;
         file.write_all(value.as_bytes())?;
         file.set_len(value.len() as u64)?;
     }
diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs
index 17de46636b5..26710bf61d5 100644
--- a/src/libstd/sys/unix/ext/fs.rs
+++ b/src/libstd/sys/unix/ext/fs.rs
@@ -73,15 +73,17 @@ pub trait PermissionsExt {
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```no_run
     /// use std::fs::File;
     /// use std::os::unix::fs::PermissionsExt;
     ///
+    /// # fn run() -> std::io::Result<()> {
     /// let f = File::create("foo.txt")?;
     /// let metadata = f.metadata()?;
     /// let permissions = metadata.permissions();
     ///
     /// println!("permissions: {}", permissions.mode());
+    /// # Ok(()) }
     /// ```
     #[stable(feature = "fs_ext", since = "1.1.0")]
     fn mode(&self) -> u32;
@@ -90,16 +92,18 @@ pub trait PermissionsExt {
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```no_run
     /// use std::fs::File;
     /// use std::os::unix::fs::PermissionsExt;
     ///
+    /// # fn run() -> std::io::Result<()> {
     /// let f = File::create("foo.txt")?;
     /// let metadata = f.metadata()?;
     /// let mut permissions = metadata.permissions();
     ///
     /// permissions.set_mode(0o644); // Read/write for owner and read for others.
     /// assert_eq!(permissions.mode(), 0o644);
+    /// # Ok(()) }
     /// ```
     #[stable(feature = "fs_ext", since = "1.1.0")]
     fn set_mode(&mut self, mode: u32);
@@ -109,7 +113,7 @@ pub trait PermissionsExt {
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```
     /// use std::fs::Permissions;
     /// use std::os::unix::fs::PermissionsExt;
     ///
@@ -149,14 +153,17 @@ pub trait OpenOptionsExt {
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```no_run
+    /// # #![feature(libc)]
     /// extern crate libc;
     /// use std::fs::OpenOptions;
     /// use std::os::unix::fs::OpenOptionsExt;
     ///
+    /// # fn main() {
     /// let mut options = OpenOptions::new();
     /// options.mode(0o644); // Give read/write for owner and read for others.
     /// let file = options.open("foo.txt");
+    /// # }
     /// ```
     #[stable(feature = "fs_ext", since = "1.1.0")]
     fn mode(&mut self, mode: u32) -> &mut Self;
@@ -171,17 +178,20 @@ pub trait OpenOptionsExt {
     ///
     /// # Examples
     ///
-    /// ```rust,ignore
+    /// ```no_run
+    /// # #![feature(libc)]
     /// extern crate libc;
     /// use std::fs::OpenOptions;
     /// use std::os::unix::fs::OpenOptionsExt;
     ///
+    /// # fn main() {
     /// let mut options = OpenOptions::new();
     /// options.write(true);
     /// if cfg!(unix) {
     ///     options.custom_flags(libc::O_NOFOLLOW);
     /// }
     /// let file = options.open("foo.txt");
+    /// # }
     /// ```
     #[stable(feature = "open_options_ext", since = "1.10.0")]
     fn custom_flags(&mut self, flags: i32) -> &mut Self;
@@ -353,7 +363,7 @@ pub trait DirBuilderExt {
     ///
     /// # Examples
     ///
-    /// ```ignore
+    /// ```no_run
     /// use std::fs::DirBuilder;
     /// use std::os::unix::fs::DirBuilderExt;
     ///
diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs
index 2d00cb38ec4..67348a00494 100644
--- a/src/libstd/sys/windows/ext/fs.rs
+++ b/src/libstd/sys/windows/ext/fs.rs
@@ -169,8 +169,10 @@ pub trait OpenOptionsExt {
     ///
     /// # Examples
     ///
-    /// ```ignore
+    /// ```no_run
+    /// # #[cfg(for_demonstration_only)]
     /// extern crate winapi;
+    /// # mod winapi { pub const FILE_FLAG_DELETE_ON_CLOSE: u32 = 0x04000000; }
     ///
     /// use std::fs::OpenOptions;
     /// use std::os::windows::prelude::*;
@@ -204,8 +206,10 @@ pub trait OpenOptionsExt {
     ///
     /// # Examples
     ///
-    /// ```ignore
+    /// ```no_run
+    /// # #[cfg(for_demonstration_only)]
     /// extern crate winapi;
+    /// # mod winapi { pub const FILE_ATTRIBUTE_HIDDEN: u32 = 2; }
     ///
     /// use std::fs::OpenOptions;
     /// use std::os::windows::prelude::*;
diff --git a/src/libstd/sys_common/thread_local.rs b/src/libstd/sys_common/thread_local.rs
index 0ade90e64c3..9ba023b57e6 100644
--- a/src/libstd/sys_common/thread_local.rs
+++ b/src/libstd/sys_common/thread_local.rs
@@ -33,7 +33,7 @@
 //! Using a dynamically allocated TLS key. Note that this key can be shared
 //! among many threads via an `Arc`.
 //!
-//! ```rust,ignore
+//! ```ignore (cannot-doctest-private-modules)
 //! let key = Key::new(None);
 //! assert!(key.get().is_null());
 //! key.set(1 as *mut u8);
@@ -45,7 +45,7 @@
 //! Sometimes a statically allocated key is either required or easier to work
 //! with, however.
 //!
-//! ```rust,ignore
+//! ```ignore (cannot-doctest-private-modules)
 //! static KEY: StaticKey = INIT;
 //!
 //! unsafe {
@@ -74,7 +74,7 @@ use sys_common::mutex::Mutex;
 ///
 /// # Examples
 ///
-/// ```ignore
+/// ```ignore (cannot-doctest-private-modules)
 /// use tls::os::{StaticKey, INIT};
 ///
 /// static KEY: StaticKey = INIT;
@@ -105,7 +105,7 @@ pub struct StaticKey {
 ///
 /// # Examples
 ///
-/// ```rust,ignore
+/// ```ignore (cannot-doctest-private-modules)
 /// use tls::os::Key;
 ///
 /// let key = Key::new(None);