From 87f5a98a5d8f29d1a631cd06a39863a1e494b4d7 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Fri, 18 Jan 2019 19:08:31 +0100 Subject: Use `to_ne_bytes` for converting IPv4Address to octets It is easier and it should be also faster, because `to_ne_bytes` just calls `mem::transmute`. --- src/libstd/net/ip.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index f98113e0896..29f635919cb 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -393,8 +393,7 @@ impl Ipv4Addr { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn octets(&self) -> [u8; 4] { - let bits = u32::from_be(self.inner.s_addr); - [(bits >> 24) as u8, (bits >> 16) as u8, (bits >> 8) as u8, bits as u8] + self.inner.s_addr.to_ne_bytes() } /// Returns [`true`] for the special 'unspecified' address (0.0.0.0). -- cgit 1.4.1-3-g733a5 From 27c8dfddac4c69a6fd399abe537e1007306c58cf Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Sun, 3 Feb 2019 22:38:43 -0800 Subject: Improve error message and docs for non-UTF-8 bytes in stdio on Windows cc #23344 --- src/libstd/io/stdio.rs | 45 +++++++++++++++++++++++++++++++++++++++++ src/libstd/sys/windows/stdio.rs | 4 +++- 2 files changed, 48 insertions(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index d2494693230..4068c0f9c7d 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -131,6 +131,11 @@ fn handle_ebadf(r: io::Result, default: T) -> io::Result { /// /// [`io::stdin`]: fn.stdin.html /// [`BufRead`]: trait.BufRead.html +/// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return +/// an error. #[stable(feature = "rust1", since = "1.0.0")] pub struct Stdin { inner: Arc>>>, @@ -144,6 +149,11 @@ pub struct Stdin { /// [`Read`]: trait.Read.html /// [`BufRead`]: trait.BufRead.html /// [`Stdin::lock`]: struct.Stdin.html#method.lock +/// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return +/// an error. #[stable(feature = "rust1", since = "1.0.0")] pub struct StdinLock<'a> { inner: MutexGuard<'a, BufReader>>, @@ -157,6 +167,11 @@ pub struct StdinLock<'a> { /// /// [lock]: struct.Stdin.html#method.lock /// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return +/// an error. +/// /// # Examples /// /// Using implicit synchronization: @@ -328,6 +343,11 @@ impl<'a> fmt::Debug for StdinLock<'a> { /// /// Created by the [`io::stdout`] method. /// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. +/// /// [`lock`]: #method.lock /// [`io::stdout`]: fn.stdout.html #[stable(feature = "rust1", since = "1.0.0")] @@ -343,6 +363,11 @@ pub struct Stdout { /// This handle implements the [`Write`] trait, and is constructed via /// the [`Stdout::lock`] method. /// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. +/// /// [`Write`]: trait.Write.html /// [`Stdout::lock`]: struct.Stdout.html#method.lock #[stable(feature = "rust1", since = "1.0.0")] @@ -358,6 +383,11 @@ pub struct StdoutLock<'a> { /// /// [Stdout::lock]: struct.Stdout.html#method.lock /// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. +/// /// # Examples /// /// Using implicit synchronization: @@ -476,6 +506,11 @@ impl<'a> fmt::Debug for StdoutLock<'a> { /// For more information, see the [`io::stderr`] method. /// /// [`io::stderr`]: fn.stderr.html +/// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. #[stable(feature = "rust1", since = "1.0.0")] pub struct Stderr { inner: Arc>>>, @@ -487,6 +522,11 @@ pub struct Stderr { /// the [`Stderr::lock`] method. /// /// [`Stderr::lock`]: struct.Stderr.html#method.lock +/// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. #[stable(feature = "rust1", since = "1.0.0")] pub struct StderrLock<'a> { inner: ReentrantMutexGuard<'a, RefCell>>, @@ -496,6 +536,11 @@ pub struct StderrLock<'a> { /// /// This handle is not buffered. /// +/// ### Note: Windows Portability Consideration +/// When operating in a console, the Windows implementation of this stream does not support +/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return +/// an error. +/// /// # Examples /// /// Using implicit synchronization: diff --git a/src/libstd/sys/windows/stdio.rs b/src/libstd/sys/windows/stdio.rs index a4f4bd22cd9..0ea19a85525 100644 --- a/src/libstd/sys/windows/stdio.rs +++ b/src/libstd/sys/windows/stdio.rs @@ -188,7 +188,9 @@ impl Output { } fn invalid_encoding() -> io::Error { - io::Error::new(io::ErrorKind::InvalidData, "text was not valid unicode") + io::Error::new(io::ErrorKind::InvalidData, + "Windows stdio in console mode does not support non-UTF-8 byte sequences; \ + see https://github.com/rust-lang/rust/issues/23344") } fn readconsole_input_control(wakeup_mask: c::ULONG) -> c::CONSOLE_READCONSOLE_CONTROL { -- cgit 1.4.1-3-g733a5 From 82df9d7434c949b4357fb4c80c36961404226f93 Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Mon, 4 Feb 2019 16:02:54 +0530 Subject: Remove stray FIXME --- src/libstd/sys/sgx/rwlock.rs | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/sgx/rwlock.rs b/src/libstd/sys/sgx/rwlock.rs index 43ceae7d33b..33163a556c1 100644 --- a/src/libstd/sys/sgx/rwlock.rs +++ b/src/libstd/sys/sgx/rwlock.rs @@ -19,9 +19,6 @@ unsafe fn rw_lock_size_assert(r: RWLock) { mem::transmute::(r); } -//unsafe impl Send for RWLock {} -//unsafe impl Sync for RWLock {} // FIXME - impl RWLock { pub const fn new() -> RWLock { RWLock { -- cgit 1.4.1-3-g733a5 From 4c8c0fc1e2145b520ef31d1bf5e4d3fa1050c579 Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Tue, 5 Feb 2019 16:19:05 +0530 Subject: SGX target: handle empty user buffers correctly --- src/libstd/sys/sgx/abi/usercalls/alloc.rs | 7 ++++++- src/libstd/sys/sgx/abi/usercalls/mod.rs | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/sgx/abi/usercalls/alloc.rs b/src/libstd/sys/sgx/abi/usercalls/alloc.rs index 8d0013a235a..2efbaa9b148 100644 --- a/src/libstd/sys/sgx/abi/usercalls/alloc.rs +++ b/src/libstd/sys/sgx/abi/usercalls/alloc.rs @@ -537,7 +537,12 @@ impl UserRef { pub fn copy_user_buffer(&self) -> Vec { unsafe { let buf = self.to_enclave(); - User::from_raw_parts(buf.data as _, buf.len).to_enclave() + if buf.len > 0 { + User::from_raw_parts(buf.data as _, buf.len).to_enclave() + } else { + // Mustn't look at `data` or call `free` if `len` is `0`. + Vec::with_capacity(0) + } } } } diff --git a/src/libstd/sys/sgx/abi/usercalls/mod.rs b/src/libstd/sys/sgx/abi/usercalls/mod.rs index 58903761ebe..511d6e9e927 100644 --- a/src/libstd/sys/sgx/abi/usercalls/mod.rs +++ b/src/libstd/sys/sgx/abi/usercalls/mod.rs @@ -22,7 +22,8 @@ pub fn read(fd: Fd, buf: &mut [u8]) -> IoResult { #[unstable(feature = "sgx_platform", issue = "56975")] pub fn read_alloc(fd: Fd) -> IoResult> { unsafe { - let mut userbuf = alloc::User::::uninitialized(); + let userbuf = ByteBuffer { data: ::ptr::null_mut(), len: 0 }; + let mut userbuf = alloc::User::new_from_enclave(&userbuf); raw::read_alloc(fd, userbuf.as_raw_mut_ptr()).from_sgx_result()?; Ok(userbuf.copy_user_buffer()) } -- cgit 1.4.1-3-g733a5 From d89ebdd475ceaa35173e7d39dfdf23f8b7318745 Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Tue, 5 Feb 2019 16:19:20 +0530 Subject: Expose correct items in `os::fortanix_sgx::usercalls::alloc` --- src/libstd/os/fortanix_sgx/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/os/fortanix_sgx/mod.rs b/src/libstd/os/fortanix_sgx/mod.rs index 810965fc1b8..f536c5d04e6 100644 --- a/src/libstd/os/fortanix_sgx/mod.rs +++ b/src/libstd/os/fortanix_sgx/mod.rs @@ -16,7 +16,7 @@ pub mod usercalls { /// Primitives for allocating memory in userspace as well as copying data /// to and from user memory. pub mod alloc { - pub use sys::abi::usercalls::alloc; + pub use sys::abi::usercalls::alloc::*; } /// Lowest-level interfaces to usercalls and usercall ABI type definitions. -- cgit 1.4.1-3-g733a5 From 8b886e07f52d1523421a3cf0c484a4898d13b432 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 5 Feb 2019 14:37:15 +0100 Subject: Remove images' url to make it work even without internet connection --- src/liballoc/lib.rs | 4 +--- src/libarena/lib.rs | 4 +--- src/libcore/lib.rs | 4 +--- src/libfmt_macros/lib.rs | 4 +--- src/libgraphviz/lib.rs | 4 +--- src/libpanic_abort/lib.rs | 4 +--- src/libpanic_unwind/lib.rs | 4 +--- src/libproc_macro/lib.rs | 4 +--- src/librustc/lib.rs | 4 +--- src/librustc_apfloat/lib.rs | 4 +--- src/librustc_borrowck/lib.rs | 4 +--- src/librustc_codegen_llvm/lib.rs | 4 +--- src/librustc_codegen_ssa/lib.rs | 4 +--- src/librustc_codegen_utils/codegen_backend.rs | 4 +--- src/librustc_codegen_utils/lib.rs | 4 +--- src/librustc_data_structures/lib.rs | 4 +--- src/librustc_driver/lib.rs | 4 +--- src/librustc_errors/lib.rs | 4 +--- src/librustc_incremental/lib.rs | 4 +--- src/librustc_lint/lib.rs | 4 +--- src/librustc_llvm/lib.rs | 4 +--- src/librustc_metadata/lib.rs | 4 +--- src/librustc_passes/lib.rs | 4 +--- src/librustc_plugin/lib.rs | 4 +--- src/librustc_privacy/lib.rs | 4 +--- src/librustc_resolve/lib.rs | 4 +--- src/librustc_save_analysis/lib.rs | 4 +--- src/librustc_target/lib.rs | 4 +--- src/librustc_typeck/lib.rs | 4 +--- src/librustdoc/lib.rs | 4 +--- src/libserialize/lib.rs | 4 +--- src/libstd/lib.rs | 4 +--- src/libsyntax/lib.rs | 4 +--- src/libsyntax_ext/lib.rs | 4 +--- src/libsyntax_pos/lib.rs | 4 +--- src/libterm/lib.rs | 4 +--- src/libtest/lib.rs | 7 +------ 37 files changed, 37 insertions(+), 114 deletions(-) (limited to 'src/libstd') diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 80097a128a5..189ba84eeed 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -55,9 +55,7 @@ reason = "this library is unlikely to be stabilized in its current \ form or name", issue = "27783")] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/", test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))] #![no_std] diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 9f9ded51e37..aa522d86dcf 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -8,9 +8,7 @@ //! This crate implements `TypedArena`, a simple arena that can only hold //! objects of a single type. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(no_crate_inject, attr(deny(warnings))))] #![feature(alloc)] diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 7180a813a3e..78f1c3c0dff 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -51,9 +51,7 @@ #![cfg(not(test))] #![stable(feature = "core", since = "1.6.0")] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/", test(no_crate_inject, attr(deny(warnings))), diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 7bfe2377cea..ea67c01dfc9 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -4,9 +4,7 @@ //! Parsing does not happen at runtime: structures of `std::fmt::rt` are //! generated instead. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))] diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index f05f6e6651f..8ce0f755df0 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -271,9 +271,7 @@ //! //! * [DOT language](http://www.graphviz.org/doc/info/lang.html) -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(allow(unused_variables), deny(warnings))))] #![deny(rust_2018_idioms)] diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index daa1998d29d..7c6f36ece3c 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -5,9 +5,7 @@ #![no_std] #![unstable(feature = "panic_abort", issue = "32837")] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] #![panic_runtime] diff --git a/src/libpanic_unwind/lib.rs b/src/libpanic_unwind/lib.rs index 98f174710d2..fa7a0916d42 100644 --- a/src/libpanic_unwind/lib.rs +++ b/src/libpanic_unwind/lib.rs @@ -14,9 +14,7 @@ #![no_std] #![unstable(feature = "panic_unwind", issue = "32837")] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] #![feature(allocator_api)] diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index bb6f5e234f7..2cdc5a48a53 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -9,9 +9,7 @@ #![stable(feature = "proc_macro_lib", since = "1.15.0")] #![deny(missing_docs)] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/", test(no_crate_inject, attr(deny(warnings))), diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index d1951351520..be147556477 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -26,9 +26,7 @@ //! //! This API is completely unstable and subject to change. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![deny(rust_2018_idioms)] #![allow(explicit_outlives_requirements)] diff --git a/src/librustc_apfloat/lib.rs b/src/librustc_apfloat/lib.rs index 17311f0688f..f79d448edce 100644 --- a/src/librustc_apfloat/lib.rs +++ b/src/librustc_apfloat/lib.rs @@ -30,9 +30,7 @@ //! //! This API is completely unstable and subject to change. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![forbid(unsafe_code)] #![deny(rust_2018_idioms)] diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index 8bdc4e1d5c1..49890330a4e 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -1,6 +1,4 @@ -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![allow(non_camel_case_types)] diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index ab2fb67d549..ad8db25ee95 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -4,9 +4,7 @@ //! //! This API is completely unstable and subject to change. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(box_patterns)] #![feature(box_syntax)] diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs index 1accbeb2aa8..58b3f0434a6 100644 --- a/src/librustc_codegen_ssa/lib.rs +++ b/src/librustc_codegen_ssa/lib.rs @@ -1,6 +1,4 @@ -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(box_patterns)] #![feature(box_syntax)] diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs index 8981c542961..a87b02d33de 100644 --- a/src/librustc_codegen_utils/codegen_backend.rs +++ b/src/librustc_codegen_utils/codegen_backend.rs @@ -4,9 +4,7 @@ //! //! This API is completely unstable and subject to change. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![deny(warnings)] #![feature(box_syntax)] diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index 8e96f985401..d6ef555144d 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -2,9 +2,7 @@ //! //! This API is completely unstable and subject to change. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(box_patterns)] #![feature(box_syntax)] diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index ec71f515894..a46f8aed324 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -6,9 +6,7 @@ //! //! This API is completely unstable and subject to change. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(in_band_lifetimes)] #![feature(unboxed_closures)] diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index d0dc7799c7b..189869c1155 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -4,9 +4,7 @@ //! //! This API is completely unstable and subject to change. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(box_syntax)] #![cfg_attr(unix, feature(libc))] diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 831415ed0bb..ea530fa1bfb 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -1,6 +1,4 @@ -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(custom_attribute)] #![allow(unused_attributes)] diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index ae2e6e0b94c..f69a1cfa3a9 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -1,8 +1,6 @@ //! Support for serializing the dep-graph and reloading it. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(nll)] #![feature(specialization)] diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 6607951d2cd..fd5e68d5ae6 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -9,9 +9,7 @@ //! //! This API is completely unstable and subject to change. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![cfg_attr(test, feature(test))] #![feature(box_patterns)] diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 99c5e2493ed..3fcb20a29dd 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -1,9 +1,7 @@ #![deny(rust_2018_idioms)] #![feature(static_nobundle)] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. #[allow(unused_extern_crates)] diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 1a661421240..5dc736bfbd3 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -1,6 +1,4 @@ -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(box_patterns)] #![feature(libc)] diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 76605c58a78..625f2fcb249 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -4,9 +4,7 @@ //! //! This API is completely unstable and subject to change. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(nll)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 9a31bddc1ed..32e003ff107 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -50,9 +50,7 @@ //! See the [`plugin` feature](../unstable-book/language-features/plugin.html) of //! the Unstable Book for more examples. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 000c6bb275b..14a0922c477 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1,6 +1,4 @@ -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![deny(rust_2018_idioms)] diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index b166b1be02f..270f2424197 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1,6 +1,4 @@ -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(crate_visibility_modifier)] #![feature(label_break_value)] diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 73eb5de5c76..b9d195d5715 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -1,6 +1,4 @@ -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(custom_attribute)] #![feature(nll)] #![allow(unused_attributes)] diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index 0df0027c171..8e9d0851af1 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -7,9 +7,7 @@ //! more 'stuff' here in the future. It does not have a dependency on //! LLVM. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(box_syntax)] #![feature(nll)] diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index d5e870bb28d..8d77310f3d4 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -55,9 +55,7 @@ This API is completely unstable and subject to change. */ -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![allow(non_camel_case_types)] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index f4149b5f357..ddb730672d2 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -1,6 +1,4 @@ -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/")] #![feature(bind_by_move_pattern_guards)] diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index e8d185a9cc0..fe93a2dfb29 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -4,9 +4,7 @@ Core encoding and decoding interfaces. */ -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", test(attr(allow(unused_variables), deny(warnings))))] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 244caf28ec7..8ecba3ecd68 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -196,9 +196,7 @@ //! [primitive types]: ../book/ch03-02-data-types.html #![stable(feature = "rust1", since = "1.0.0")] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/", test(no_crate_inject, attr(deny(warnings))), diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index c04391b34ee..878d06c0f14 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -4,9 +4,7 @@ //! //! This API is completely unstable and subject to change. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))] #![deny(rust_2018_idioms)] diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 9308cfb3a4f..670d71fe25b 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -1,8 +1,6 @@ //! Syntax extensions in the Rust compiler. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![deny(rust_2018_idioms)] diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 13e7307570a..70c45f7f9a7 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -4,9 +4,7 @@ //! //! This API is completely unstable and subject to change. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![deny(rust_2018_idioms)] diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index 115dffa5799..4d3126212dc 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -30,9 +30,7 @@ //! [win]: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682010%28v=vs.85%29.aspx //! [ti]: https://en.wikipedia.org/wiki/Terminfo -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))] #![deny(missing_docs)] diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index cced66f4a22..ae046f6d614 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -20,12 +20,7 @@ #![deny(rust_2018_idioms)] #![crate_name = "test"] #![unstable(feature = "test", issue = "27812")] -#![doc( - html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", - test(attr(deny(warnings))) -)] +#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))] #![feature(asm)] #![feature(fnbox)] #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))] -- cgit 1.4.1-3-g733a5 From 541503afa13a4ea8596755e0e88e6dd13a95faa5 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 8 Feb 2019 11:41:01 +0100 Subject: std::sys::unix::stdio: explain why we do into_raw --- src/libstd/sys/unix/stdio.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/unix/stdio.rs b/src/libstd/sys/unix/stdio.rs index 8a6b7b5f876..715f2eafb2d 100644 --- a/src/libstd/sys/unix/stdio.rs +++ b/src/libstd/sys/unix/stdio.rs @@ -12,7 +12,7 @@ impl Stdin { pub fn read(&self, data: &mut [u8]) -> io::Result { let fd = FileDesc::new(libc::STDIN_FILENO); let ret = fd.read(data); - fd.into_raw(); + fd.into_raw(); // do not close this FD ret } } @@ -23,7 +23,7 @@ impl Stdout { pub fn write(&self, data: &[u8]) -> io::Result { let fd = FileDesc::new(libc::STDOUT_FILENO); let ret = fd.write(data); - fd.into_raw(); + fd.into_raw(); // do not close this FD ret } @@ -38,7 +38,7 @@ impl Stderr { pub fn write(&self, data: &[u8]) -> io::Result { let fd = FileDesc::new(libc::STDERR_FILENO); let ret = fd.write(data); - fd.into_raw(); + fd.into_raw(); // do not close this FD ret } -- cgit 1.4.1-3-g733a5 From 4833074a9a47c12bcfeee4435bf981981ede689c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 10 Feb 2019 19:08:49 +0100 Subject: fix SGX build failures --- src/libstd/sys/sgx/ext/arch.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/sgx/ext/arch.rs b/src/libstd/sys/sgx/ext/arch.rs index 3bd87b5d265..97f7d9181a5 100644 --- a/src/libstd/sys/sgx/ext/arch.rs +++ b/src/libstd/sys/sgx/ext/arch.rs @@ -41,7 +41,7 @@ pub fn egetkey(request: &Align512<[u8; 512]>) -> Result, u32> ); match error { - 0 => Ok(out.into_inner()), + 0 => Ok(out.into_initialized()), err => Err(err), } } @@ -69,6 +69,6 @@ pub fn ereport( "{rdx}"(report.as_mut_ptr()) ); - report.into_inner() + report.into_initialized() } } -- cgit 1.4.1-3-g733a5 From b87363e7632b3f20f9b529696ffb5d5d9c3927cd Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Sat, 9 Feb 2019 21:23:30 +0000 Subject: tests: doc comments --- src/liballoc/collections/btree/node.rs | 6 ++--- src/liballoc/collections/vec_deque.rs | 4 ++-- src/liballoc/fmt.rs | 6 ++--- src/liballoc/macros.rs | 6 ++--- src/liballoc/vec.rs | 2 +- src/libcore/alloc.rs | 2 +- src/libcore/any.rs | 6 ++--- src/libcore/cell.rs | 8 +++---- src/libcore/cmp.rs | 2 +- src/libcore/convert.rs | 2 +- src/libcore/intrinsics.rs | 12 +++++----- src/libcore/iter/traits/iterator.rs | 10 ++++---- src/libcore/macros.rs | 2 +- src/libcore/mem.rs | 4 ++-- src/libcore/num/dec2flt/mod.rs | 6 ++--- src/libcore/num/dec2flt/rawfp.rs | 10 ++++---- src/libcore/ops/arith.rs | 2 +- src/libcore/ops/try.rs | 2 +- src/libcore/ptr.rs | 16 ++++++------- src/libcore/slice/mod.rs | 6 ++--- src/libcore/slice/rotate.rs | 8 +++---- src/libcore/str/mod.rs | 20 ++++++++-------- src/libcore/time.rs | 2 +- src/libproc_macro/bridge/scoped_cell.rs | 4 ++-- src/libproc_macro/diagnostic.rs | 8 +++---- src/libproc_macro/lib.rs | 12 +++++----- src/libstd/f64.rs | 2 +- src/libstd/ffi/os_str.rs | 2 +- src/libstd/fs.rs | 4 ++-- src/libstd/io/buffered.rs | 8 +++---- src/libstd/keyword_docs.rs | 2 +- src/libstd/macros.rs | 28 +++++++++++----------- src/libstd/net/addr.rs | 2 +- src/libstd/primitive_docs.rs | 2 +- src/libstd/sync/condvar.rs | 8 +++---- src/libstd/sync/mpsc/mod.rs | 2 +- src/libstd/sync/mpsc/select.rs | 4 ++-- src/libstd/sync/rwlock.rs | 2 +- src/libstd/sys/redox/ext/fs.rs | 4 ++-- src/libstd/sys/unix/ext/fs.rs | 4 ++-- src/libstd/sys/windows/ext/ffi.rs | 16 ++++++------- src/libstd/thread/mod.rs | 2 +- src/libstd/time.rs | 2 +- .../incremental/change_add_field/struct_point.rs | 18 +++++++------- .../run-pass-fulldeps/pprust-expr-roundtrip.rs | 4 ++-- src/test/run-pass/auxiliary/svh-b.rs | 6 ++--- src/test/run-pass/issues/issue-7012.rs | 2 +- src/test/run-pass/item-attributes.rs | 2 +- src/test/run-pass/monomorphize-abi-alignment.rs | 2 +- .../run-pass/numbers-arithmetic/num-wrapping.rs | 2 +- src/test/rustdoc/auxiliary/enum_primitive.rs | 2 +- src/test/rustdoc/issue-27862.rs | 2 +- .../associated-types-coherence-failure.rs | 2 +- src/test/ui/issues/issue-20797.rs | 6 ++--- src/test/ui/issues/issue-48636.fixed | 2 +- src/test/ui/issues/issue-48636.rs | 2 +- .../ui/issues/issue-52126-assign-op-invariance.rs | 2 +- src/test/ui/nll/user-annotations/issue-55241.rs | 2 +- src/test/ui/on-unimplemented/bad-annotation.rs | 2 +- src/test/ui/on-unimplemented/on-trait.rs | 2 +- src/test/ui/svh/auxiliary/svh-b.rs | 6 ++--- 61 files changed, 164 insertions(+), 164 deletions(-) (limited to 'src/libstd') diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index c4f39430533..481ee7cebc4 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -50,11 +50,11 @@ pub const CAPACITY: usize = 2 * B - 1; /// /// We have a separate type for the header and rely on it matching the prefix of `LeafNode`, in /// order to statically allocate a single dummy node to avoid allocations. This struct is -/// `repr(C)` to prevent them from being reordered. `LeafNode` does not just contain a +/// `repr(C)` to prevent them from being reordered. `LeafNode` does not just contain a /// `NodeHeader` because we do not want unnecessary padding between `len` and the keys. -/// Crucially, `NodeHeader` can be safely transmuted to different K and V. (This is exploited +/// Crucially, `NodeHeader` can be safely transmuted to different K and V. (This is exploited /// by `as_header`.) -/// See `into_key_slice` for an explanation of K2. K2 cannot be safely transmuted around +/// See `into_key_slice` for an explanation of K2. K2 cannot be safely transmuted around /// because the size of `NodeHeader` depends on its alignment! #[repr(C)] struct NodeHeader { diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 99fa54acb08..a292bde3315 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -1922,7 +1922,7 @@ impl VecDeque { /// /// # Panics /// - /// If `mid` is greater than `len()`. Note that `mid == len()` + /// If `mid` is greater than `len()`. Note that `mid == len()` /// does _not_ panic and is a no-op rotation. /// /// # Complexity @@ -1967,7 +1967,7 @@ impl VecDeque { /// /// # Panics /// - /// If `k` is greater than `len()`. Note that `k == len()` + /// If `k` is greater than `len()`. Note that `k == len()` /// does _not_ panic and is a no-op rotation. /// /// # Complexity diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index 9bda7034a62..d2ba9b00191 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -27,7 +27,7 @@ //! will then parse the format string and determine if the list of arguments //! provided is suitable to pass to this format string. //! -//! To convert a single value to a string, use the [`to_string`] method. This +//! To convert a single value to a string, use the [`to_string`] method. This //! will use the [`Display`] formatting trait. //! //! ## Positional parameters @@ -102,7 +102,7 @@ //! When requesting that an argument be formatted with a particular type, you //! are actually requesting that an argument ascribes to a particular trait. //! This allows multiple actual types to be formatted via `{:x}` (like [`i8`] as -//! well as [`isize`]). The current mapping of types to traits is: +//! well as [`isize`]). The current mapping of types to traits is: //! //! * *nothing* ⇒ [`Display`] //! * `?` ⇒ [`Debug`] @@ -427,7 +427,7 @@ //! 3. An asterisk `.*`: //! //! `.*` means that this `{...}` is associated with *two* format inputs rather than one: the -//! first input holds the `usize` precision, and the second holds the value to print. Note that +//! first input holds the `usize` precision, and the second holds the value to print. Note that //! in this case, if one uses the format string `{:.*}`, then the `` part refers //! to the *value* to print, and the `precision` must come in the input preceding ``. //! diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs index db91b07fa71..4fe6d450add 100644 --- a/src/liballoc/macros.rs +++ b/src/liballoc/macros.rs @@ -62,8 +62,8 @@ macro_rules! vec { /// Creates a `String` using interpolation of runtime expressions. /// -/// The first argument `format!` receives is a format string. This must be a string -/// literal. The power of the formatting string is in the `{}`s contained. +/// The first argument `format!` receives is a format string. This must be a string +/// literal. The power of the formatting string is in the `{}`s contained. /// /// Additional parameters passed to `format!` replace the `{}`s within the /// formatting string in the order given unless named or positional parameters @@ -73,7 +73,7 @@ macro_rules! vec { /// The same convention is used with [`print!`] and [`write!`] macros, /// depending on the intended destination of the string. /// -/// To convert a single value to a string, use the [`to_string`] method. This +/// To convert a single value to a string, use the [`to_string`] method. This /// will use the [`Display`] formatting trait. /// /// [fmt]: ../std/fmt/index.html diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 57e10498b92..4bc21ec7f5e 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -738,7 +738,7 @@ impl Vec { /// Forces the length of the vector to `new_len`. /// /// This is a low-level operation that maintains none of the normal - /// invariants of the type. Normally changing the length of a vector + /// invariants of the type. Normally changing the length of a vector /// is done using one of the safe operations instead, such as /// [`truncate`], [`resize`], [`extend`], or [`clear`]. /// diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index 66a3094d77d..f49e226a5cb 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -425,7 +425,7 @@ impl fmt::Display for CannotReallocInPlace { /// The `GlobalAlloc` trait is an `unsafe` trait for a number of reasons, and /// implementors must ensure that they adhere to these contracts: /// -/// * It's undefined behavior if global allocators unwind. This restriction may +/// * It's undefined behavior if global allocators unwind. This restriction may /// be lifted in the future, but currently a panic from any of these /// functions may lead to memory unsafety. /// diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 2afd9e0c072..01ab523a4c3 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -18,7 +18,7 @@ //! //! Consider a situation where we want to log out a value passed to a function. //! We know the value we're working on implements Debug, but we don't know its -//! concrete type. We want to give special treatment to certain types: in this +//! concrete type. We want to give special treatment to certain types: in this //! case printing out the length of String values prior to their value. //! We don't know the concrete type of our value at compile time, so we need to //! use runtime reflection instead. @@ -31,8 +31,8 @@ //! fn log(value: &T) { //! let value_any = value as &dyn Any; //! -//! // try to convert our value to a String. If successful, we want to -//! // output the String's length as well as its value. If not, it's a +//! // Try to convert our value to a `String`. If successful, we want to +//! // output the String`'s length as well as its value. If not, it's a //! // different type: just print it out unadorned. //! match value_any.downcast_ref::() { //! Some(as_string) => { diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index d57ca13a334..fb8d7e5d088 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1133,7 +1133,7 @@ impl<'b, T: ?Sized> Ref<'b, T> { /// The `RefCell` is already immutably borrowed, so this cannot fail. /// /// This is an associated function that needs to be used as - /// `Ref::clone(...)`. A `Clone` implementation or a method would interfere + /// `Ref::clone(...)`. A `Clone` implementation or a method would interfere /// with the widespread use of `r.borrow().clone()` to clone the contents of /// a `RefCell`. #[stable(feature = "cell_extras", since = "1.15.0")] @@ -1174,7 +1174,7 @@ impl<'b, T: ?Sized> Ref<'b, T> { } } - /// Split a `Ref` into multiple `Ref`s for different components of the + /// Splits a `Ref` into multiple `Ref`s for different components of the /// borrowed data. /// /// The `RefCell` is already immutably borrowed, so this cannot fail. @@ -1223,7 +1223,7 @@ impl<'b, T: ?Sized> RefMut<'b, T> { /// The `RefCell` is already mutably borrowed, so this cannot fail. /// /// This is an associated function that needs to be used as - /// `RefMut::map(...)`. A method would interfere with methods of the same + /// `RefMut::map(...)`. A method would interfere with methods of the same /// name on the contents of a `RefCell` used through `Deref`. /// /// # Examples @@ -1253,7 +1253,7 @@ impl<'b, T: ?Sized> RefMut<'b, T> { } } - /// Split a `RefMut` into multiple `RefMut`s for different components of the + /// Splits a `RefMut` into multiple `RefMut`s for different components of the /// borrowed data. /// /// The underlying `RefCell` will remain mutably borrowed until both diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index d43a5c1032c..81fcdeee12d 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -26,7 +26,7 @@ use self::Ordering::*; /// relations](http://en.wikipedia.org/wiki/Partial_equivalence_relation). /// /// This trait allows for partial equality, for types that do not have a full -/// equivalence relation. For example, in floating point numbers `NaN != NaN`, +/// equivalence relation. For example, in floating point numbers `NaN != NaN`, /// so floating point types implement `PartialEq` but not `Eq`. /// /// Formally, the equality must be (for all `a`, `b` and `c`): diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 203be541e49..de34e79f597 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -217,7 +217,7 @@ pub trait AsMut { /// /// There is one exception to implementing `Into`, and it's kind of esoteric. /// If the destination type is not part of the current crate, and it uses a -/// generic variable, then you can't implement `From` directly. For example, +/// generic variable, then you can't implement `From` directly. For example, /// take this crate: /// /// ```compile_fail diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index e927ed40d7f..c29358c4c4a 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1,6 +1,6 @@ -//! rustc compiler intrinsics. +//! Compiler intrinsics. //! -//! The corresponding definitions are in librustc_codegen_llvm/intrinsic.rs. +//! The corresponding definitions are in `librustc_codegen_llvm/intrinsic.rs`. //! //! # Volatiles //! @@ -697,7 +697,7 @@ extern "rust-intrinsic" { /// Creates a value initialized to zero. /// /// `init` is unsafe because it returns a zeroed-out datum, - /// which is unsafe unless T is `Copy`. Also, even if T is + /// which is unsafe unless `T` is `Copy`. Also, even if T is /// `Copy`, an all-zero value may not correspond to any legitimate /// state for the type in question. pub fn init() -> T; @@ -988,7 +988,7 @@ extern "rust-intrinsic" { /// beginning at `dst` with the same size. /// /// Like [`read`], `copy_nonoverlapping` creates a bitwise copy of `T`, regardless of - /// whether `T` is [`Copy`]. If `T` is not [`Copy`], using *both* the values + /// whether `T` is [`Copy`]. If `T` is not [`Copy`], using *both* the values /// in the region beginning at `*src` and the region beginning at `*dst` can /// [violate memory safety][read-ownership]. /// @@ -1055,7 +1055,7 @@ extern "rust-intrinsic" { /// [`copy_nonoverlapping`] can be used instead. /// /// `copy` is semantically equivalent to C's [`memmove`], but with the argument - /// order swapped. Copying takes place as if the bytes were copied from `src` + /// order swapped. Copying takes place as if the bytes were copied from `src` /// to a temporary array and then copied from the array to `dst`. /// /// [`copy_nonoverlapping`]: ./fn.copy_nonoverlapping.html @@ -1072,7 +1072,7 @@ extern "rust-intrinsic" { /// * Both `src` and `dst` must be properly aligned. /// /// Like [`read`], `copy` creates a bitwise copy of `T`, regardless of - /// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the values + /// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the values /// in the region beginning at `*src` and the region beginning at `*dst` can /// [violate memory safety][read-ownership]. /// diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index 218c7199f35..1c86745d9ba 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -564,9 +564,9 @@ pub trait Iterator { /// Calls a closure on each element of an iterator. /// /// This is equivalent to using a [`for`] loop on the iterator, although - /// `break` and `continue` are not possible from a closure. It's generally + /// `break` and `continue` are not possible from a closure. It's generally /// more idiomatic to use a `for` loop, but `for_each` may be more legible - /// when processing items at the end of longer iterator chains. In some + /// when processing items at the end of longer iterator chains. In some /// cases `for_each` may also be faster than a loop, because it will use /// internal iteration on adaptors like `Chain`. /// @@ -1515,7 +1515,7 @@ pub trait Iterator { /// is propagated back to the caller immediately (short-circuiting). /// /// The initial value is the value the accumulator will have on the first - /// call. If applying the closure succeeded against every element of the + /// call. If applying the closure succeeded against every element of the /// iterator, `try_fold()` returns the final accumulator as success. /// /// Folding is useful whenever you have a collection of something, and want @@ -1528,10 +1528,10 @@ pub trait Iterator { /// do something better than the default `for` loop implementation. /// /// In particular, try to have this call `try_fold()` on the internal parts - /// from which this iterator is composed. If multiple calls are needed, + /// from which this iterator is composed. If multiple calls are needed, /// the `?` operator may be convenient for chaining the accumulator value /// along, but beware any invariants that need to be upheld before those - /// early returns. This is a `&mut self` method, so iteration needs to be + /// early returns. This is a `&mut self` method, so iteration needs to be /// resumable after hitting an error here. /// /// # Examples diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 664490c1997..d81d309a81a 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -432,7 +432,7 @@ macro_rules! writeln { /// * Iterators that dynamically terminate. /// /// If the determination that the code is unreachable proves incorrect, the -/// program immediately terminates with a [`panic!`]. The function [`unreachable_unchecked`], +/// program immediately terminates with a [`panic!`]. The function [`unreachable_unchecked`], /// which belongs to the [`std::hint`] module, informs the compiler to /// optimize the code out of the release version entirely. /// diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 2f86e13b938..855b8ba7f96 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -1101,7 +1101,7 @@ impl MaybeUninit { } /// Create a new `MaybeUninit` in an uninitialized state, with the memory being - /// filled with `0` bytes. It depends on `T` whether that already makes for + /// filled with `0` bytes. It depends on `T` whether that already makes for /// proper initialization. For example, `MaybeUninit::zeroed()` is initialized, /// but `MaybeUninit<&'static i32>::zeroed()` is not because references must not /// be null. @@ -1130,7 +1130,7 @@ impl MaybeUninit { } } - /// Extract the value from the `MaybeUninit` container. This is a great way + /// Extract the value from the `MaybeUninit` container. This is a great way /// to ensure that the data will get dropped, because the resulting `T` is /// subject to the usual drop handling. /// diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index 14a912872be..a1bf6f824f6 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -37,7 +37,7 @@ //! //! In addition, there are numerous helper functions that are used in the paper but not available //! in Rust (or at least in core). Our version is additionally complicated by the need to handle -//! overflow and underflow and the desire to handle subnormal numbers. Bellerophon and +//! overflow and underflow and the desire to handle subnormal numbers. Bellerophon and //! Algorithm R have trouble with overflow, subnormals, and underflow. We conservatively switch to //! Algorithm M (with the modifications described in section 8 of the paper) well before the //! inputs get into the critical region. @@ -148,7 +148,7 @@ macro_rules! from_str_float_impl { /// # Return value /// /// `Err(ParseFloatError)` if the string did not represent a valid - /// number. Otherwise, `Ok(n)` where `n` is the floating-point + /// number. Otherwise, `Ok(n)` where `n` is the floating-point /// number represented by `src`. #[inline] fn from_str(src: &str) -> Result { @@ -209,7 +209,7 @@ fn pfe_invalid() -> ParseFloatError { ParseFloatError { kind: FloatErrorKind::Invalid } } -/// Split decimal string into sign and the rest, without inspecting or validating the rest. +/// Splits a decimal string into sign and the rest, without inspecting or validating the rest. fn extract_sign(s: &str) -> (Sign, &str) { match s.as_bytes()[0] { b'+' => (Sign::Positive, &s[1..]), diff --git a/src/libcore/num/dec2flt/rawfp.rs b/src/libcore/num/dec2flt/rawfp.rs index 6976bd1a0ee..06d7fb8d103 100644 --- a/src/libcore/num/dec2flt/rawfp.rs +++ b/src/libcore/num/dec2flt/rawfp.rs @@ -59,10 +59,10 @@ pub trait RawFloat /// Type used by `to_bits` and `from_bits`. type Bits: Add + From + TryFrom; - /// Raw transmutation to integer. + /// Performs a raw transmutation to an integer. fn to_bits(self) -> Self::Bits; - /// Raw transmutation from integer. + /// Performs a raw transmutation from an integer. fn from_bits(v: Self::Bits) -> Self; /// Returns the category that this number falls into. @@ -71,14 +71,14 @@ pub trait RawFloat /// Returns the mantissa, exponent and sign as integers. fn integer_decode(self) -> (u64, i16, i8); - /// Decode the float. + /// Decodes the float. fn unpack(self) -> Unpacked; - /// Cast from a small integer that can be represented exactly. Panic if the integer can't be + /// Casts from a small integer that can be represented exactly. Panic if the integer can't be /// represented, the other code in this module makes sure to never let that happen. fn from_int(x: u64) -> Self; - /// Get the value 10e from a pre-computed table. + /// Gets the value 10e from a pre-computed table. /// Panics for `e >= CEIL_LOG5_OF_MAX_SIG`. fn short_fast_pow10(e: usize) -> Self; diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 7d8bf18d33a..202beddfcb0 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -518,7 +518,7 @@ pub trait Rem { macro_rules! rem_impl_integer { ($($t:ty)*) => ($( - /// This operation satisfies `n % d == n - (n / d) * d`. The + /// This operation satisfies `n % d == n - (n / d) * d`. The /// result has the same sign as the left operand. #[stable(feature = "rust1", since = "1.0.0")] impl Rem for $t { diff --git a/src/libcore/ops/try.rs b/src/libcore/ops/try.rs index 380bd12131c..9fa2c81954e 100644 --- a/src/libcore/ops/try.rs +++ b/src/libcore/ops/try.rs @@ -1,7 +1,7 @@ /// A trait for customizing the behavior of the `?` operator. /// /// A type implementing `Try` is one that has a canonical way to view it -/// in terms of a success/failure dichotomy. This trait allows both +/// in terms of a success/failure dichotomy. This trait allows both /// extracting those success or failure values from an existing instance and /// creating a new instance from a success or failure value. #[unstable(feature = "try_trait", issue = "42327")] diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 537aa92c2cf..20960845718 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -12,7 +12,7 @@ //! to access only a single value, in which case the documentation omits the size //! and implicitly assumes it to be `size_of::()` bytes. //! -//! The precise rules for validity are not determined yet. The guarantees that are +//! The precise rules for validity are not determined yet. The guarantees that are //! provided at this point are very minimal: //! //! * A [null] pointer is *never* valid, not even for accesses of [size zero][zst]. @@ -104,7 +104,7 @@ pub use intrinsics::write_bytes; /// /// * `to_drop` must be [valid] for reads. /// -/// * `to_drop` must be properly aligned. See the example below for how to drop +/// * `to_drop` must be properly aligned. See the example below for how to drop /// an unaligned pointer. /// /// Additionally, if `T` is not [`Copy`], using the pointed-to value after @@ -135,7 +135,7 @@ pub use intrinsics::write_bytes; /// unsafe { /// // Get a raw pointer to the last element in `v`. /// let ptr = &mut v[1] as *mut _; -/// // Shorten `v` to prevent the last item from being dropped. We do that first, +/// // Shorten `v` to prevent the last item from being dropped. We do that first, /// // to prevent issues if the `drop_in_place` below panics. /// v.set_len(1); /// // Without a call `drop_in_place`, the last item would never be dropped, @@ -531,7 +531,7 @@ pub unsafe fn replace(dst: *mut T, mut src: T) -> T { /// /// `read` creates a bitwise copy of `T`, regardless of whether `T` is [`Copy`]. /// If `T` is not [`Copy`], using both the returned value and the value at -/// `*src` can violate memory safety. Note that assigning to `*src` counts as a +/// `*src` can violate memory safety. Note that assigning to `*src` counts as a /// use because it will attempt to drop the value at `*src`. /// /// [`write`] can be used to overwrite data without causing it to be dropped. @@ -588,7 +588,7 @@ pub unsafe fn read(src: *const T) -> T { /// * `src` must be [valid] for reads. /// /// Like [`read`], `read_unaligned` creates a bitwise copy of `T`, regardless of -/// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned +/// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned /// value and the value at `*src` can [violate memory safety][read-ownership]. /// /// Note that even if `T` has size `0`, the pointer must be non-NULL. @@ -839,7 +839,7 @@ pub unsafe fn write_unaligned(dst: *mut T, src: T) { /// * `src` must be properly aligned. /// /// Like [`read`], `read_unaligned` creates a bitwise copy of `T`, regardless of -/// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned +/// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned /// value and the value at `*src` can [violate memory safety][read-ownership]. /// However, storing non-[`Copy`] types in volatile memory is almost certainly /// incorrect. @@ -1093,7 +1093,7 @@ impl *const T { /// unless `x` and `y` point into the same allocated object. /// /// Always use `.offset(count)` instead when possible, because `offset` - /// allows the compiler to optimize better. If you need to cross object + /// allows the compiler to optimize better. If you need to cross object /// boundaries, cast the pointer to an integer and do the arithmetic there. /// /// # Examples @@ -1712,7 +1712,7 @@ impl *mut T { /// unless `x` and `y` point into the same allocated object. /// /// Always use `.offset(count)` instead when possible, because `offset` - /// allows the compiler to optimize better. If you need to cross object + /// allows the compiler to optimize better. If you need to cross object /// boundaries, cast the pointer to an integer and do the arithmetic there. /// /// # Examples diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index d062da0c247..e2129c68e7f 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -1197,7 +1197,7 @@ impl [T] { /// Returns an iterator over subslices separated by elements that match /// `pred` limited to returning at most `n` items. This starts at the end of - /// the slice and works backwards. The matched element is not contained in + /// the slice and works backwards. The matched element is not contained in /// the subslices. /// /// The last element returned, if any, will contain the remainder of the @@ -3145,7 +3145,7 @@ unsafe impl Sync for Iter<'_, T> {} unsafe impl Send for Iter<'_, T> {} impl<'a, T> Iter<'a, T> { - /// View the underlying data as a subslice of the original data. + /// Views the underlying data as a subslice of the original data. /// /// This has the same lifetime as the original slice, and so the /// iterator can continue to be used while this exists. @@ -3247,7 +3247,7 @@ unsafe impl Sync for IterMut<'_, T> {} unsafe impl Send for IterMut<'_, T> {} impl<'a, T> IterMut<'a, T> { - /// View the underlying data as a subslice of the original data. + /// Views the underlying data as a subslice of the original data. /// /// To avoid creating `&mut` references that alias, this is forced /// to consume the iterator. diff --git a/src/libcore/slice/rotate.rs b/src/libcore/slice/rotate.rs index 52677713f5a..9b35b51349a 100644 --- a/src/libcore/slice/rotate.rs +++ b/src/libcore/slice/rotate.rs @@ -26,7 +26,7 @@ impl RawArray { } /// Rotates the range `[mid-left, mid+right)` such that the element at `mid` -/// becomes the first element. Equivalently, rotates the range `left` +/// becomes the first element. Equivalently, rotates the range `left` /// elements to the left or `right` elements to the right. /// /// # Safety @@ -36,10 +36,10 @@ impl RawArray { /// # Algorithm /// /// For longer rotations, swap the left-most `delta = min(left, right)` -/// elements with the right-most `delta` elements. LLVM vectorizes this, +/// elements with the right-most `delta` elements. LLVM vectorizes this, /// which is profitable as we only reach this step for a "large enough" -/// rotation. Doing this puts `delta` elements on the larger side into the -/// correct position, leaving a smaller rotate problem. Demonstration: +/// rotation. Doing this puts `delta` elements on the larger side into the +/// correct position, leaving a smaller rotate problem. Demonstration: /// /// ```text /// [ 6 7 8 9 10 11 12 13 . 1 2 3 4 5 ] diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 81c351be305..c43db916888 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -612,7 +612,7 @@ impl<'a> DoubleEndedIterator for Chars<'a> { impl FusedIterator for Chars<'_> {} impl<'a> Chars<'a> { - /// View the underlying data as a subslice of the original data. + /// Views the underlying data as a subslice of the original data. /// /// This has the same lifetime as the original slice, and so the /// iterator can continue to be used while this exists. @@ -702,7 +702,7 @@ impl<'a> DoubleEndedIterator for CharIndices<'a> { impl FusedIterator for CharIndices<'_> {} impl<'a> CharIndices<'a> { - /// View the underlying data as a subslice of the original data. + /// Views the underlying data as a subslice of the original data. /// /// This has the same lifetime as the original slice, and so the /// iterator can continue to be used while this exists. @@ -1579,9 +1579,9 @@ mod traits { /// Implements ordering of strings. /// - /// Strings are ordered lexicographically by their byte values. This orders Unicode code - /// points based on their positions in the code charts. This is not necessarily the same as - /// "alphabetical" order, which varies by language and locale. Sorting strings according to + /// Strings are ordered lexicographically by their byte values. This orders Unicode code + /// points based on their positions in the code charts. This is not necessarily the same as + /// "alphabetical" order, which varies by language and locale. Sorting strings according to /// culturally-accepted standards requires locale-specific data that is outside the scope of /// the `str` type. #[stable(feature = "rust1", since = "1.0.0")] @@ -1607,9 +1607,9 @@ mod traits { /// Implements comparison operations on strings. /// - /// Strings are compared lexicographically by their byte values. This compares Unicode code - /// points based on their positions in the code charts. This is not necessarily the same as - /// "alphabetical" order, which varies by language and locale. Comparing strings according to + /// Strings are compared lexicographically by their byte values. This compares Unicode code + /// points based on their positions in the code charts. This is not necessarily the same as + /// "alphabetical" order, which varies by language and locale. Comparing strings according to /// culturally-accepted standards requires locale-specific data that is outside the scope of /// the `str` type. #[stable(feature = "rust1", since = "1.0.0")] @@ -2643,7 +2643,7 @@ impl str { Bytes(self.as_bytes().iter().cloned()) } - /// Split a string slice by whitespace. + /// Splits a string slice by whitespace. /// /// The iterator returned will return string slices that are sub-slices of /// the original string slice, separated by any amount of whitespace. @@ -2686,7 +2686,7 @@ impl str { SplitWhitespace { inner: self.split(IsWhitespace).filter(IsNotEmpty) } } - /// Split a string slice by ASCII whitespace. + /// Splits a string slice by ASCII whitespace. /// /// The iterator returned will return string slices that are sub-slices of /// the original string slice, separated by any amount of ASCII whitespace. diff --git a/src/libcore/time.rs b/src/libcore/time.rs index a751965dffa..ee583c829dd 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -43,7 +43,7 @@ pub const NANOSECOND: Duration = Duration::from_nanos(1); /// timeouts. /// /// Each `Duration` is composed of a whole number of seconds and a fractional part -/// represented in nanoseconds. If the underlying system does not support +/// represented in nanoseconds. If the underlying system does not support /// nanosecond-level precision, APIs binding a system timeout will typically round up /// the number of nanoseconds. /// diff --git a/src/libproc_macro/bridge/scoped_cell.rs b/src/libproc_macro/bridge/scoped_cell.rs index b1ab27c153e..6f7965095b6 100644 --- a/src/libproc_macro/bridge/scoped_cell.rs +++ b/src/libproc_macro/bridge/scoped_cell.rs @@ -38,7 +38,7 @@ impl ScopedCell { ScopedCell(Cell::new(value)) } - /// Set the value in `self` to `replacement` while + /// Sets the value in `self` to `replacement` while /// running `f`, which gets the old value, mutably. /// The old value will be restored after `f` exits, even /// by panic, including modifications made to it by `f`. @@ -73,7 +73,7 @@ impl ScopedCell { f(RefMutL(put_back_on_drop.value.as_mut().unwrap())) } - /// Set the value in `self` to `value` while running `f`. + /// Sets the value in `self` to `value` while running `f`. pub fn set<'a, R>(&self, value: >::Out, f: impl FnOnce() -> R) -> R { self.replace(value, |_| f()) } diff --git a/src/libproc_macro/diagnostic.rs b/src/libproc_macro/diagnostic.rs index 7a0c9419f62..65eebb5ec37 100644 --- a/src/libproc_macro/diagnostic.rs +++ b/src/libproc_macro/diagnostic.rs @@ -56,7 +56,7 @@ pub struct Diagnostic { macro_rules! diagnostic_child_methods { ($spanned:ident, $regular:ident, $level:expr) => ( - /// Add a new child diagnostic message to `self` with the level + /// Adds a new child diagnostic message to `self` with the level /// identified by this method's name with the given `spans` and /// `message`. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] @@ -67,7 +67,7 @@ macro_rules! diagnostic_child_methods { self } - /// Add a new child diagnostic message to `self` with the level + /// Adds a new child diagnostic message to `self` with the level /// identified by this method's name with the given `message`. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub fn $regular>(mut self, message: T) -> Diagnostic { @@ -93,7 +93,7 @@ impl<'a> Iterator for Children<'a> { #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] impl Diagnostic { - /// Create a new diagnostic with the given `level` and `message`. + /// Creates a new diagnostic with the given `level` and `message`. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub fn new>(level: Level, message: T) -> Diagnostic { Diagnostic { @@ -104,7 +104,7 @@ impl Diagnostic { } } - /// Create a new diagnostic with the given `level` and `message` pointing to + /// Creates a new diagnostic with the given `level` and `message` pointing to /// the given set of `spans`. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub fn spanned(spans: S, level: Level, message: T) -> Diagnostic diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 2cdc5a48a53..bd0a7ec0e1a 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -88,7 +88,7 @@ impl TokenStream { /// or characters not existing in the language. /// All tokens in the parsed stream get `Span::call_site()` spans. /// -/// NOTE: Some errors may cause panics instead of returning `LexError`. We reserve the right to +/// NOTE: some errors may cause panics instead of returning `LexError`. We reserve the right to /// change these errors into `LexError`s later. #[stable(feature = "proc_macro_lib", since = "1.15.0")] impl FromStr for TokenStream { @@ -244,7 +244,7 @@ impl !Sync for Span {} macro_rules! diagnostic_method { ($name:ident, $level:expr) => ( - /// Create a new `Diagnostic` with the given `message` at the span + /// Creates a new `Diagnostic` with the given `message` at the span /// `self`. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub fn $name>(self, message: T) -> Diagnostic { @@ -290,19 +290,19 @@ impl Span { Span(self.0.source()) } - /// Get the starting line/column in the source file for this span. + /// Gets the starting line/column in the source file for this span. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn start(&self) -> LineColumn { self.0.start() } - /// Get the ending line/column in the source file for this span. + /// Gets the ending line/column in the source file for this span. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn end(&self) -> LineColumn { self.0.end() } - /// Create a new span encompassing `self` and `other`. + /// Creates a new span encompassing `self` and `other`. /// /// Returns `None` if `self` and `other` are from different files. #[unstable(feature = "proc_macro_span", issue = "54725")] @@ -368,7 +368,7 @@ impl !Sync for LineColumn {} pub struct SourceFile(bridge::client::SourceFile); impl SourceFile { - /// Get the path to this source file. + /// Gets the path to this source file. /// /// ### Note /// If the code span associated with this `SourceFile` was generated by an external macro, this diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 2e0383ccef5..7fa7b807519 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -250,7 +250,7 @@ impl f64 { /// Calculates the least nonnegative remainder of `self (mod rhs)`. /// /// In particular, the return value `r` satisfies `0.0 <= r < rhs.abs()` in - /// most cases. However, due to a floating point round-off error it can + /// most cases. However, due to a floating point round-off error it can /// result in `r == rhs.abs()`, violating the mathematical definition, if /// `self` is much smaller than `rhs.abs()` in magnitude and `self < 0.0`. /// This result is not an element of the function's codomain, but it is the diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index f8176892513..c05c19ae566 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -24,7 +24,7 @@ use sys_common::{AsInner, IntoInner, FromInner}; /// /// `OsString` and [`OsStr`] bridge this gap by simultaneously representing Rust /// and platform-native string values, and in particular allowing a Rust string -/// to be converted into an "OS" string with no cost if possible. A consequence +/// to be converted into an "OS" string with no cost if possible. A consequence /// of this is that `OsString` instances are *not* `NUL` terminated; in order /// to pass to e.g., Unix system call, you should create a [`CStr`]. /// diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 3538816c112..2837aade82c 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -222,7 +222,7 @@ fn initial_buffer_size(file: &File) -> usize { /// Read the entire contents of a file into a bytes vector. /// /// This is a convenience function for using [`File::open`] and [`read_to_end`] -/// with fewer imports and without an intermediate variable. It pre-allocates a +/// with fewer imports and without an intermediate variable. It pre-allocates a /// buffer based on the file size when available, so it is generally faster than /// reading into a vector created with `Vec::new()`. /// @@ -263,7 +263,7 @@ pub fn read>(path: P) -> io::Result> { /// Read the entire contents of a file into a string. /// /// This is a convenience function for using [`File::open`] and [`read_to_string`] -/// with fewer imports and without an intermediate variable. It pre-allocates a +/// with fewer imports and without an intermediate variable. It pre-allocates a /// buffer based on the file size when available, so it is generally faster than /// reading into a string created with `String::new()`. /// diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 056aa7c0c42..0615cd59db4 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -16,9 +16,9 @@ use memchr; /// the underlying [`Read`] and maintains an in-memory buffer of the results. /// /// `BufReader` can improve the speed of programs that make *small* and -/// *repeated* read calls to the same file or network socket. It does not +/// *repeated* read calls to the same file or network socket. It does not /// help when reading very large amounts at once, or reading just one or a few -/// times. It also provides no advantage when reading from a source that is +/// times. It also provides no advantage when reading from a source that is /// already in memory, like a `Vec`. /// /// [`Read`]: ../../std/io/trait.Read.html @@ -331,9 +331,9 @@ impl Seek for BufReader { /// writer in large, infrequent batches. /// /// `BufWriter` can improve the speed of programs that make *small* and -/// *repeated* write calls to the same file or network socket. It does not +/// *repeated* write calls to the same file or network socket. It does not /// help when writing very large amounts at once, or writing just one or a few -/// times. It also provides no advantage when writing to a destination that is +/// times. It also provides no advantage when writing to a destination that is /// in memory, like a `Vec`. /// /// When the `BufWriter` is dropped, the contents of its buffer will be written diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index a7ecee2d822..d5c2aaea543 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -627,7 +627,7 @@ mod loop_keyword { } /// directly accessed and modified. /// /// Tuple structs are similar to regular structs, but its fields have no names. They are used like -/// tuples, with deconstruction possible via `let TupleStruct(x, y) = foo;` syntax. For accessing +/// tuples, with deconstruction possible via `let TupleStruct(x, y) = foo;` syntax. For accessing /// individual variables, the same syntax is used as with regular tuples, namely `foo.0`, `foo.1`, /// etc, starting at zero. /// diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index b87257188df..2ed3377838b 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -11,8 +11,8 @@ /// an unrecoverable problem. /// /// This macro is the perfect way to assert conditions in example code and in -/// tests. `panic!` is closely tied with the `unwrap` method of both [`Option`] -/// and [`Result`][runwrap] enums. Both implementations call `panic!` when they are set +/// tests. `panic!` is closely tied with the `unwrap` method of both [`Option`] +/// and [`Result`][runwrap] enums. Both implementations call `panic!` when they are set /// to None or Err variants. /// /// This macro is used to inject panic into a Rust thread, causing the thread to @@ -21,7 +21,7 @@ /// is transmitted. /// /// [`Result`] enum is often a better solution for recovering from errors than -/// using the `panic!` macro. This macro should be used to avoid proceeding using +/// using the `panic!` macro. This macro should be used to avoid proceeding using /// incorrect values, such as from external sources. Detailed information about /// error handling is found in the [book]. /// @@ -79,7 +79,7 @@ macro_rules! panic { /// necessary to use [`io::stdout().flush()`][flush] to ensure the output is emitted /// immediately. /// -/// Use `print!` only for the primary output of your program. Use +/// Use `print!` only for the primary output of your program. Use /// [`eprint!`] instead to print error and progress messages. /// /// [`println!`]: ../std/macro.println.html @@ -124,7 +124,7 @@ macro_rules! print { /// Use the [`format!`] syntax to write data to the standard output. /// See [`std::fmt`] for more information. /// -/// Use `println!` only for the primary output of your program. Use +/// Use `println!` only for the primary output of your program. Use /// [`eprintln!`] instead to print error and progress messages. /// /// [`format!`]: ../std/macro.format.html @@ -154,10 +154,10 @@ macro_rules! println { /// Macro for printing to the standard error. /// /// Equivalent to the [`print!`] macro, except that output goes to -/// [`io::stderr`] instead of `io::stdout`. See [`print!`] for +/// [`io::stderr`] instead of `io::stdout`. See [`print!`] for /// example usage. /// -/// Use `eprint!` only for error and progress messages. Use `print!` +/// Use `eprint!` only for error and progress messages. Use `print!` /// instead for the primary output of your program. /// /// [`io::stderr`]: ../std/io/struct.Stderr.html @@ -182,10 +182,10 @@ macro_rules! eprint { /// Macro for printing to the standard error, with a newline. /// /// Equivalent to the [`println!`] macro, except that output goes to -/// [`io::stderr`] instead of `io::stdout`. See [`println!`] for +/// [`io::stderr`] instead of `io::stdout`. See [`println!`] for /// example usage. /// -/// Use `eprintln!` only for error and progress messages. Use `println!` +/// Use `eprintln!` only for error and progress messages. Use `println!` /// instead for the primary output of your program. /// /// [`io::stderr`]: ../std/io/struct.Stderr.html @@ -462,16 +462,16 @@ mod builtin { /// The core macro for formatted string creation & output. /// /// This macro functions by taking a formatting string literal containing - /// `{}` for each additional argument passed. `format_args!` prepares the + /// `{}` for each additional argument passed. `format_args!` prepares the /// additional parameters to ensure the output can be interpreted as a string - /// and canonicalizes the arguments into a single type. Any value that implements + /// and canonicalizes the arguments into a single type. Any value that implements /// the [`Display`] trait can be passed to `format_args!`, as can any /// [`Debug`] implementation be passed to a `{:?}` within the formatting string. /// /// This macro produces a value of type [`fmt::Arguments`]. This value can be /// passed to the macros within [`std::fmt`] for performing useful redirection. /// All other formatting macros ([`format!`], [`write!`], [`println!`], etc) are - /// proxied through this one. `format_args!`, unlike its derived macros, avoids + /// proxied through this one. `format_args!`, unlike its derived macros, avoids /// heap allocations. /// /// You can use the [`fmt::Arguments`] value that `format_args!` returns @@ -554,7 +554,7 @@ mod builtin { /// If the named environment variable is present at compile time, this will /// expand into an expression of type `Option<&'static str>` whose value is /// `Some` of the value of the environment variable. If the environment - /// variable is not present, then this will expand to `None`. See + /// variable is not present, then this will expand to `None`. See /// [`Option`][option] for more information on this type. /// /// A compile time error is never emitted when using this macro regardless @@ -904,7 +904,7 @@ mod builtin { /// # Custom Messages /// /// This macro has a second form, where a custom panic message can - /// be provided with or without arguments for formatting. See [`std::fmt`] + /// be provided with or without arguments for formatting. See [`std::fmt`] /// for syntax for this form. /// /// [`panic!`]: macro.panic.html diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index 8ace1127658..91167debff3 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -671,7 +671,7 @@ impl hash::Hash for SocketAddrV6 { /// [`SocketAddr`] values. /// /// This trait is used for generic address resolution when constructing network -/// objects. By default it is implemented for the following types: +/// objects. By default it is implemented for the following types: /// /// * [`SocketAddr`]: [`to_socket_addrs`] is the identity function. /// diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index c2751508ce0..b0c0a8949db 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -1062,7 +1062,7 @@ mod prim_ref { } /// On top of that, function pointers can vary based on what ABI they use. This is achieved by /// adding the `extern` keyword to the type name, followed by the ABI in question. For example, /// `fn()` is different from `extern "C" fn()`, which itself is different from `extern "stdcall" -/// fn()`, and so on for the various ABIs that Rust supports. Non-`extern` functions have an ABI +/// fn()`, and so on for the various ABIs that Rust supports. Non-`extern` functions have an ABI /// of `"Rust"`, and `extern` functions without an explicit ABI have an ABI of `"C"`. For more /// information, see [the nomicon's section on foreign calling conventions][nomicon-abi]. /// diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 76887379106..3b147e059a0 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -343,13 +343,13 @@ impl Condvar { /// /// Note that the best effort is made to ensure that the time waited is /// measured with a monotonic clock, and not affected by the changes made to - /// the system time. This function is susceptible to spurious wakeups. + /// the system time. This function is susceptible to spurious wakeups. /// Condition variables normally have a boolean predicate associated with /// them, and the predicate must always be checked each time this function - /// returns to protect against spurious wakeups. Additionally, it is + /// returns to protect against spurious wakeups. Additionally, it is /// typically desirable for the time-out to not exceed some duration in /// spite of spurious wakes, thus the sleep-duration is decremented by the - /// amount slept. Alternatively, use the `wait_timeout_until` method + /// amount slept. Alternatively, use the `wait_timeout_until` method /// to wait until a condition is met with a total time-out regardless /// of spurious wakes. /// @@ -413,7 +413,7 @@ impl Condvar { } /// Waits on this condition variable for a notification, timing out after a - /// specified duration. Spurious wakes will not cause this function to + /// specified duration. Spurious wakes will not cause this function to /// return. /// /// The semantics of this function are equivalent to [`wait_until`] except diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 446c164965d..d1cd76778f4 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -789,7 +789,7 @@ impl Sender { /// where the corresponding receiver has already been deallocated. Note /// that a return value of [`Err`] means that the data will never be /// received, but a return value of [`Ok`] does *not* mean that the data - /// will be received. It is possible for the corresponding receiver to + /// will be received. It is possible for the corresponding receiver to /// hang up immediately after this function returns [`Ok`]. /// /// [`Err`]: ../../../std/result/enum.Result.html#variant.Err diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 8f41680a818..472df01fee3 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -72,11 +72,11 @@ struct SelectInner { impl !marker::Send for Select {} /// A handle to a receiver which is currently a member of a `Select` set of -/// receivers. This handle is used to keep the receiver in the set as well as +/// receivers. This handle is used to keep the receiver in the set as well as /// interact with the underlying receiver. pub struct Handle<'rx, T:Send+'rx> { /// The ID of this handle, used to compare against the return value of - /// `Select::wait()` + /// `Select::wait()`. id: usize, selector: *mut SelectInner, next: *mut Handle<'static, ()>, diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 7fbe0b8c199..2b3bcb97d59 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -314,7 +314,7 @@ impl RwLock { /// Determines whether the lock is poisoned. /// /// If another thread is active, the lock can still become poisoned at any - /// time. You should not trust a `false` value for program correctness + /// time. You should not trust a `false` value for program correctness /// without additional synchronization. /// /// # Examples diff --git a/src/libstd/sys/redox/ext/fs.rs b/src/libstd/sys/redox/ext/fs.rs index 04edfd6851d..76fea656d13 100644 --- a/src/libstd/sys/redox/ext/fs.rs +++ b/src/libstd/sys/redox/ext/fs.rs @@ -287,9 +287,9 @@ impl FileTypeExt for fs::FileType { /// # Note /// /// On Windows, you must specify whether a symbolic link points to a file -/// or directory. Use `os::windows::fs::symlink_file` to create a +/// or directory. Use `os::windows::fs::symlink_file` to create a /// symbolic link to a file, or `os::windows::fs::symlink_dir` to create a -/// symbolic link to a directory. Additionally, the process must have +/// symbolic link to a directory. Additionally, the process must have /// `SeCreateSymbolicLinkPrivilege` in order to be able to create a /// symbolic link. /// diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs index e962d09e274..afeb756806f 100644 --- a/src/libstd/sys/unix/ext/fs.rs +++ b/src/libstd/sys/unix/ext/fs.rs @@ -805,9 +805,9 @@ impl DirEntryExt for fs::DirEntry { /// # Note /// /// On Windows, you must specify whether a symbolic link points to a file -/// or directory. Use `os::windows::fs::symlink_file` to create a +/// or directory. Use `os::windows::fs::symlink_file` to create a /// symbolic link to a file, or `os::windows::fs::symlink_dir` to create a -/// symbolic link to a directory. Additionally, the process must have +/// symbolic link to a directory. Additionally, the process must have /// `SeCreateSymbolicLinkPrivilege` in order to be able to create a /// symbolic link. /// diff --git a/src/libstd/sys/windows/ext/ffi.rs b/src/libstd/sys/windows/ext/ffi.rs index eb278919307..6508c0cf447 100644 --- a/src/libstd/sys/windows/ext/ffi.rs +++ b/src/libstd/sys/windows/ext/ffi.rs @@ -3,19 +3,19 @@ //! # Overview //! //! For historical reasons, the Windows API uses a form of potentially -//! ill-formed UTF-16 encoding for strings. Specifically, the 16-bit +//! ill-formed UTF-16 encoding for strings. Specifically, the 16-bit //! code units in Windows strings may contain [isolated surrogate code -//! points which are not paired together][ill-formed-utf-16]. The +//! points which are not paired together][ill-formed-utf-16]. The //! Unicode standard requires that surrogate code points (those in the //! range U+D800 to U+DFFF) always be *paired*, because in the UTF-16 //! encoding a *surrogate code unit pair* is used to encode a single -//! character. For compatibility with code that does not enforce +//! character. For compatibility with code that does not enforce //! these pairings, Windows does not enforce them, either. //! //! While it is not always possible to convert such a string losslessly into //! a valid UTF-16 string (or even UTF-8), it is often desirable to be //! able to round-trip such a string from and to Windows APIs -//! losslessly. For example, some Rust code may be "bridging" some +//! losslessly. For example, some Rust code may be "bridging" some //! Windows APIs together, just passing `WCHAR` strings among those //! APIs without ever really looking into the strings. //! @@ -28,16 +28,16 @@ //! # `OsStringExt` and `OsStrExt` //! //! [`OsString`] is the Rust wrapper for owned strings in the -//! preferred representation of the operating system. On Windows, +//! preferred representation of the operating system. On Windows, //! this struct gets augmented with an implementation of the -//! [`OsStringExt`] trait, which has a [`from_wide`] method. This +//! [`OsStringExt`] trait, which has a [`from_wide`] method. This //! lets you create an [`OsString`] from a `&[u16]` slice; presumably //! you get such a slice out of a `WCHAR` Windows API. //! //! Similarly, [`OsStr`] is the Rust wrapper for borrowed strings from -//! preferred representation of the operating system. On Windows, the +//! preferred representation of the operating system. On Windows, the //! [`OsStrExt`] trait provides the [`encode_wide`] method, which -//! outputs an [`EncodeWide`] iterator. You can [`collect`] this +//! outputs an [`EncodeWide`] iterator. You can [`collect`] this //! iterator, for example, to obtain a `Vec`; you can later get a //! pointer to this vector's contents and feed it to Windows APIs. //! diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index eb8e0c1c8ac..438ea3aa3f6 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -841,7 +841,7 @@ const NOTIFIED: usize = 2; /// let flag2 = Arc::clone(&flag); /// /// let parked_thread = thread::spawn(move || { -/// // We want to wait until the flag is set. We *could* just spin, but using +/// // We want to wait until the flag is set. We *could* just spin, but using /// // park/unpark is more efficient. /// while !flag2.load(Ordering::Acquire) { /// println!("Parking thread"); diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 23924559fcc..c258e3f1a55 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -33,7 +33,7 @@ pub use core::time::{SECOND, MILLISECOND, MICROSECOND, NANOSECOND}; /// instant when created, and are often useful for tasks such as measuring /// benchmarks or timing how long an operation takes. /// -/// Note, however, that instants are not guaranteed to be **steady**. In other +/// Note, however, that instants are not guaranteed to be **steady**. In other /// words, each tick of the underlying clock may not be the same length (e.g. /// some seconds may be longer than others). An instant may jump forwards or /// experience time dilation (slow down or speed up), but it will never go diff --git a/src/test/incremental/change_add_field/struct_point.rs b/src/test/incremental/change_add_field/struct_point.rs index 6006831e482..182e6cb45be 100644 --- a/src/test/incremental/change_add_field/struct_point.rs +++ b/src/test/incremental/change_add_field/struct_point.rs @@ -60,7 +60,7 @@ pub mod point { } } -/// A fn that has the changed type in its signature; must currently be +/// A function that has the changed type in its signature; must currently be /// rebuilt. /// /// You could imagine that, in the future, if the change were @@ -76,7 +76,7 @@ pub mod fn_with_type_in_sig { } } -/// Call a fn that has the changed type in its signature; this +/// Call a function that has the changed type in its signature; this /// currently must also be rebuilt. /// /// You could imagine that, in the future, if the change were @@ -92,7 +92,7 @@ pub mod call_fn_with_type_in_sig { } } -/// A fn that uses the changed type, but only in its body, not its +/// A function that uses the changed type, but only in its body, not its /// signature. /// /// You could imagine that, in the future, if the change were @@ -108,10 +108,10 @@ pub mod fn_with_type_in_body { } } -/// A fn X that calls a fn Y, where Y uses the changed type in its +/// A function `X` that calls a function `Y`, where `Y` uses the changed type in its /// body. In this case, the effects of the change should be contained -/// to Y; X should not have to be rebuilt, nor should it need to be -/// typechecked again. +/// to `Y`; `X` should not have to be rebuilt, nor should it need to be +/// type-checked again. pub mod call_fn_with_type_in_body { use fn_with_type_in_body; @@ -121,7 +121,7 @@ pub mod call_fn_with_type_in_body { } } -/// A fn item that makes an instance of `Point` but does not invoke methods +/// A function item that makes an instance of `Point` but does not invoke methods. pub mod fn_make_struct { use point::Point; @@ -131,7 +131,7 @@ pub mod fn_make_struct { } } -/// A fn item that reads fields from `Point` but does not invoke methods +/// A function item that reads fields from `Point` but does not invoke methods. pub mod fn_read_field { use point::Point; @@ -141,7 +141,7 @@ pub mod fn_read_field { } } -/// A fn item that writes to a field of `Point` but does not invoke methods +/// A function item that writes to a field of `Point` but does not invoke methods. pub mod fn_write_field { use point::Point; diff --git a/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs b/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs index ee4ecde44f2..956bc5ad862 100644 --- a/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs @@ -59,8 +59,8 @@ fn make_x() -> P { expr(ExprKind::Path(None, path)) } -/// Iterate over exprs of depth up to `depth`. The goal is to explore all "interesting" -/// combinations of expression nesting. For example, we explore combinations using `if`, but not +/// Iterate over exprs of depth up to `depth`. The goal is to explore all "interesting" +/// combinations of expression nesting. For example, we explore combinations using `if`, but not /// `while` or `match`, since those should print and parse in much the same way as `if`. fn iter_exprs(depth: usize, f: &mut FnMut(P)) { if depth == 0 { diff --git a/src/test/run-pass/auxiliary/svh-b.rs b/src/test/run-pass/auxiliary/svh-b.rs index 03869aeb371..57029f70888 100644 --- a/src/test/run-pass/auxiliary/svh-b.rs +++ b/src/test/run-pass/auxiliary/svh-b.rs @@ -1,7 +1,7 @@ -//! This is a client of the `a` crate defined in "svn-a-base.rs". The -//! rpass and cfail tests (such as "run-pass/svh-add-comment.rs") use +//! This is a client of the `a` crate defined in `svn-a-base.rs`. The +//! rpass and cfail tests (such as `run-pass/svh-add-comment.rs`) use //! it by swapping in a different object code library crate built from -//! some variant of "svn-a-base.rs", and then we are checking if the +//! some variant of `svn-a-base.rs`, and then we are checking if the //! compiler properly ignores or accepts the change, based on whether //! the change could affect the downstream crate content or not //! (#14132). diff --git a/src/test/run-pass/issues/issue-7012.rs b/src/test/run-pass/issues/issue-7012.rs index a1c4bf83beb..90eba170695 100644 --- a/src/test/run-pass/issues/issue-7012.rs +++ b/src/test/run-pass/issues/issue-7012.rs @@ -5,7 +5,7 @@ /* # Comparison of static arrays -The expected behaviour would be that test==test1, therefore 'true' +The expected behaviour would be that `test == test1`, therefore 'true' would be printed, however the below prints false. */ diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index 52b931f638c..e3ed350f29a 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -163,7 +163,7 @@ mod test_foreign_items { } -// FIXME #623 - these aren't supported yet +// FIXME(#623): - these aren't supported yet /*mod test_literals { #![str = "s"] #![char = 'c'] diff --git a/src/test/run-pass/monomorphize-abi-alignment.rs b/src/test/run-pass/monomorphize-abi-alignment.rs index b55974e6421..a26f324f7dc 100644 --- a/src/test/run-pass/monomorphize-abi-alignment.rs +++ b/src/test/run-pass/monomorphize-abi-alignment.rs @@ -2,7 +2,7 @@ /*! * On x86_64-linux-gnu and possibly other platforms, structs get 8-byte "preferred" alignment, * but their "ABI" alignment (i.e., what actually matters for data layout) is the largest alignment - * of any field. (Also, u64 has 8-byte ABI alignment; this is not always true). + * of any field. (Also, `u64` has 8-byte ABI alignment; this is not always true). * * On such platforms, if monomorphize uses the "preferred" alignment, then it will unify * `A` and `B`, even though `S` and `S` have the field `t` at different offsets, diff --git a/src/test/run-pass/numbers-arithmetic/num-wrapping.rs b/src/test/run-pass/numbers-arithmetic/num-wrapping.rs index d7ab51f8649..9a01549ecd2 100644 --- a/src/test/run-pass/numbers-arithmetic/num-wrapping.rs +++ b/src/test/run-pass/numbers-arithmetic/num-wrapping.rs @@ -175,7 +175,7 @@ fn test_op_assigns() { assert_eq!(black_box(tmp), Wrapping($ans)); } - // FIXME(30524): Uncomment this test + // FIXME(30524): uncomment this test /* { let mut tmp = Wrapping($initial); diff --git a/src/test/rustdoc/auxiliary/enum_primitive.rs b/src/test/rustdoc/auxiliary/enum_primitive.rs index eff47e8d8dd..ed1da253a97 100644 --- a/src/test/rustdoc/auxiliary/enum_primitive.rs +++ b/src/test/rustdoc/auxiliary/enum_primitive.rs @@ -22,7 +22,7 @@ //! This crate exports a macro `enum_from_primitive!` that wraps an //! `enum` declaration and automatically adds an implementation of //! `num::FromPrimitive` (reexported here), to allow conversion from -//! primitive integers to the enum. It therefore provides an +//! primitive integers to the enum. It therefore provides an //! alternative to the built-in `#[derive(FromPrimitive)]`, which //! requires the unstable `std::num::FromPrimitive` and is disabled in //! Rust 1.0. diff --git a/src/test/rustdoc/issue-27862.rs b/src/test/rustdoc/issue-27862.rs index ce3978e7e9a..77522f1be23 100644 --- a/src/test/rustdoc/issue-27862.rs +++ b/src/test/rustdoc/issue-27862.rs @@ -1,4 +1,4 @@ -/// Test | Table +/// Tests | Table /// ------|------------- /// t = b | id = \|x\| x pub struct Foo; // @has issue_27862/struct.Foo.html //td 'id = |x| x' diff --git a/src/test/ui/associated-types/associated-types-coherence-failure.rs b/src/test/ui/associated-types/associated-types-coherence-failure.rs index fe1201ea06f..c33f2ac96ba 100644 --- a/src/test/ui/associated-types/associated-types-coherence-failure.rs +++ b/src/test/ui/associated-types/associated-types-coherence-failure.rs @@ -41,7 +41,7 @@ impl ToOwned for u8 { pub trait ToOwned { type Owned; - /// Create owned data from borrowed data, usually by copying. + /// Creates owned data from borrowed data, usually by copying. fn to_owned(&self) -> Self::Owned; } diff --git a/src/test/ui/issues/issue-20797.rs b/src/test/ui/issues/issue-20797.rs index ce8564ffe43..e504b4705da 100644 --- a/src/test/ui/issues/issue-20797.rs +++ b/src/test/ui/issues/issue-20797.rs @@ -17,7 +17,7 @@ impl PathExtensions for PathBuf {} /// A strategy for acquiring more subpaths to walk. pub trait Strategy { type P: PathExtensions; - /// Get additional subpaths from a given path. + /// Gets additional subpaths from a given path. fn get_more(&self, item: &Self::P) -> io::Result>; /// Determine whether a path should be walked further. /// This is run against each item from `get_more()`. @@ -44,7 +44,7 @@ pub struct Subpaths { } impl Subpaths { - /// Create a directory walker with a root path and strategy. + /// Creates a directory walker with a root path and strategy. pub fn new(p: &S::P, strategy: S) -> io::Result> { let stack = strategy.get_more(p)?; Ok(Subpaths { stack: stack, strategy: strategy }) @@ -52,7 +52,7 @@ impl Subpaths { } impl Subpaths { - /// Create a directory walker with a root path and a default strategy. + /// Creates a directory walker with a root path and a default strategy. pub fn walk(p: &S::P) -> io::Result> { Subpaths::new(p, Default::default()) } diff --git a/src/test/ui/issues/issue-48636.fixed b/src/test/ui/issues/issue-48636.fixed index 39e6c98b1f5..7d76f9a99be 100644 --- a/src/test/ui/issues/issue-48636.fixed +++ b/src/test/ui/issues/issue-48636.fixed @@ -4,7 +4,7 @@ struct S { x: u8, - /// The id of the parent core + /// The ID of the parent core y: u8, } //~^^^ ERROR found a documentation comment that doesn't document anything diff --git a/src/test/ui/issues/issue-48636.rs b/src/test/ui/issues/issue-48636.rs index bcf57772b51..371c0ef6732 100644 --- a/src/test/ui/issues/issue-48636.rs +++ b/src/test/ui/issues/issue-48636.rs @@ -4,7 +4,7 @@ struct S { x: u8 - /// The id of the parent core + /// The ID of the parent core y: u8, } //~^^^ ERROR found a documentation comment that doesn't document anything diff --git a/src/test/ui/issues/issue-52126-assign-op-invariance.rs b/src/test/ui/issues/issue-52126-assign-op-invariance.rs index b974a8d4bda..c96cfdf3cd1 100644 --- a/src/test/ui/issues/issue-52126-assign-op-invariance.rs +++ b/src/test/ui/issues/issue-52126-assign-op-invariance.rs @@ -27,7 +27,7 @@ impl<'l> AddAssign for Counter<'l> } } -/// often times crashes, if not prints invalid strings +/// Often crashes, if not prints invalid strings. pub fn panics() { let mut acc = Counter{map: HashMap::new()}; for line in vec!["123456789".to_string(), "12345678".to_string()] { diff --git a/src/test/ui/nll/user-annotations/issue-55241.rs b/src/test/ui/nll/user-annotations/issue-55241.rs index e5600803df8..d7686b9dc94 100644 --- a/src/test/ui/nll/user-annotations/issue-55241.rs +++ b/src/test/ui/nll/user-annotations/issue-55241.rs @@ -18,7 +18,7 @@ pub trait NodeCodec { } pub trait Trie> { - /// Return the root of the trie. + /// Returns the root of the trie. fn root(&self) -> &H::Out; /// Is the trie empty? diff --git a/src/test/ui/on-unimplemented/bad-annotation.rs b/src/test/ui/on-unimplemented/bad-annotation.rs index 6843c4bfa99..846db63024c 100644 --- a/src/test/ui/on-unimplemented/bad-annotation.rs +++ b/src/test/ui/on-unimplemented/bad-annotation.rs @@ -10,7 +10,7 @@ trait Foo #[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an iterator over elements of type `{A}`"] trait MyFromIterator { - /// Build a container with elements from an external iterator. + /// Builds a container with elements from an external iterator. fn my_from_iter>(iterator: T) -> Self; } diff --git a/src/test/ui/on-unimplemented/on-trait.rs b/src/test/ui/on-unimplemented/on-trait.rs index 22afda16f43..109cb5ba969 100644 --- a/src/test/ui/on-unimplemented/on-trait.rs +++ b/src/test/ui/on-unimplemented/on-trait.rs @@ -15,7 +15,7 @@ fn foobar>() -> T { #[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an iterator over elements of type `{A}`"] trait MyFromIterator { - /// Build a container with elements from an external iterator. + /// Builds a container with elements from an external iterator. fn my_from_iter>(iterator: T) -> Self; } diff --git a/src/test/ui/svh/auxiliary/svh-b.rs b/src/test/ui/svh/auxiliary/svh-b.rs index 03869aeb371..57029f70888 100644 --- a/src/test/ui/svh/auxiliary/svh-b.rs +++ b/src/test/ui/svh/auxiliary/svh-b.rs @@ -1,7 +1,7 @@ -//! This is a client of the `a` crate defined in "svn-a-base.rs". The -//! rpass and cfail tests (such as "run-pass/svh-add-comment.rs") use +//! This is a client of the `a` crate defined in `svn-a-base.rs`. The +//! rpass and cfail tests (such as `run-pass/svh-add-comment.rs`) use //! it by swapping in a different object code library crate built from -//! some variant of "svn-a-base.rs", and then we are checking if the +//! some variant of `svn-a-base.rs`, and then we are checking if the //! compiler properly ignores or accepts the change, based on whether //! the change could affect the downstream crate content or not //! (#14132). -- cgit 1.4.1-3-g733a5 From 99ed06eb8864e704c4a1871ccda4648273bee4ef Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Sat, 9 Feb 2019 22:16:58 +0000 Subject: libs: doc comments --- src/liballoc/borrow.rs | 4 +- src/liballoc/collections/binary_heap.rs | 2 +- src/liballoc/collections/btree/map.rs | 2 +- src/liballoc/collections/btree/node.rs | 4 +- src/liballoc/collections/btree/set.rs | 4 +- src/liballoc/collections/vec_deque.rs | 8 +-- src/liballoc/macros.rs | 2 +- src/liballoc/raw_vec.rs | 4 +- src/liballoc/rc.rs | 10 +-- src/liballoc/slice.rs | 6 +- src/liballoc/string.rs | 6 +- src/liballoc/sync.rs | 8 +-- src/liballoc/tests/heap.rs | 2 +- src/liballoc/vec.rs | 8 +-- src/libcore/cell.rs | 8 +-- src/libcore/char/decode.rs | 2 +- src/libcore/char/methods.rs | 20 +++--- src/libcore/default.rs | 2 +- src/libcore/ffi.rs | 4 +- src/libcore/fmt/mod.rs | 4 +- src/libcore/future/future.rs | 2 +- src/libcore/hash/sip.rs | 6 +- src/libcore/hint.rs | 2 +- src/libcore/intrinsics.rs | 32 ++++----- src/libcore/iter/range.rs | 10 +-- src/libcore/iter/traits/exact_size.rs | 2 +- src/libcore/iter/traits/iterator.rs | 4 +- src/libcore/macros.rs | 4 +- src/libcore/mem.rs | 44 ++++++------ src/libcore/num/dec2flt/algorithm.rs | 2 +- src/libcore/num/dec2flt/mod.rs | 4 +- src/libcore/num/dec2flt/num.rs | 6 +- src/libcore/num/dec2flt/parse.rs | 2 +- src/libcore/num/dec2flt/rawfp.rs | 4 +- src/libcore/num/f32.rs | 10 +-- src/libcore/num/f64.rs | 10 +-- src/libcore/num/mod.rs | 4 +- src/libcore/ops/arith.rs | 4 +- src/libcore/ops/range.rs | 4 +- src/libcore/option.rs | 6 +- src/libcore/pin.rs | 12 ++-- src/libcore/ptr.rs | 6 +- src/libcore/result.rs | 2 +- src/libcore/slice/memchr.rs | 2 +- src/libcore/slice/mod.rs | 8 +-- src/libcore/str/mod.rs | 10 +-- src/libcore/str/pattern.rs | 8 +-- src/libcore/task/poll.rs | 10 +-- src/libcore/task/wake.rs | 14 ++-- src/libcore/tests/iter.rs | 4 +- src/libcore/time.rs | 2 +- src/libstd/collections/hash/map.rs | 14 ++-- src/libstd/collections/hash/set.rs | 4 +- src/libstd/collections/hash/table.rs | 12 ++-- src/libstd/collections/mod.rs | 4 +- src/libstd/error.rs | 4 +- src/libstd/ffi/c_str.rs | 2 +- src/libstd/ffi/os_str.rs | 2 +- src/libstd/fs.rs | 26 +++---- src/libstd/io/mod.rs | 6 +- src/libstd/keyword_docs.rs | 4 +- src/libstd/lib.rs | 2 +- src/libstd/net/addr.rs | 2 +- src/libstd/net/ip.rs | 10 +-- src/libstd/net/tcp.rs | 8 +-- src/libstd/net/udp.rs | 12 ++-- src/libstd/path.rs | 6 +- src/libstd/primitive_docs.rs | 2 +- src/libstd/process.rs | 14 ++-- src/libstd/sync/barrier.rs | 2 +- src/libstd/sync/condvar.rs | 2 +- src/libstd/sync/mpsc/blocking.rs | 6 +- src/libstd/sync/mpsc/select.rs | 4 +- src/libstd/sync/mpsc/shared.rs | 2 +- src/libstd/sync/mutex.rs | 2 +- src/libstd/sync/once.rs | 6 +- src/libstd/sync/rwlock.rs | 2 +- src/libstd/sys/cloudabi/abi/cloudabi.rs | 16 ++--- src/libstd/sys/mod.rs | 2 +- src/libstd/sys/redox/ext/fs.rs | 2 +- src/libstd/sys/redox/ext/net.rs | 6 +- src/libstd/sys/redox/ext/process.rs | 4 +- src/libstd/sys/redox/mutex.rs | 2 +- src/libstd/sys/redox/process.rs | 2 +- src/libstd/sys/redox/syscall/call.rs | 104 ++++++++++++++-------------- src/libstd/sys/redox/syscall/flag.rs | 16 ++--- src/libstd/sys/sgx/abi/thread.rs | 2 +- src/libstd/sys/sgx/abi/tls.rs | 2 +- src/libstd/sys/sgx/abi/usercalls/alloc.rs | 51 ++++++++------ src/libstd/sys/sgx/abi/usercalls/raw.rs | 6 +- src/libstd/sys/sgx/waitqueue.rs | 4 +- src/libstd/sys/unix/ext/fs.rs | 8 +-- src/libstd/sys/unix/ext/net.rs | 8 +-- src/libstd/sys/unix/ext/process.rs | 4 +- src/libstd/sys/unix/process/process_unix.rs | 2 +- src/libstd/sys/windows/ext/fs.rs | 4 +- src/libstd/sys/windows/ext/io.rs | 6 +- src/libstd/sys/windows/os.rs | 2 +- src/libstd/sys/windows/pipe.rs | 2 +- src/libstd/sys_common/backtrace.rs | 4 +- src/libstd/sys_common/wtf8.rs | 10 +-- src/libtest/lib.rs | 2 +- 102 files changed, 394 insertions(+), 387 deletions(-) (limited to 'src/libstd') diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index 270f48e8083..40c71f12cd8 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -137,11 +137,11 @@ impl ToOwned for T /// ``` /// use std::borrow::{Cow, ToOwned}; /// -/// struct Items<'a, X: 'a> where [X]: ToOwned> { +/// struct Items<'a, X: 'a> where [X]: ToOwned> { /// values: Cow<'a, [X]>, /// } /// -/// impl<'a, X: Clone + 'a> Items<'a, X> where [X]: ToOwned> { +/// impl<'a, X: Clone + 'a> Items<'a, X> where [X]: ToOwned> { /// fn new(v: Cow<'a, [X]>) -> Self { /// Items { values: v } /// } diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index 6214e1ce245..3b94379b58f 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -863,7 +863,7 @@ struct Hole<'a, T: 'a> { } impl<'a, T> Hole<'a, T> { - /// Create a new Hole at index `pos`. + /// Create a new `Hole` at index `pos`. /// /// Unsafe because pos must be within the data slice. #[inline] diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index aaaa419dcb8..5ec5064b735 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -2368,7 +2368,7 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> { /// Gets a mutable reference to the value in the entry. /// - /// If you need a reference to the `OccupiedEntry` which may outlive the + /// If you need a reference to the `OccupiedEntry` that may outlive the /// destruction of the `Entry` value, see [`into_mut`]. /// /// [`into_mut`]: #method.into_mut diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index 481ee7cebc4..eb0667228d1 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -1295,7 +1295,7 @@ impl<'a, K, V> Handle, K, V, marker::Internal>, marker:: } } - /// Returns whether it is valid to call `.merge()`, i.e., whether there is enough room in + /// Returns `true` if it is valid to call `.merge()`, i.e., whether there is enough room in /// a node to hold the combination of the nodes to the left and right of this handle along /// with the key/value pair at this handle. pub fn can_merge(&self) -> bool { @@ -1573,7 +1573,7 @@ unsafe fn move_edges( impl Handle, HandleType> { - /// Check whether the underlying node is an `Internal` node or a `Leaf` node. + /// Checks whether the underlying node is an `Internal` node or a `Leaf` node. pub fn force(self) -> ForceResult< Handle, HandleType>, Handle, HandleType> diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index 78cd21dd411..870e3e47692 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -556,7 +556,7 @@ impl BTreeSet { Recover::replace(&mut self.map, value) } - /// Removes a value from the set. Returns `true` if the value was + /// Removes a value from the set. Returns whether the value was /// present in the set. /// /// The value may be any borrowed form of the set's value type, @@ -988,7 +988,7 @@ impl<'a, T> DoubleEndedIterator for Range<'a, T> { #[stable(feature = "fused", since = "1.26.0")] impl FusedIterator for Range<'_, T> {} -/// Compare `x` and `y`, but return `short` if x is None and `long` if y is None +/// Compares `x` and `y`, but return `short` if x is None and `long` if y is None fn cmp_opt(x: Option<&T>, y: Option<&T>, short: Ordering, long: Ordering) -> Ordering { match (x, y) { (None, _) => short, diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index a292bde3315..b6fdaa89992 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -124,7 +124,7 @@ impl VecDeque { ptr::write(self.ptr().add(off), value); } - /// Returns `true` if and only if the buffer is at full capacity. + /// Returns `true` if the buffer is at full capacity. #[inline] fn is_full(&self) -> bool { self.cap() - self.len() == 1 @@ -560,7 +560,7 @@ impl VecDeque { /// Does nothing if the capacity is already sufficient. /// /// Note that the allocator may give the collection more space than it - /// requests. Therefore capacity can not be relied upon to be precisely + /// requests. Therefore, capacity can not be relied upon to be precisely /// minimal. Prefer `reserve` if future insertions are expected. /// /// # Errors @@ -924,7 +924,7 @@ impl VecDeque { self.tail == self.head } - /// Create a draining iterator that removes the specified range in the + /// Creates a draining iterator that removes the specified range in the /// `VecDeque` and yields the removed items. /// /// Note 1: The element range is removed even if the iterator is not @@ -932,7 +932,7 @@ impl VecDeque { /// /// Note 2: It is unspecified how many elements are removed from the deque, /// if the `Drain` value is not dropped, but the borrow it holds expires - /// (eg. due to mem::forget). + /// (e.g., due to `mem::forget`). /// /// # Panics /// diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs index 4fe6d450add..aadc5d68ac1 100644 --- a/src/liballoc/macros.rs +++ b/src/liballoc/macros.rs @@ -67,7 +67,7 @@ macro_rules! vec { /// /// Additional parameters passed to `format!` replace the `{}`s within the /// formatting string in the order given unless named or positional parameters -/// are used, see [`std::fmt`][fmt] for more information. +/// are used; see [`std::fmt`][fmt] for more information. /// /// A common use for `format!` is concatenation and interpolation of strings. /// The same convention is used with [`print!`] and [`write!`] macros, diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index dcecf9bc76d..fe28fe5095c 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -335,7 +335,7 @@ impl RawVec { /// enough to want to do that it's easiest to just have a dedicated method. Slightly /// more efficient logic can be provided for this than the general case. /// - /// Returns true if the reallocation attempt has succeeded, or false otherwise. + /// Returns `true` if the reallocation attempt has succeeded. /// /// # Panics /// @@ -504,7 +504,7 @@ impl RawVec { /// the requested space. This is not really unsafe, but the unsafe /// code *you* write that relies on the behavior of this function may break. /// - /// Returns true if the reallocation attempt has succeeded, or false otherwise. + /// Returns `true` if the reallocation attempt has succeeded. /// /// # Panics /// diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index d78869270d5..12f75d84211 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -512,7 +512,7 @@ impl Rc { this.strong() } - /// Returns true if there are no other `Rc` or [`Weak`][weak] pointers to + /// Returns `true` if there are no other `Rc` or [`Weak`][weak] pointers to /// this inner value. /// /// [weak]: struct.Weak.html @@ -561,7 +561,7 @@ impl Rc { #[inline] #[stable(feature = "ptr_eq", since = "1.17.0")] - /// Returns true if the two `Rc`s point to the same value (not + /// Returns `true` if the two `Rc`s point to the same value (not /// just values that compare as equal). /// /// # Examples @@ -1334,8 +1334,8 @@ impl Weak { }) } - /// Return `None` when the pointer is dangling and there is no allocated `RcBox`, - /// i.e., this `Weak` was created by `Weak::new` + /// Returns `None` when the pointer is dangling and there is no allocated `RcBox` + /// (i.e., when this `Weak` was created by `Weak::new`). #[inline] fn inner(&self) -> Option<&RcBox> { if is_dangling(self.ptr) { @@ -1345,7 +1345,7 @@ impl Weak { } } - /// Returns true if the two `Weak`s point to the same value (not just values + /// Returns `true` if the two `Weak`s point to the same value (not just values /// that compare as equal). /// /// # Notes diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 479959deeb1..c4f4a80a017 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -205,10 +205,10 @@ impl [T] { /// /// The comparator function must define a total ordering for the elements in the slice. If /// the ordering is not total, the order of the elements is unspecified. An order is a - /// total order if it is (for all a, b and c): + /// total order if it is (for all `a`, `b` and `c`): /// - /// * total and antisymmetric: exactly one of a < b, a == b or a > b is true; and - /// * transitive, a < b and b < c implies a < c. The same must hold for both == and >. + /// * total and antisymmetric: exactly one of `a < b`, `a == b` or `a > b` is true, and + /// * transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`. /// /// For example, while [`f64`] doesn't implement [`Ord`] because `NaN != NaN`, we can use /// `partial_cmp` as our sort function when we know the slice doesn't contain a `NaN`. diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 73f67e98f36..84c35c6f1bd 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -963,7 +963,7 @@ impl String { /// Does nothing if the capacity is already sufficient. /// /// Note that the allocator may give the collection more space than it - /// requests. Therefore capacity can not be relied upon to be precisely + /// requests. Therefore, capacity can not be relied upon to be precisely /// minimal. Prefer `reserve` if future insertions are expected. /// /// # Errors @@ -1377,9 +1377,7 @@ impl String { self.vec.len() } - /// Returns `true` if this `String` has a length of zero. - /// - /// Returns `false` otherwise. + /// Returns `true` if this `String` has a length of zero, and `false` otherwise. /// /// # Examples /// diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 5bdb3616ed2..b7d7995b540 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -560,7 +560,7 @@ impl Arc { #[inline] #[stable(feature = "ptr_eq", since = "1.17.0")] - /// Returns true if the two `Arc`s point to the same value (not + /// Returns `true` if the two `Arc`s point to the same value (not /// just values that compare as equal). /// /// # Examples @@ -1191,8 +1191,8 @@ impl Weak { }) } - /// Return `None` when the pointer is dangling and there is no allocated `ArcInner`, - /// i.e., this `Weak` was created by `Weak::new` + /// Returns `None` when the pointer is dangling and there is no allocated `ArcInner`, + /// (i.e., when this `Weak` was created by `Weak::new`). #[inline] fn inner(&self) -> Option<&ArcInner> { if is_dangling(self.ptr) { @@ -1202,7 +1202,7 @@ impl Weak { } } - /// Returns true if the two `Weak`s point to the same value (not just values + /// Returns `true` if the two `Weak`s point to the same value (not just values /// that compare as equal). /// /// # Notes diff --git a/src/liballoc/tests/heap.rs b/src/liballoc/tests/heap.rs index 809d2bc094a..7bc1aac7c8b 100644 --- a/src/liballoc/tests/heap.rs +++ b/src/liballoc/tests/heap.rs @@ -2,7 +2,7 @@ use std::alloc::{Global, Alloc, Layout, System}; -/// https://github.com/rust-lang/rust/issues/45955 +/// Issue #45955. #[test] fn alloc_system_overaligned_request() { check_overalign_requests(System) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 4bc21ec7f5e..57723e4d212 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -463,7 +463,7 @@ impl Vec { /// Does nothing if the capacity is already sufficient. /// /// Note that the allocator may give the collection more space than it - /// requests. Therefore capacity can not be relied upon to be precisely + /// requests. Therefore, capacity can not be relied upon to be precisely /// minimal. Prefer `reserve` if future insertions are expected. /// /// # Panics @@ -525,7 +525,7 @@ impl Vec { /// Does nothing if the capacity is already sufficient. /// /// Note that the allocator may give the collection more space than it - /// requests. Therefore capacity can not be relied upon to be precisely + /// requests. Therefore, capacity can not be relied upon to be precisely /// minimal. Prefer `reserve` if future insertions are expected. /// /// # Errors @@ -2608,7 +2608,7 @@ impl Drain<'_, T> { /// The range from `self.vec.len` to `self.tail_start` contains elements /// that have been moved out. /// Fill that range as much as possible with new elements from the `replace_with` iterator. - /// Return whether we filled the entire range. (`replace_with.next()` didn’t return `None`.) + /// Returns `true` if we filled the entire range. (`replace_with.next()` didn’t return `None`.) unsafe fn fill>(&mut self, replace_with: &mut I) -> bool { let vec = self.vec.as_mut(); let range_start = vec.len; @@ -2628,7 +2628,7 @@ impl Drain<'_, T> { true } - /// Make room for inserting more elements before the tail. + /// Makes room for inserting more elements before the tail. unsafe fn move_tail(&mut self, extra_capacity: usize) { let vec = self.vec.as_mut(); let used_capacity = self.tail_start + self.tail_len; diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index fb8d7e5d088..8383d305518 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -130,7 +130,7 @@ //! //! This is simply a special - but common - case of the previous: hiding mutability for operations //! that appear to be immutable. The `clone` method is expected to not change the source value, and -//! is declared to take `&self`, not `&mut self`. Therefore any mutation that happens in the +//! is declared to take `&self`, not `&mut self`. Therefore, any mutation that happens in the //! `clone` method must use cell types. For example, `Rc` maintains its reference counts within a //! `Cell`. //! @@ -1145,7 +1145,7 @@ impl<'b, T: ?Sized> Ref<'b, T> { } } - /// Make a new `Ref` for a component of the borrowed data. + /// Makes a new `Ref` for a component of the borrowed data. /// /// The `RefCell` is already immutably borrowed, so this cannot fail. /// @@ -1217,7 +1217,7 @@ impl fmt::Display for Ref<'_, T> { } impl<'b, T: ?Sized> RefMut<'b, T> { - /// Make a new `RefMut` for a component of the borrowed data, e.g., an enum + /// Makes a new `RefMut` for a component of the borrowed data, e.g., an enum /// variant. /// /// The `RefCell` is already mutably borrowed, so this cannot fail. @@ -1416,7 +1416,7 @@ impl fmt::Display for RefMut<'_, T> { /// co-exist with it. A `&mut T` must always be unique. /// /// Note that while mutating or mutably aliasing the contents of an `&UnsafeCell` is -/// okay (provided you enforce the invariants some other way), it is still undefined behavior +/// ok (provided you enforce the invariants some other way), it is still undefined behavior /// to have multiple `&mut UnsafeCell` aliases. /// /// # Examples diff --git a/src/libcore/char/decode.rs b/src/libcore/char/decode.rs index 510c46cdca0..133c9169df8 100644 --- a/src/libcore/char/decode.rs +++ b/src/libcore/char/decode.rs @@ -20,7 +20,7 @@ pub struct DecodeUtf16Error { code: u16, } -/// Create an iterator over the UTF-16 encoded code points in `iter`, +/// Creates an iterator over the UTF-16 encoded code points in `iter`, /// returning unpaired surrogates as `Err`s. /// /// # Examples diff --git a/src/libcore/char/methods.rs b/src/libcore/char/methods.rs index fbc9a4a6b8e..72967b9adf7 100644 --- a/src/libcore/char/methods.rs +++ b/src/libcore/char/methods.rs @@ -524,7 +524,7 @@ impl char { } } - /// Returns true if this `char` is an alphabetic code point, and false if not. + /// Returns `true` if this `char` is an alphabetic code point, and false if not. /// /// # Examples /// @@ -548,7 +548,7 @@ impl char { } } - /// Returns true if this `char` satisfies the 'XID_Start' Unicode property, and false + /// Returns `true` if this `char` satisfies the 'XID_Start' Unicode property, and false /// otherwise. /// /// 'XID_Start' is a Unicode Derived Property specified in @@ -562,7 +562,7 @@ impl char { derived_property::XID_Start(self) } - /// Returns true if this `char` satisfies the 'XID_Continue' Unicode property, and false + /// Returns `true` if this `char` satisfies the 'XID_Continue' Unicode property, and false /// otherwise. /// /// 'XID_Continue' is a Unicode Derived Property specified in @@ -576,7 +576,7 @@ impl char { derived_property::XID_Continue(self) } - /// Returns true if this `char` is lowercase, and false otherwise. + /// Returns `true` if this `char` is lowercase. /// /// 'Lowercase' is defined according to the terms of the Unicode Derived Core /// Property `Lowercase`. @@ -604,7 +604,7 @@ impl char { } } - /// Returns true if this `char` is uppercase, and false otherwise. + /// Returns `true` if this `char` is uppercase. /// /// 'Uppercase' is defined according to the terms of the Unicode Derived Core /// Property `Uppercase`. @@ -632,7 +632,7 @@ impl char { } } - /// Returns true if this `char` is whitespace, and false otherwise. + /// Returns `true` if this `char` is whitespace. /// /// 'Whitespace' is defined according to the terms of the Unicode Derived Core /// Property `White_Space`. @@ -659,7 +659,7 @@ impl char { } } - /// Returns true if this `char` is alphanumeric, and false otherwise. + /// Returns `true` if this `char` is alphanumeric. /// /// 'Alphanumeric'-ness is defined in terms of the Unicode General Categories /// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'. @@ -684,7 +684,7 @@ impl char { self.is_alphabetic() || self.is_numeric() } - /// Returns true if this `char` is a control code point, and false otherwise. + /// Returns `true` if this `char` is a control code point. /// /// 'Control code point' is defined in terms of the Unicode General /// Category `Cc`. @@ -704,7 +704,7 @@ impl char { general_category::Cc(self) } - /// Returns true if this `char` is an extended grapheme character, and false otherwise. + /// Returns `true` if this `char` is an extended grapheme character. /// /// 'Extended grapheme character' is defined in terms of the Unicode Shaping and Rendering /// Category `Grapheme_Extend`. @@ -713,7 +713,7 @@ impl char { derived_property::Grapheme_Extend(self) } - /// Returns true if this `char` is numeric, and false otherwise. + /// Returns `true` if this `char` is numeric. /// /// 'Numeric'-ness is defined in terms of the Unicode General Categories /// 'Nd', 'Nl', 'No'. diff --git a/src/libcore/default.rs b/src/libcore/default.rs index 0e47c2fd0b5..5ad05b38247 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -54,7 +54,7 @@ /// /// ## How can I implement `Default`? /// -/// Provide an implementation for the `default()` method that returns the value of +/// Provides an implementation for the `default()` method that returns the value of /// your type that should be the default: /// /// ``` diff --git a/src/libcore/ffi.rs b/src/libcore/ffi.rs index 644380c69f2..d88793f2801 100644 --- a/src/libcore/ffi.rs +++ b/src/libcore/ffi.rs @@ -184,7 +184,7 @@ impl<'a> VaList<'a> { va_arg(self) } - /// Copy the `va_list` at the current location. + /// Copies the `va_list` at the current location. #[unstable(feature = "c_variadic", reason = "the `c_variadic` feature has not been properly tested on \ all supported platforms", @@ -213,7 +213,7 @@ extern "rust-intrinsic" { /// `va_copy`. fn va_end(ap: &mut VaList); - /// Copy the current location of arglist `src` to the arglist `dst`. + /// Copies the current location of arglist `src` to the arglist `dst`. #[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")), windows))] diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 530b2f52c0d..2ce58c803b8 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -483,12 +483,12 @@ impl Display for Arguments<'_> { /// implementations, such as [`debug_struct`][debug_struct]. /// /// `Debug` implementations using either `derive` or the debug builder API -/// on [`Formatter`] support pretty printing using the alternate flag: `{:#?}`. +/// on [`Formatter`] support pretty-printing using the alternate flag: `{:#?}`. /// /// [debug_struct]: ../../std/fmt/struct.Formatter.html#method.debug_struct /// [`Formatter`]: ../../std/fmt/struct.Formatter.html /// -/// Pretty printing with `#?`: +/// Pretty-printing with `#?`: /// /// ``` /// #[derive(Debug)] diff --git a/src/libcore/future/future.rs b/src/libcore/future/future.rs index 539b07fc21e..0f142347a95 100644 --- a/src/libcore/future/future.rs +++ b/src/libcore/future/future.rs @@ -60,7 +60,7 @@ pub trait Future { /// progress, meaning that each time the current task is woken up, it should /// actively re-`poll` pending futures that it still has an interest in. /// - /// The `poll` function is not called repeatedly in a tight loop-- instead, + /// The `poll` function is not called repeatedly in a tight loop -- instead, /// it should only be called when the future indicates that it is ready to /// make progress (by calling `wake()`). If you're familiar with the /// `poll(2)` or `select(2)` syscalls on Unix it's worth noting that futures diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index 18f09f4c5dd..235c79307ab 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -10,7 +10,7 @@ use mem; /// An implementation of SipHash 1-3. /// /// This is currently the default hashing function used by standard library -/// (eg. `collections::HashMap` uses it by default). +/// (e.g., `collections::HashMap` uses it by default). /// /// See: #[unstable(feature = "hashmap_internals", issue = "0")] @@ -90,7 +90,7 @@ macro_rules! compress { }); } -/// Load an integer of the desired type from a byte stream, in LE order. Uses +/// Loads an integer of the desired type from a byte stream, in LE order. Uses /// `copy_nonoverlapping` to let the compiler generate the most efficient way /// to load it from a possibly unaligned address. /// @@ -107,7 +107,7 @@ macro_rules! load_int_le { }); } -/// Load an u64 using up to 7 bytes of a byte slice. +/// Loads an u64 using up to 7 bytes of a byte slice. /// /// Unsafe because: unchecked indexing at start..start+len #[inline] diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs index ad5a2071a73..89de5c1bc8a 100644 --- a/src/libcore/hint.rs +++ b/src/libcore/hint.rs @@ -34,7 +34,7 @@ use intrinsics; /// use std::hint::unreachable_unchecked; /// /// // `b.saturating_add(1)` is always positive (not zero), -/// // hence `checked_div` will never return None. +/// // hence `checked_div` will never return `None`. /// // Therefore, the else branch is unreachable. /// a.checked_div(b.saturating_add(1)) /// .unwrap_or_else(|| unsafe { unreachable_unchecked() }) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index c29358c4c4a..f6de7566be9 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -315,35 +315,35 @@ extern "rust-intrinsic" { /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap). pub fn atomic_xchg_relaxed(dst: *mut T, src: T) -> T; - /// Add to the current value, returning the previous value. + /// Adds to the current value, returning the previous value. /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_add` method by passing /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html) /// as the `order`. For example, /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). pub fn atomic_xadd(dst: *mut T, src: T) -> T; - /// Add to the current value, returning the previous value. + /// Adds to the current value, returning the previous value. /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_add` method by passing /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html) /// as the `order`. For example, /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). pub fn atomic_xadd_acq(dst: *mut T, src: T) -> T; - /// Add to the current value, returning the previous value. + /// Adds to the current value, returning the previous value. /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_add` method by passing /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html) /// as the `order`. For example, /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). pub fn atomic_xadd_rel(dst: *mut T, src: T) -> T; - /// Add to the current value, returning the previous value. + /// Adds to the current value, returning the previous value. /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_add` method by passing /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html) /// as the `order`. For example, /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add). pub fn atomic_xadd_acqrel(dst: *mut T, src: T) -> T; - /// Add to the current value, returning the previous value. + /// Adds to the current value, returning the previous value. /// The stabilized version of this intrinsic is available on the /// `std::sync::atomic` types via the `fetch_add` method by passing /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html) @@ -556,7 +556,7 @@ extern "rust-intrinsic" { pub fn atomic_umax_relaxed(dst: *mut T, src: T) -> T; /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction - /// if supported; otherwise, it is a noop. + /// if supported; otherwise, it is a no-op. /// Prefetches have no effect on the behavior of the program but can change its performance /// characteristics. /// @@ -564,7 +564,7 @@ extern "rust-intrinsic" { /// ranging from (0) - no locality, to (3) - extremely local keep in cache pub fn prefetch_read_data(data: *const T, locality: i32); /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction - /// if supported; otherwise, it is a noop. + /// if supported; otherwise, it is a no-op. /// Prefetches have no effect on the behavior of the program but can change its performance /// characteristics. /// @@ -572,7 +572,7 @@ extern "rust-intrinsic" { /// ranging from (0) - no locality, to (3) - extremely local keep in cache pub fn prefetch_write_data(data: *const T, locality: i32); /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction - /// if supported; otherwise, it is a noop. + /// if supported; otherwise, it is a no-op. /// Prefetches have no effect on the behavior of the program but can change its performance /// characteristics. /// @@ -580,7 +580,7 @@ extern "rust-intrinsic" { /// ranging from (0) - no locality, to (3) - extremely local keep in cache pub fn prefetch_read_instruction(data: *const T, locality: i32); /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction - /// if supported; otherwise, it is a noop. + /// if supported; otherwise, it is a no-op. /// Prefetches have no effect on the behavior of the program but can change its performance /// characteristics. /// @@ -857,7 +857,7 @@ extern "rust-intrinsic" { /// /// // The no-copy, unsafe way, still using transmute, but not UB. /// // This is equivalent to the original, but safer, and reuses the - /// // same Vec internals. Therefore the new inner type must have the + /// // same `Vec` internals. Therefore, the new inner type must have the /// // exact same size, and the same alignment, as the old type. /// // The same caveats exist for this method as transmute, for /// // the original inner type (`&i32`) to the converted inner type @@ -875,8 +875,8 @@ extern "rust-intrinsic" { /// ``` /// use std::{slice, mem}; /// - /// // There are multiple ways to do this; and there are multiple problems - /// // with the following, transmute, way. + /// // There are multiple ways to do this, and there are multiple problems + /// // with the following (transmute) way. /// fn split_at_mut_transmute(slice: &mut [T], mid: usize) /// -> (&mut [T], &mut [T]) { /// let len = slice.len(); @@ -1200,19 +1200,19 @@ extern "rust-intrinsic" { /// unless size is equal to zero. pub fn volatile_set_memory(dst: *mut T, val: u8, count: usize); - /// Perform a volatile load from the `src` pointer. + /// Performs a volatile load from the `src` pointer. /// The stabilized version of this intrinsic is /// [`std::ptr::read_volatile`](../../std/ptr/fn.read_volatile.html). pub fn volatile_load(src: *const T) -> T; - /// Perform a volatile store to the `dst` pointer. + /// Performs a volatile store to the `dst` pointer. /// The stabilized version of this intrinsic is /// [`std::ptr::write_volatile`](../../std/ptr/fn.write_volatile.html). pub fn volatile_store(dst: *mut T, val: T); - /// Perform a volatile load from the `src` pointer + /// Performs a volatile load from the `src` pointer /// The pointer is not required to be aligned. pub fn unaligned_volatile_load(src: *const T) -> T; - /// Perform a volatile store to the `dst` pointer. + /// Performs a volatile store to the `dst` pointer. /// The pointer is not required to be aligned. pub fn unaligned_volatile_store(dst: *mut T, val: T); diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index 66c09a0ddd0..a3e9cfa9493 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -20,19 +20,19 @@ pub trait Step: Clone + PartialOrd + Sized { /// without overflow. fn steps_between(start: &Self, end: &Self) -> Option; - /// Replaces this step with `1`, returning itself + /// Replaces this step with `1`, returning itself. fn replace_one(&mut self) -> Self; - /// Replaces this step with `0`, returning itself + /// Replaces this step with `0`, returning itself. fn replace_zero(&mut self) -> Self; - /// Adds one to this step, returning the result + /// Adds one to this step, returning the result. fn add_one(&self) -> Self; - /// Subtracts one to this step, returning the result + /// Subtracts one to this step, returning the result. fn sub_one(&self) -> Self; - /// Add an usize, returning None on overflow + /// Adds a `usize`, returning `None` on overflow. fn add_usize(&self, n: usize) -> Option; } diff --git a/src/libcore/iter/traits/exact_size.rs b/src/libcore/iter/traits/exact_size.rs index 3bfba29e219..d6eab40213e 100644 --- a/src/libcore/iter/traits/exact_size.rs +++ b/src/libcore/iter/traits/exact_size.rs @@ -104,7 +104,7 @@ pub trait ExactSizeIterator: Iterator { lower } - /// Returns whether the iterator is empty. + /// Returns `true` if the iterator is empty. /// /// This method has a default implementation using `self.len()`, so you /// don't need to implement it yourself. diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index 1c86745d9ba..861e9c3157a 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -120,7 +120,7 @@ pub trait Iterator { /// // ... and then None once it's over. /// assert_eq!(None, iter.next()); /// - /// // More calls may or may not return None. Here, they always will. + /// // More calls may or may not return `None`. Here, they always will. /// assert_eq!(None, iter.next()); /// assert_eq!(None, iter.next()); /// ``` @@ -1215,7 +1215,7 @@ pub trait Iterator { /// assert_eq!(iter.next(), Some(4)); /// assert_eq!(iter.next(), None); /// - /// // it will always return None after the first time. + /// // it will always return `None` after the first time. /// assert_eq!(iter.next(), None); /// assert_eq!(iter.next(), None); /// assert_eq!(iter.next(), None); diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index d81d309a81a..2a9cb75df2c 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -1,4 +1,4 @@ -/// Entry point of thread panic, for details, see std::macros +/// Entry point of thread panic. For details, see `std::macros`. #[macro_export] #[allow_internal_unstable] #[stable(feature = "core", since = "1.6.0")] @@ -493,7 +493,7 @@ macro_rules! unreachable { /// A standardized placeholder for marking unfinished code. /// /// This can be useful if you are prototyping and are just looking to have your -/// code typecheck, or if you're implementing a trait that requires multiple +/// code type-check, or if you're implementing a trait that requires multiple /// methods, and you're only planning on using one of them. /// /// # Panics diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 855b8ba7f96..2a493e88fe8 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -295,7 +295,7 @@ pub const fn size_of() -> usize { /// Returns the size of the pointed-to value in bytes. /// /// This is usually the same as `size_of::()`. However, when `T` *has* no -/// statically known size, e.g., a slice [`[T]`][slice] or a [trait object], +/// statically-known size, e.g., a slice [`[T]`][slice] or a [trait object], /// then `size_of_val` can be used to get the dynamically-known size. /// /// [slice]: ../../std/primitive.slice.html @@ -403,7 +403,7 @@ pub fn align_of_val(val: &T) -> usize { unsafe { intrinsics::min_align_of_val(val) } } -/// Returns whether dropping values of type `T` matters. +/// Returns `true` if dropping values of type `T` matters. /// /// This is purely an optimization hint, and may be implemented conservatively: /// it may return `true` for types that don't actually need to be dropped. @@ -958,7 +958,7 @@ impl ManuallyDrop { ManuallyDrop { value } } - /// Extract the value from the `ManuallyDrop` container. + /// Extracts the value from the `ManuallyDrop` container. /// /// This allows the value to be dropped again. /// @@ -1038,26 +1038,29 @@ impl DerefMut for ManuallyDrop { /// A newtype to construct uninitialized instances of `T`. /// /// The compiler, in general, assumes that variables are properly initialized -/// at their respective type. For example, a variable of reference type must -/// be aligned and non-NULL. This is an invariant that must *always* be upheld, -/// even in unsafe code. As a consequence, 0-initializing a variable of reference +/// at their respective type. For example, a variable of reference type must +/// be aligned and non-NULL. This is an invariant that must *always* be upheld, +/// even in unsafe code. As a consequence, zero-initializing a variable of reference /// type causes instantaneous undefined behavior, no matter whether that reference /// ever gets used to access memory: +/// /// ```rust,no_run /// use std::mem; /// /// let x: &i32 = unsafe { mem::zeroed() }; // undefined behavior! /// ``` +/// /// This is exploited by the compiler for various optimizations, such as eliding /// run-time checks and optimizing `enum` layout. /// -/// Not initializing memory at all (instead of 0-initializing it) causes the same +/// Not initializing memory at all (instead of zero--initializing it) causes the same /// issue: after all, the initial value of the variable might just happen to be /// one that violates the invariant. /// /// `MaybeUninit` serves to enable unsafe code to deal with uninitialized data: /// it is a signal to the compiler indicating that the data here might *not* /// be initialized: +/// /// ```rust /// #![feature(maybe_uninit)] /// use std::mem::MaybeUninit; @@ -1070,6 +1073,7 @@ impl DerefMut for ManuallyDrop { /// // initializing `x`! /// let x = unsafe { x.into_initialized() }; /// ``` +/// /// The compiler then knows to not optimize this code. #[allow(missing_debug_implementations)] #[unstable(feature = "maybe_uninit", issue = "53491")] @@ -1090,7 +1094,7 @@ impl MaybeUninit { MaybeUninit { value: ManuallyDrop::new(val) } } - /// Create a new `MaybeUninit` in an uninitialized state. + /// Creates a new `MaybeUninit` in an uninitialized state. /// /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. /// It is your responsibility to make sure `T` gets dropped if it got initialized. @@ -1100,7 +1104,7 @@ impl MaybeUninit { MaybeUninit { uninit: () } } - /// Create a new `MaybeUninit` in an uninitialized state, with the memory being + /// Creates a new `MaybeUninit` in an uninitialized state, with the memory being /// filled with `0` bytes. It depends on `T` whether that already makes for /// proper initialization. For example, `MaybeUninit::zeroed()` is initialized, /// but `MaybeUninit<&'static i32>::zeroed()` is not because references must not @@ -1118,9 +1122,9 @@ impl MaybeUninit { u } - /// Set the value of the `MaybeUninit`. This overwrites any previous value without dropping it. - /// For your convenience, this also returns a mutable reference to the (now - /// safely initialized) content of `self`. + /// Sets the value of the `MaybeUninit`. This overwrites any previous value without dropping it. + /// For your convenience, this also returns a mutable reference to the (now safely initialized) + /// contents of `self`. #[unstable(feature = "maybe_uninit", issue = "53491")] #[inline(always)] pub fn set(&mut self, val: T) -> &mut T { @@ -1130,7 +1134,7 @@ impl MaybeUninit { } } - /// Extract the value from the `MaybeUninit` container. This is a great way + /// Extracts the value from the `MaybeUninit` container. This is a great way /// to ensure that the data will get dropped, because the resulting `T` is /// subject to the usual drop handling. /// @@ -1145,7 +1149,7 @@ impl MaybeUninit { ManuallyDrop::into_inner(self.value) } - /// Deprecated alternative to `into_initialized`. Will never get stabilized. + /// Deprecated alternative to `into_initialized`. Will never get stabilized. /// Exists only to transition stdsimd to `into_initialized`. #[inline(always)] #[allow(unused)] @@ -1153,7 +1157,7 @@ impl MaybeUninit { self.into_initialized() } - /// Get a reference to the contained value. + /// Gets a reference to the contained value. /// /// # Unsafety /// @@ -1165,7 +1169,7 @@ impl MaybeUninit { &*self.value } - /// Get a mutable reference to the contained value. + /// Gets a mutable reference to the contained value. /// /// # Unsafety /// @@ -1180,7 +1184,7 @@ impl MaybeUninit { &mut *self.value } - /// Get a pointer to the contained value. Reading from this pointer or turning it + /// Gets a pointer to the contained value. Reading from this pointer or turning it /// into a reference will be undefined behavior unless the `MaybeUninit` is initialized. #[unstable(feature = "maybe_uninit", issue = "53491")] #[inline(always)] @@ -1188,7 +1192,7 @@ impl MaybeUninit { unsafe { &*self.value as *const T } } - /// Get a mutable pointer to the contained value. Reading from this pointer or turning it + /// Get sa mutable pointer to the contained value. Reading from this pointer or turning it /// into a reference will be undefined behavior unless the `MaybeUninit` is initialized. #[unstable(feature = "maybe_uninit", issue = "53491")] #[inline(always)] @@ -1196,14 +1200,14 @@ impl MaybeUninit { unsafe { &mut *self.value as *mut T } } - /// Get a pointer to the first element of the array. + /// Gets a pointer to the first element of the array. #[unstable(feature = "maybe_uninit", issue = "53491")] #[inline(always)] pub fn first_ptr(this: &[MaybeUninit]) -> *const T { this as *const [MaybeUninit] as *const T } - /// Get a mutable pointer to the first element of the array. + /// Gets a mutable pointer to the first element of the array. #[unstable(feature = "maybe_uninit", issue = "53491")] #[inline(always)] pub fn first_ptr_mut(this: &mut [MaybeUninit]) -> *mut T { diff --git a/src/libcore/num/dec2flt/algorithm.rs b/src/libcore/num/dec2flt/algorithm.rs index d56fa9662a9..3b57bb7544b 100644 --- a/src/libcore/num/dec2flt/algorithm.rs +++ b/src/libcore/num/dec2flt/algorithm.rs @@ -61,7 +61,7 @@ mod fpu_precision { unsafe { asm!("fldcw $0" :: "m" (cw) :: "volatile") } } - /// Set the precision field of the FPU to `T` and return a `FPUControlWord` + /// Sets the precision field of the FPU to `T` and returns a `FPUControlWord`. pub fn set_precision() -> FPUControlWord { let cw = 0u16; diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index a1bf6f824f6..47ea5aa5ff0 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -54,7 +54,7 @@ //! operations as well, if you want 0.5 ULP accuracy you need to do *everything* in full precision //! and round *exactly once, at the end*, by considering all truncated bits at once. //! -//! FIXME Although some code duplication is necessary, perhaps parts of the code could be shuffled +//! FIXME: Although some code duplication is necessary, perhaps parts of the code could be shuffled //! around such that less code is duplicated. Large parts of the algorithms are independent of the //! float type to output, or only needs access to a few constants, which could be passed in as //! parameters. @@ -219,7 +219,7 @@ fn extract_sign(s: &str) -> (Sign, &str) { } } -/// Convert a decimal string into a floating point number. +/// Converts a decimal string into a floating point number. fn dec2flt(s: &str) -> Result { if s.is_empty() { return Err(pfe_empty()) diff --git a/src/libcore/num/dec2flt/num.rs b/src/libcore/num/dec2flt/num.rs index b76c58cc66e..12671318571 100644 --- a/src/libcore/num/dec2flt/num.rs +++ b/src/libcore/num/dec2flt/num.rs @@ -27,7 +27,7 @@ pub fn compare_with_half_ulp(f: &Big, ones_place: usize) -> Ordering { Equal } -/// Convert an ASCII string containing only decimal digits to a `u64`. +/// Converts an ASCII string containing only decimal digits to a `u64`. /// /// Does not perform checks for overflow or invalid characters, so if the caller is not careful, /// the result is bogus and can panic (though it won't be `unsafe`). Additionally, empty strings @@ -44,7 +44,7 @@ pub fn from_str_unchecked<'a, T>(bytes: T) -> u64 where T : IntoIterator Big { @@ -69,7 +69,7 @@ pub fn to_u64(x: &Big) -> u64 { } -/// Extract a range of bits. +/// Extracts a range of bits. /// Index 0 is the least significant bit and the range is half-open as usual. /// Panics if asked to extract more bits than fit into the return type. diff --git a/src/libcore/num/dec2flt/parse.rs b/src/libcore/num/dec2flt/parse.rs index 9e075e43303..933f8c1d3f7 100644 --- a/src/libcore/num/dec2flt/parse.rs +++ b/src/libcore/num/dec2flt/parse.rs @@ -42,7 +42,7 @@ pub enum ParseResult<'a> { Invalid, } -/// Check if the input string is a valid floating point number and if so, locate the integral +/// Checks if the input string is a valid floating point number and if so, locate the integral /// part, the fractional part, and the exponent in it. Does not handle signs. pub fn parse_decimal(s: &str) -> ParseResult { if s.is_empty() { diff --git a/src/libcore/num/dec2flt/rawfp.rs b/src/libcore/num/dec2flt/rawfp.rs index 06d7fb8d103..b65f539b29c 100644 --- a/src/libcore/num/dec2flt/rawfp.rs +++ b/src/libcore/num/dec2flt/rawfp.rs @@ -240,7 +240,7 @@ impl RawFloat for f64 { fn from_bits(v: Self::Bits) -> Self { Self::from_bits(v) } } -/// Convert an Fp to the closest machine float type. +/// Converts an `Fp` to the closest machine float type. /// Does not handle subnormal results. pub fn fp_to_float(x: Fp) -> T { let x = x.normalize(); @@ -319,7 +319,7 @@ pub fn big_to_fp(f: &Big) -> Fp { } } -/// Find the largest floating point number strictly smaller than the argument. +/// Finds the largest floating point number strictly smaller than the argument. /// Does not handle subnormals, zero, or exponent underflow. pub fn prev_float(x: T) -> T { match x.classify() { diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 68da79135d3..dc0580764ac 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -144,7 +144,7 @@ pub mod consts { #[lang = "f32"] #[cfg(not(test))] impl f32 { - /// Returns `true` if this value is `NaN` and false otherwise. + /// Returns `true` if this value is `NaN`. /// /// ``` /// use std::f32; @@ -169,8 +169,8 @@ impl f32 { f32::from_bits(self.to_bits() & 0x7fff_ffff) } - /// Returns `true` if this value is positive infinity or negative infinity and - /// false otherwise. + /// Returns `true` if this value is positive infinity or negative infinity, and + /// `false` otherwise. /// /// ``` /// use std::f32; @@ -272,7 +272,7 @@ impl f32 { } } - /// Returns `true` if and only if `self` has a positive sign, including `+0.0`, `NaN`s with + /// Returns `true` if `self` has a positive sign, including `+0.0`, `NaN`s with /// positive sign bit and positive infinity. /// /// ``` @@ -288,7 +288,7 @@ impl f32 { !self.is_sign_negative() } - /// Returns `true` if and only if `self` has a negative sign, including `-0.0`, `NaN`s with + /// Returns `true` if `self` has a negative sign, including `-0.0`, `NaN`s with /// negative sign bit and negative infinity. /// /// ``` diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index b6773915481..c3677f8c8fa 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -144,7 +144,7 @@ pub mod consts { #[lang = "f64"] #[cfg(not(test))] impl f64 { - /// Returns `true` if this value is `NaN` and false otherwise. + /// Returns `true` if this value is `NaN`. /// /// ``` /// use std::f64; @@ -169,8 +169,8 @@ impl f64 { f64::from_bits(self.to_bits() & 0x7fff_ffff_ffff_ffff) } - /// Returns `true` if this value is positive infinity or negative infinity and - /// false otherwise. + /// Returns `true` if this value is positive infinity or negative infinity, and + /// `false` otherwise. /// /// ``` /// use std::f64; @@ -272,7 +272,7 @@ impl f64 { } } - /// Returns `true` if and only if `self` has a positive sign, including `+0.0`, `NaN`s with + /// Returns `true` if `self` has a positive sign, including `+0.0`, `NaN`s with /// positive sign bit and positive infinity. /// /// ``` @@ -296,7 +296,7 @@ impl f64 { self.is_sign_positive() } - /// Returns `true` if and only if `self` has a negative sign, including `-0.0`, `NaN`s with + /// Returns `true` if `self` has a negative sign, including `-0.0`, `NaN`s with /// negative sign bit and negative infinity. /// /// ``` diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index f80f8392827..6b3ec2c21be 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -52,7 +52,7 @@ assert_eq!(size_of::>(), size_of::<", s } impl $Ty { - /// Create a non-zero without checking the value. + /// Creates a non-zero without checking the value. /// /// # Safety /// @@ -63,7 +63,7 @@ assert_eq!(size_of::>(), size_of::<", s $Ty(n) } - /// Create a non-zero if the given value is not zero. + /// Creates a non-zero if the given value is not zero. #[$stability] #[inline] pub fn new(n: $Int) -> Option { diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 202beddfcb0..0252edee231 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -49,7 +49,7 @@ /// } /// /// // Notice that the implementation uses the associated type `Output`. -/// impl> Add for Point { +/// impl> Add for Point { /// type Output = Point; /// /// fn add(self, other: Point) -> Point { @@ -157,7 +157,7 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// } /// /// // Notice that the implementation uses the associated type `Output`. -/// impl> Sub for Point { +/// impl> Sub for Point { /// type Output = Point; /// /// fn sub(self, other: Point) -> Point { diff --git a/src/libcore/ops/range.rs b/src/libcore/ops/range.rs index 815a4cfeed8..b3dd5d20299 100644 --- a/src/libcore/ops/range.rs +++ b/src/libcore/ops/range.rs @@ -52,7 +52,7 @@ impl fmt::Debug for RangeFull { /// (`start..end`). /// /// The `Range` `start..end` contains all values with `x >= start` and -/// `x < end`. It is empty unless `start < end`. +/// `x < end`. It is empty unless `start < end`. /// /// # Examples /// @@ -297,7 +297,7 @@ impl> RangeTo { /// A range bounded inclusively below and above (`start..=end`). /// /// The `RangeInclusive` `start..=end` contains all values with `x >= start` -/// and `x <= end`. It is empty unless `start <= end`. +/// and `x <= end`. It is empty unless `start <= end`. /// /// This iterator is [fused], but the specific values of `start` and `end` after /// iteration has finished are **unspecified** other than that [`.is_empty()`] diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 0e54397db02..76ef36ac309 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -214,7 +214,7 @@ impl Option { /// /// # Examples /// - /// Convert an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, preserving the original. + /// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, preserving the original. /// The [`map`] method takes the `self` argument by value, consuming the original, /// so this technique uses `as_ref` to first take an `Option` to a reference /// to the value inside the original. @@ -395,7 +395,7 @@ impl Option { /// /// # Examples /// - /// Convert an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, consuming the original: + /// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, consuming the original: /// /// [`String`]: ../../std/string/struct.String.html /// [`usize`]: ../../std/primitive.usize.html @@ -963,7 +963,7 @@ impl Option { /// /// # Examples /// - /// Convert a string to an integer, turning poorly-formed strings + /// Converts a string to an integer, turning poorly-formed strings /// into 0 (the default value for integers). [`parse`] converts /// a string to any other type that implements [`FromStr`], returning /// [`None`] on error. diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs index 56a32c928fb..ee9098d73ee 100644 --- a/src/libcore/pin.rs +++ b/src/libcore/pin.rs @@ -199,7 +199,7 @@ impl Pin

{ Pin { pointer } } - /// Get a pinned shared reference from this pinned pointer. + /// Gets a pinned shared reference from this pinned pointer. #[stable(feature = "pin", since = "1.33.0")] #[inline(always)] pub fn as_ref(self: &Pin

) -> Pin<&P::Target> { @@ -208,7 +208,7 @@ impl Pin

{ } impl Pin

{ - /// Get a pinned mutable reference from this pinned pointer. + /// Gets a pinned mutable reference from this pinned pointer. #[stable(feature = "pin", since = "1.33.0")] #[inline(always)] pub fn as_mut(self: &mut Pin

) -> Pin<&mut P::Target> { @@ -247,7 +247,7 @@ impl<'a, T: ?Sized> Pin<&'a T> { Pin::new_unchecked(new_pointer) } - /// Get a shared reference out of a pin. + /// Gets a shared reference out of a pin. /// /// Note: `Pin` also implements `Deref` to the target, which can be used /// to access the inner value. However, `Deref` only provides a reference @@ -262,14 +262,14 @@ impl<'a, T: ?Sized> Pin<&'a T> { } impl<'a, T: ?Sized> Pin<&'a mut T> { - /// Convert this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime. + /// Converts this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime. #[stable(feature = "pin", since = "1.33.0")] #[inline(always)] pub fn into_ref(self: Pin<&'a mut T>) -> Pin<&'a T> { Pin { pointer: self.pointer } } - /// Get a mutable reference to the data inside of this `Pin`. + /// Gets a mutable reference to the data inside of this `Pin`. /// /// This requires that the data inside this `Pin` is `Unpin`. /// @@ -286,7 +286,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> { self.pointer } - /// Get a mutable reference to the data inside of this `Pin`. + /// Gets a mutable reference to the data inside of this `Pin`. /// /// # Safety /// diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 20960845718..866c8d0896b 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -825,7 +825,7 @@ pub unsafe fn write_unaligned(dst: *mut T, src: T) { /// /// The compiler shouldn't change the relative order or number of volatile /// memory operations. However, volatile memory operations on zero-sized types -/// (e.g., if a zero-sized type is passed to `read_volatile`) are no-ops +/// (e.g., if a zero-sized type is passed to `read_volatile`) are noops /// and may be ignored. /// /// [c11]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf @@ -903,7 +903,7 @@ pub unsafe fn read_volatile(src: *const T) -> T { /// /// The compiler shouldn't change the relative order or number of volatile /// memory operations. However, volatile memory operations on zero-sized types -/// (e.g., if a zero-sized type is passed to `write_volatile`) are no-ops +/// (e.g., if a zero-sized type is passed to `write_volatile`) are noops /// and may be ignored. /// /// [c11]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf @@ -2473,7 +2473,7 @@ impl PartialEq for *mut T { #[stable(feature = "rust1", since = "1.0.0")] impl Eq for *mut T {} -/// Compare raw pointers for equality. +/// Compares raw pointers for equality. /// /// This is the same as using the `==` operator, but less generic: /// the arguments have to be `*const T` raw pointers, diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 1ebf0714e23..92d29f6ee8a 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -896,7 +896,7 @@ impl Result { /// /// # Examples /// - /// Convert a string to an integer, turning poorly-formed strings + /// Converts a string to an integer, turning poorly-formed strings /// into 0 (the default value for integers). [`parse`] converts /// a string to any other type that implements [`FromStr`], returning an /// [`Err`] on error. diff --git a/src/libcore/slice/memchr.rs b/src/libcore/slice/memchr.rs index 312838a170c..cbba546b8da 100644 --- a/src/libcore/slice/memchr.rs +++ b/src/libcore/slice/memchr.rs @@ -11,7 +11,7 @@ const HI_U64: u64 = 0x8080808080808080; const LO_USIZE: usize = LO_U64 as usize; const HI_USIZE: usize = HI_U64 as usize; -/// Returns whether `x` contains any zero byte. +/// Returns `true` if `x` contains any zero byte. /// /// From *Matters Computational*, J. Arndt: /// diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index e2129c68e7f..acca9748372 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4123,7 +4123,7 @@ pub struct ChunksExact<'a, T:'a> { } impl<'a, T> ChunksExact<'a, T> { - /// Return the remainder of the original slice that is not going to be + /// Returns the remainder of the original slice that is not going to be /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. #[stable(feature = "chunks_exact", since = "1.31.0")] @@ -4247,7 +4247,7 @@ pub struct ChunksExactMut<'a, T:'a> { } impl<'a, T> ChunksExactMut<'a, T> { - /// Return the remainder of the original slice that is not going to be + /// Returns the remainder of the original slice that is not going to be /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. #[stable(feature = "chunks_exact", since = "1.31.0")] @@ -4619,7 +4619,7 @@ pub struct RChunksExact<'a, T:'a> { } impl<'a, T> RChunksExact<'a, T> { - /// Return the remainder of the original slice that is not going to be + /// Returns the remainder of the original slice that is not going to be /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. #[stable(feature = "rchunks", since = "1.31.0")] @@ -4744,7 +4744,7 @@ pub struct RChunksExactMut<'a, T:'a> { } impl<'a, T> RChunksExactMut<'a, T> { - /// Return the remainder of the original slice that is not going to be + /// Returns the remainder of the original slice that is not going to be /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. #[stable(feature = "rchunks", since = "1.31.0")] diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index c43db916888..6c08e545c5c 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -226,7 +226,7 @@ impl Utf8Error { #[stable(feature = "utf8_error", since = "1.5.0")] pub fn valid_up_to(&self) -> usize { self.valid_up_to } - /// Provide more information about the failure: + /// Provides more information about the failure: /// /// * `None`: the end of the input was reached unexpectedly. /// `self.valid_up_to()` is 1 to 3 bytes from the end of the input. @@ -3504,7 +3504,7 @@ impl str { /// /// A string is a sequence of bytes. `start` in this context means the first /// position of that byte string; for a left-to-right language like English or - /// Russian, this will be left side; and for right-to-left languages like + /// Russian, this will be left side, and for right-to-left languages like /// like Arabic or Hebrew, this will be the right side. /// /// # Examples @@ -3541,7 +3541,7 @@ impl str { /// /// A string is a sequence of bytes. `end` in this context means the last /// position of that byte string; for a left-to-right language like English or - /// Russian, this will be right side; and for right-to-left languages like + /// Russian, this will be right side, and for right-to-left languages like /// like Arabic or Hebrew, this will be the left side. /// /// # Examples @@ -3787,7 +3787,7 @@ impl str { /// /// A string is a sequence of bytes. `start` in this context means the first /// position of that byte string; for a left-to-right language like English or - /// Russian, this will be left side; and for right-to-left languages like + /// Russian, this will be left side, and for right-to-left languages like /// like Arabic or Hebrew, this will be the right side. /// /// # Examples @@ -3819,7 +3819,7 @@ impl str { /// /// A string is a sequence of bytes. `end` in this context means the last /// position of that byte string; for a left-to-right language like English or - /// Russian, this will be right side; and for right-to-left languages like + /// Russian, this will be right side, and for right-to-left languages like /// like Arabic or Hebrew, this will be the left side. /// /// # Examples diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index e5a75cdbbcc..2571780ad0b 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -117,7 +117,7 @@ pub unsafe trait Searcher<'a> { /// `[Reject(0, 1), Reject(1, 2), Match(2, 5), Reject(5, 8)]` fn next(&mut self) -> SearchStep; - /// Find the next `Match` result. See `next()` + /// Finds the next `Match` result. See `next()` /// /// Unlike next(), there is no guarantee that the returned ranges /// of this and next_reject will overlap. This will return (start_match, end_match), @@ -134,7 +134,7 @@ pub unsafe trait Searcher<'a> { } } - /// Find the next `Reject` result. See `next()` and `next_match()` + /// Finds the next `Reject` result. See `next()` and `next_match()` /// /// Unlike next(), there is no guarantee that the returned ranges /// of this and next_match will overlap. @@ -185,7 +185,7 @@ pub unsafe trait ReverseSearcher<'a>: Searcher<'a> { /// `[Reject(7, 8), Match(4, 7), Reject(1, 4), Reject(0, 1)]` fn next_back(&mut self) -> SearchStep; - /// Find the next `Match` result. See `next_back()` + /// Finds the next `Match` result. See `next_back()` #[inline] fn next_match_back(&mut self) -> Option<(usize, usize)>{ loop { @@ -197,7 +197,7 @@ pub unsafe trait ReverseSearcher<'a>: Searcher<'a> { } } - /// Find the next `Reject` result. See `next_back()` + /// Finds the next `Reject` result. See `next_back()` #[inline] fn next_reject_back(&mut self) -> Option<(usize, usize)>{ loop { diff --git a/src/libcore/task/poll.rs b/src/libcore/task/poll.rs index ac656153519..c811f96ace3 100644 --- a/src/libcore/task/poll.rs +++ b/src/libcore/task/poll.rs @@ -22,7 +22,7 @@ pub enum Poll { } impl Poll { - /// Change the ready value of this `Poll` with the closure provided + /// Changes the ready value of this `Poll` with the closure provided. pub fn map(self, f: F) -> Poll where F: FnOnce(T) -> U { @@ -32,7 +32,7 @@ impl Poll { } } - /// Returns whether this is `Poll::Ready` + /// Returns `true` if this is `Poll::Ready` #[inline] pub fn is_ready(&self) -> bool { match *self { @@ -41,7 +41,7 @@ impl Poll { } } - /// Returns whether this is `Poll::Pending` + /// Returns `true` if this is `Poll::Pending` #[inline] pub fn is_pending(&self) -> bool { !self.is_ready() @@ -49,7 +49,7 @@ impl Poll { } impl Poll> { - /// Change the success value of this `Poll` with the closure provided + /// Changes the success value of this `Poll` with the closure provided. pub fn map_ok(self, f: F) -> Poll> where F: FnOnce(T) -> U { @@ -60,7 +60,7 @@ impl Poll> { } } - /// Change the error value of this `Poll` with the closure provided + /// Changes the error value of this `Poll` with the closure provided. pub fn map_err(self, f: F) -> Poll> where F: FnOnce(E) -> U { diff --git a/src/libcore/task/wake.rs b/src/libcore/task/wake.rs index 3f7098f1ef9..6d54989706c 100644 --- a/src/libcore/task/wake.rs +++ b/src/libcore/task/wake.rs @@ -41,11 +41,11 @@ impl Waker { unsafe { self.inner.as_ref().wake() } } - /// Returns whether or not this `Waker` and `other` awaken the same task. + /// Returns `true` if or not this `Waker` and `other` awaken the same task. /// /// This function works on a best-effort basis, and may return false even /// when the `Waker`s would awaken the same task. However, if this function - /// returns true, it is guaranteed that the `Waker`s will awaken the same + /// returns `true`, it is guaranteed that the `Waker`s will awaken the same /// task. /// /// This function is primarily used for optimization purposes. @@ -54,7 +54,7 @@ impl Waker { self.inner == other.inner } - /// Returns whether or not this `Waker` and `other` `LocalWaker` awaken + /// Returns `true` if or not this `Waker` and `other` `LocalWaker` awaken /// the same task. /// /// This function works on a best-effort basis, and may return false even @@ -150,7 +150,7 @@ impl LocalWaker { unsafe { self.0.inner.as_ref().wake_local() } } - /// Returns whether or not this `LocalWaker` and `other` `LocalWaker` awaken the same task. + /// Returns `true` if or not this `LocalWaker` and `other` `LocalWaker` awaken the same task. /// /// This function works on a best-effort basis, and may return false even /// when the `LocalWaker`s would awaken the same task. However, if this function @@ -163,7 +163,7 @@ impl LocalWaker { self.0.will_wake(&other.0) } - /// Returns whether or not this `LocalWaker` and `other` `Waker` awaken the same task. + /// Returns `true` if or not this `LocalWaker` and `other` `Waker` awaken the same task. /// /// This function works on a best-effort basis, and may return false even /// when the `Waker`s would awaken the same task. However, if this function @@ -223,14 +223,14 @@ pub unsafe trait UnsafeWake: Send + Sync { /// Drops this instance of `UnsafeWake`, deallocating resources /// associated with it. /// - /// FIXME(cramertj) + // FIXME(cramertj): /// This method is intended to have a signature such as: /// /// ```ignore (not-a-doctest) /// fn drop_raw(self: *mut Self); /// ``` /// - /// Unfortunately in Rust today that signature is not object safe. + /// Unfortunately, in Rust today that signature is not object safe. /// Nevertheless it's recommended to implement this function *as if* that /// were its signature. As such it is not safe to call on an invalid /// pointer, nor is the validity of the pointer guaranteed after this diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 9b4c78f8d3b..51a6017de1b 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -881,7 +881,7 @@ fn test_iterator_flat_map() { assert_eq!(i, ys.len()); } -/// Test `FlatMap::fold` with items already picked off the front and back, +/// Tests `FlatMap::fold` with items already picked off the front and back, /// to make sure all parts of the `FlatMap` are folded correctly. #[test] fn test_iterator_flat_map_fold() { @@ -919,7 +919,7 @@ fn test_iterator_flatten() { assert_eq!(i, ys.len()); } -/// Test `Flatten::fold` with items already picked off the front and back, +/// Tests `Flatten::fold` with items already picked off the front and back, /// to make sure all parts of the `Flatten` are folded correctly. #[test] fn test_iterator_flatten_fold() { diff --git a/src/libcore/time.rs b/src/libcore/time.rs index ee583c829dd..ac7e11754aa 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -515,7 +515,7 @@ impl Duration { } } - /// Multiply `Duration` by `f64`. + /// Multiplies `Duration` by `f64`. /// /// # Panics /// This method will panic if result is not finite, negative or overflows `Duration`. diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 91c4e990e00..beecfb1aa29 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -370,7 +370,7 @@ const DISPLACEMENT_THRESHOLD: usize = 128; /// } /// /// impl Viking { -/// /// Create a new Viking. +/// /// Creates a new Viking. /// fn new(name: &str, country: &str) -> Viking { /// Viking { name: name.to_string(), country: country.to_string() } /// } @@ -556,7 +556,7 @@ fn pop_internal(starting_bucket: FullBucketMut) (retkey, retval, gap.into_table()) } -/// Perform robin hood bucket stealing at the given `bucket`. You must +/// Performs robin hood bucket stealing at the given `bucket`. You must /// also pass that bucket's displacement so we don't have to recalculate it. /// /// `hash`, `key`, and `val` are the elements to "robin hood" into the hashtable. @@ -1214,7 +1214,7 @@ impl HashMap self.table.size() } - /// Returns true if the map contains no elements. + /// Returns `true` if the map contains no elements. /// /// # Examples /// @@ -1332,7 +1332,7 @@ impl HashMap self.search(k).map(|bucket| bucket.into_refs()) } - /// Returns true if the map contains a value for the specified key. + /// Returns `true` if the map contains a value for the specified key. /// /// The key may be any borrowed form of the map's key type, but /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for @@ -1896,7 +1896,7 @@ impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S> where S: BuildHasher, K: Eq + Hash, { - /// Create a `RawEntryMut` from the given key. + /// Creates a `RawEntryMut` from the given key. #[unstable(feature = "hash_raw_entry", issue = "56167")] pub fn from_key(self, k: &Q) -> RawEntryMut<'a, K, V, S> where K: Borrow, @@ -1907,7 +1907,7 @@ impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S> self.from_key_hashed_nocheck(hasher.finish(), k) } - /// Create a `RawEntryMut` from the given key and its hash. + /// Creates a `RawEntryMut` from the given key and its hash. #[inline] #[unstable(feature = "hash_raw_entry", issue = "56167")] pub fn from_key_hashed_nocheck(self, hash: u64, k: &Q) -> RawEntryMut<'a, K, V, S> @@ -1939,7 +1939,7 @@ impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S> } } } - /// Create a `RawEntryMut` from the given hash. + /// Creates a `RawEntryMut` from the given hash. #[inline] #[unstable(feature = "hash_raw_entry", issue = "56167")] pub fn from_hash(self, hash: u64, is_match: F) -> RawEntryMut<'a, K, V, S> diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index c55dd049ec6..92e63df7c68 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -471,7 +471,7 @@ impl HashSet self.map.len() } - /// Returns true if the set contains no elements. + /// Returns `true` if the set contains no elements. /// /// # Examples /// @@ -696,7 +696,7 @@ impl HashSet Recover::replace(&mut self.map, value) } - /// Removes a value from the set. Returns `true` if the value was + /// Removes a value from the set. Returns whether the value was /// present in the set. /// /// The value may be any borrowed form of the set's value type, but diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 28beb80612c..9446a80a55c 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -248,11 +248,11 @@ impl FullBucket { pub fn into_table(self) -> M { self.table } - /// Get the raw index. + /// Gets the raw index. pub fn index(&self) -> usize { self.raw.idx } - /// Get the raw bucket. + /// Gets the raw bucket. pub fn raw(&self) -> RawBucket { self.raw } @@ -270,7 +270,7 @@ impl EmptyBucket { } impl Bucket { - /// Get the raw index. + /// Gets the raw index. pub fn index(&self) -> usize { self.raw.idx } @@ -503,7 +503,7 @@ impl>> FullBucket { } } - /// Get the distance between this bucket and the 'ideal' location + /// Gets the distance between this bucket and the 'ideal' location /// as determined by the key's hash stored in it. /// /// In the cited blog posts above, this is called the "distance to @@ -839,12 +839,12 @@ impl RawTable { } } - /// Set the table tag + /// Sets the table tag. pub fn set_tag(&mut self, value: bool) { self.hashes.set_tag(value) } - /// Get the table tag + /// Gets the table tag. pub fn tag(&self) -> bool { self.hashes.tag() } diff --git a/src/libstd/collections/mod.rs b/src/libstd/collections/mod.rs index ef397283ca4..9ebeff48426 100644 --- a/src/libstd/collections/mod.rs +++ b/src/libstd/collections/mod.rs @@ -323,8 +323,8 @@ //! // A client of the bar. They have a blood alcohol level. //! struct Person { blood_alcohol: f32 } //! -//! // All the orders made to the bar, by client id. -//! let orders = vec![1,2,1,2,3,4,1,2,2,3,4,1,1,1]; +//! // All the orders made to the bar, by client ID. +//! let orders = vec![1, 2, 1, 2, 3, 4, 1, 2, 2, 3, 4, 1, 1, 1]; //! //! // Our clients. //! let mut blood_alcohol = BTreeMap::new(); diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 50415d9aeb9..f792ff56179 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -195,7 +195,7 @@ pub trait Error: Debug + Display { #[stable(feature = "error_source", since = "1.30.0")] fn source(&self) -> Option<&(dyn Error + 'static)> { None } - /// Get the `TypeId` of `self` + /// Gets the `TypeId` of `self` #[doc(hidden)] #[stable(feature = "error_type_id", since = "1.34.0")] fn type_id(&self) -> TypeId where Self: 'static { @@ -564,7 +564,7 @@ impl Error for char::ParseCharError { // copied from any.rs impl dyn Error + 'static { - /// Returns true if the boxed type is the same as `T` + /// Returns `true` if the boxed type is the same as `T` #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn is(&self) -> bool { diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 765452e0288..caf490a0277 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -377,7 +377,7 @@ impl CString { /// /// # Examples /// - /// Create a `CString`, pass ownership to an `extern` function (via raw pointer), then retake + /// Creates a `CString`, pass ownership to an `extern` function (via raw pointer), then retake /// ownership with `from_raw`: /// /// ```ignore (extern-declaration) diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index c05c19ae566..7dbf15cdc90 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -259,7 +259,7 @@ impl OsString { /// already sufficient. /// /// Note that the allocator may give the collection more space than it - /// requests. Therefore capacity can not be relied upon to be precisely + /// requests. Therefore, capacity can not be relied upon to be precisely /// minimal. Prefer reserve if future insertions are expected. /// /// # Examples diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 2837aade82c..f1e8619fc8f 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -25,7 +25,7 @@ use time::SystemTime; /// /// # Examples /// -/// Create a new file and write bytes to it: +/// Creates a new file and write bytes to it: /// /// ```no_run /// use std::fs::File; @@ -488,13 +488,13 @@ impl File { self.inner.file_attr().map(Metadata) } - /// Create a new `File` instance that shares the same underlying file handle + /// Creates a new `File` instance that shares the same underlying file handle /// as the existing `File` instance. Reads, writes, and seeks will affect /// both `File` instances simultaneously. /// /// # Examples /// - /// Create two handles for a file named `foo.txt`: + /// Creates two handles for a file named `foo.txt`: /// /// ```no_run /// use std::fs::File; @@ -896,7 +896,7 @@ impl Metadata { FileType(self.0.file_type()) } - /// Returns whether this metadata is for a directory. The + /// Returns `true` if this metadata is for a directory. The /// result is mutually exclusive to the result of /// [`is_file`], and will be false for symlink metadata /// obtained from [`symlink_metadata`]. @@ -919,7 +919,7 @@ impl Metadata { #[stable(feature = "rust1", since = "1.0.0")] pub fn is_dir(&self) -> bool { self.file_type().is_dir() } - /// Returns whether this metadata is for a regular file. The + /// Returns `true` if this metadata is for a regular file. The /// result is mutually exclusive to the result of /// [`is_dir`], and will be false for symlink metadata /// obtained from [`symlink_metadata`]. @@ -1096,7 +1096,7 @@ impl AsInner for Metadata { } impl Permissions { - /// Returns whether these permissions describe a readonly (unwritable) file. + /// Returns `true` if these permissions describe a readonly (unwritable) file. /// /// # Examples /// @@ -1152,7 +1152,7 @@ impl Permissions { } impl FileType { - /// Test whether this file type represents a directory. The + /// Tests whether this file type represents a directory. The /// result is mutually exclusive to the results of /// [`is_file`] and [`is_symlink`]; only zero or one of these /// tests may pass. @@ -1176,7 +1176,7 @@ impl FileType { #[stable(feature = "file_type", since = "1.1.0")] pub fn is_dir(&self) -> bool { self.0.is_dir() } - /// Test whether this file type represents a regular file. + /// Tests whether this file type represents a regular file. /// The result is mutually exclusive to the results of /// [`is_dir`] and [`is_symlink`]; only zero or one of these /// tests may pass. @@ -1200,7 +1200,7 @@ impl FileType { #[stable(feature = "file_type", since = "1.1.0")] pub fn is_file(&self) -> bool { self.0.is_file() } - /// Test whether this file type represents a symbolic link. + /// Tests whether this file type represents a symbolic link. /// The result is mutually exclusive to the results of /// [`is_dir`] and [`is_file`]; only zero or one of these /// tests may pass. @@ -1209,7 +1209,7 @@ impl FileType { /// with the [`fs::symlink_metadata`] function and not the /// [`fs::metadata`] function. The [`fs::metadata`] function /// follows symbolic links, so [`is_symlink`] would always - /// return false for the target file. + /// return `false` for the target file. /// /// [`Metadata`]: struct.Metadata.html /// [`fs::metadata`]: fn.metadata.html @@ -1290,7 +1290,7 @@ impl DirEntry { #[stable(feature = "rust1", since = "1.0.0")] pub fn path(&self) -> PathBuf { self.0.path() } - /// Return the metadata for the file that this entry points at. + /// Returns the metadata for the file that this entry points at. /// /// This function will not traverse symlinks if this entry points at a /// symlink. @@ -1325,7 +1325,7 @@ impl DirEntry { self.0.metadata().map(Metadata) } - /// Return the file type for the file that this entry points at. + /// Returns the file type for the file that this entry points at. /// /// This function will not traverse symlinks if this entry points at a /// symlink. @@ -2025,7 +2025,7 @@ impl DirBuilder { self } - /// Create the specified directory with the options configured in this + /// Creates the specified directory with the options configured in this /// builder. /// /// It is considered an error if the directory already exists unless diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 28a6fbd48cf..c0570ae60a1 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1219,11 +1219,11 @@ pub trait Seek { #[derive(Copy, PartialEq, Eq, Clone, Debug)] #[stable(feature = "rust1", since = "1.0.0")] pub enum SeekFrom { - /// Set the offset to the provided number of bytes. + /// Sets the offset to the provided number of bytes. #[stable(feature = "rust1", since = "1.0.0")] Start(#[stable(feature = "rust1", since = "1.0.0")] u64), - /// Set the offset to the size of this object plus the specified number of + /// Sets the offset to the size of this object plus the specified number of /// bytes. /// /// It is possible to seek beyond the end of an object, but it's an error to @@ -1231,7 +1231,7 @@ pub enum SeekFrom { #[stable(feature = "rust1", since = "1.0.0")] End(#[stable(feature = "rust1", since = "1.0.0")] i64), - /// Set the offset to the current position plus the specified number of + /// Sets the offset to the current position plus the specified number of /// bytes. /// /// It is possible to seek beyond the end of an object, but it's an error to diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index d5c2aaea543..bef6bc92661 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -260,7 +260,7 @@ mod extern_keyword { } /// } /// /// fn generic_where(x: T) -> T -/// where T: std::ops::Add + Copy +/// where T: std::ops::Add + Copy /// { /// x + x + x /// } @@ -289,7 +289,7 @@ mod fn_keyword { } /// `for` is primarily used in for-in-loops, but it has a few other pieces of syntactic uses such as /// `impl Trait for Type` (see [`impl`] for more info on that). for-in-loops, or to be more /// precise, iterator loops, are a simple syntactic sugar over an exceedingly common practice -/// within Rust, which is to loop over an iterator until that iterator returns None (or `break` +/// within Rust, which is to loop over an iterator until that iterator returns `None` (or `break` /// is called). /// /// ```rust diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 8ecba3ecd68..63cf6b62145 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -7,7 +7,7 @@ //! primitives](#primitives), [standard macros](#macros), [I/O] and //! [multithreading], among [many other things][other]. //! -//! `std` is available to all Rust crates by default. Therefore the +//! `std` is available to all Rust crates by default. Therefore, the //! standard library can be accessed in [`use`] statements through the path //! `std`, as in [`use std::env`]. //! diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index 91167debff3..654ad64d97b 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -510,7 +510,7 @@ impl SocketAddrV6 { self.inner.sin6_scope_id } - /// Change the scope ID associated with this socket address. + /// Changes the scope ID associated with this socket address. /// /// See the [`scope_id`] method's documentation for more details. /// diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index f45cd8b8c10..4d59aeb6765 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -773,7 +773,7 @@ impl FromInner for Ipv4Addr { #[stable(feature = "ip_u32", since = "1.1.0")] impl From for u32 { - /// Convert an `Ipv4Addr` into a host byte order `u32`. + /// Converts an `Ipv4Addr` into a host byte order `u32`. /// /// # Examples /// @@ -791,7 +791,7 @@ impl From for u32 { #[stable(feature = "ip_u32", since = "1.1.0")] impl From for Ipv4Addr { - /// Convert a host byte order `u32` into an `Ipv4Addr`. + /// Converts a host byte order `u32` into an `Ipv4Addr`. /// /// # Examples /// @@ -823,7 +823,7 @@ impl From<[u8; 4]> for Ipv4Addr { #[stable(feature = "ip_from_slice", since = "1.17.0")] impl From<[u8; 4]> for IpAddr { - /// Create an `IpAddr::V4` from a four element byte array. + /// Creates an `IpAddr::V4` from a four element byte array. /// /// # Examples /// @@ -1420,7 +1420,7 @@ impl From<[u16; 8]> for Ipv6Addr { #[stable(feature = "ip_from_slice", since = "1.17.0")] impl From<[u8; 16]> for IpAddr { - /// Create an `IpAddr::V6` from a sixteen element byte array. + /// Creates an `IpAddr::V6` from a sixteen element byte array. /// /// # Examples /// @@ -1448,7 +1448,7 @@ impl From<[u8; 16]> for IpAddr { #[stable(feature = "ip_from_slice", since = "1.17.0")] impl From<[u16; 8]> for IpAddr { - /// Create an `IpAddr::V6` from an eight element 16-bit array. + /// Creates an `IpAddr::V6` from an eight element 16-bit array. /// /// # Examples /// diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 86ecb10edf2..c4b0cd0f17c 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -497,7 +497,7 @@ impl TcpStream { self.0.ttl() } - /// Get the value of the `SO_ERROR` option on this socket. + /// Gets the value of the `SO_ERROR` option on this socket. /// /// This will retrieve the stored error in the underlying socket, clearing /// the field in the process. This can be useful for checking errors between @@ -636,7 +636,7 @@ impl TcpListener { /// /// # Examples /// - /// Create a TCP listener bound to `127.0.0.1:80`: + /// Creates a TCP listener bound to `127.0.0.1:80`: /// /// ```no_run /// use std::net::TcpListener; @@ -644,7 +644,7 @@ impl TcpListener { /// let listener = TcpListener::bind("127.0.0.1:80").unwrap(); /// ``` /// - /// Create a TCP listener bound to `127.0.0.1:80`. If that fails, create a + /// Creates a TCP listener bound to `127.0.0.1:80`. If that fails, create a /// TCP listener bound to `127.0.0.1:443`: /// /// ```no_run @@ -811,7 +811,7 @@ impl TcpListener { self.0.only_v6() } - /// Get the value of the `SO_ERROR` option on this socket. + /// Gets the value of the `SO_ERROR` option on this socket. /// /// This will retrieve the stored error in the underlying socket, clearing /// the field in the process. This can be useful for checking errors between diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 83459946ba6..d49871ce7bd 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -69,7 +69,7 @@ impl UdpSocket { /// /// # Examples /// - /// Create a UDP socket bound to `127.0.0.1:3400`: + /// Creates a UDP socket bound to `127.0.0.1:3400`: /// /// ```no_run /// use std::net::UdpSocket; @@ -77,7 +77,7 @@ impl UdpSocket { /// let socket = UdpSocket::bind("127.0.0.1:3400").expect("couldn't bind to address"); /// ``` /// - /// Create a UDP socket bound to `127.0.0.1:3400`. If the socket cannot be + /// Creates a UDP socket bound to `127.0.0.1:3400`. If the socket cannot be /// bound to that address, create a UDP socket bound to `127.0.0.1:3401`: /// /// ```no_run @@ -158,7 +158,7 @@ impl UdpSocket { /// This will return an error when the IP version of the local socket /// does not match that returned from [`ToSocketAddrs`]. /// - /// See for more details. + /// See issue #34202 for more details. /// /// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html /// @@ -590,7 +590,7 @@ impl UdpSocket { self.0.leave_multicast_v6(multiaddr, interface) } - /// Get the value of the `SO_ERROR` option on this socket. + /// Gets the value of the `SO_ERROR` option on this socket. /// /// This will retrieve the stored error in the underlying socket, clearing /// the field in the process. This can be useful for checking errors between @@ -627,7 +627,7 @@ impl UdpSocket { /// /// # Examples /// - /// Create a UDP socket bound to `127.0.0.1:3400` and connect the socket to + /// Creates a UDP socket bound to `127.0.0.1:3400` and connect the socket to /// `127.0.0.1:8080`: /// /// ```no_run @@ -756,7 +756,7 @@ impl UdpSocket { /// /// # Examples /// - /// Create a UDP socket bound to `127.0.0.1:7878` and read bytes in + /// Creates a UDP socket bound to `127.0.0.1:7878` and read bytes in /// nonblocking mode: /// /// ```no_run diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 5c7bff70a0d..0f1d627fa1e 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -2393,7 +2393,7 @@ impl Path { fs::read_dir(self) } - /// Returns whether the path points at an existing entity. + /// Returns `true` if the path points at an existing entity. /// /// This function will traverse symbolic links to query information about the /// destination file. In case of broken symbolic links this will return `false`. @@ -2419,7 +2419,7 @@ impl Path { fs::metadata(self).is_ok() } - /// Returns whether the path exists on disk and is pointing at a regular file. + /// Returns `true` if the path exists on disk and is pointing at a regular file. /// /// This function will traverse symbolic links to query information about the /// destination file. In case of broken symbolic links this will return `false`. @@ -2448,7 +2448,7 @@ impl Path { fs::metadata(self).map(|m| m.is_file()).unwrap_or(false) } - /// Returns whether the path exists on disk and is pointing at a directory. + /// Returns `true` if the path exists on disk and is pointing at a directory. /// /// This function will traverse symbolic links to query information about the /// destination file. In case of broken symbolic links this will return `false`. diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index b0c0a8949db..6bb7f28efeb 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -126,7 +126,7 @@ mod prim_bool { } /// /// ```ignore (string-from-str-error-type-is-not-never-yet) /// #[feature(exhaustive_patterns)] -/// // NOTE: This does not work today! +/// // NOTE: this does not work today! /// let Ok(s) = String::from_str("hello"); /// ``` /// diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 1263ef82e48..a2ef85016d8 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -427,7 +427,7 @@ impl Command { /// The search path to be used may be controlled by setting the /// `PATH` environment variable on the Command, /// but this has some implementation limitations on Windows - /// (see ). + /// (see issue #37519). /// /// # Examples /// @@ -445,7 +445,7 @@ impl Command { Command { inner: imp::Command::new(program.as_ref()) } } - /// Add an argument to pass to the program. + /// Adds an argument to pass to the program. /// /// Only one argument can be passed per use. So instead of: /// @@ -487,7 +487,7 @@ impl Command { self } - /// Add multiple arguments to pass to the program. + /// Adds multiple arguments to pass to the program. /// /// To pass a single argument see [`arg`]. /// @@ -540,7 +540,7 @@ impl Command { self } - /// Add or update multiple environment variable mappings. + /// Adds or updates multiple environment variable mappings. /// /// # Examples /// @@ -1287,7 +1287,7 @@ impl Child { /// /// let mut command = Command::new("ls"); /// if let Ok(child) = command.spawn() { - /// println!("Child's id is {}", child.id()); + /// println!("Child's ID is {}", child.id()); /// } else { /// println!("ls command didn't start"); /// } @@ -1332,7 +1332,7 @@ impl Child { /// /// This function will not block the calling thread and will only /// check to see if the child process has exited or not. If the child has - /// exited then on Unix the process id is reaped. This function is + /// exited then on Unix the process ID is reaped. This function is /// guaranteed to repeatedly return a successful exit status so long as the /// child has already exited. /// @@ -1979,7 +1979,7 @@ mod tests { } } - /// Test that process creation flags work by debugging a process. + /// Tests that process creation flags work by debugging a process. /// Other creation flags make it hard or impossible to detect /// behavioral changes in the process. #[test] diff --git a/src/libstd/sync/barrier.rs b/src/libstd/sync/barrier.rs index f248c721e9a..bc2e14d436a 100644 --- a/src/libstd/sync/barrier.rs +++ b/src/libstd/sync/barrier.rs @@ -159,7 +159,7 @@ impl fmt::Debug for BarrierWaitResult { } impl BarrierWaitResult { - /// Returns whether this thread from [`wait`] is the "leader thread". + /// Returns `true` if this thread from [`wait`] is the "leader thread". /// /// Only one thread will have `true` returned from their result, all other /// threads will have `false` returned. diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 3b147e059a0..036aff090ea 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -17,7 +17,7 @@ use time::{Duration, Instant}; pub struct WaitTimeoutResult(bool); impl WaitTimeoutResult { - /// Returns whether the wait was known to have timed out. + /// Returns `true` if the wait was known to have timed out. /// /// # Examples /// diff --git a/src/libstd/sync/mpsc/blocking.rs b/src/libstd/sync/mpsc/blocking.rs index ae5a18adbb3..eaf09a16756 100644 --- a/src/libstd/sync/mpsc/blocking.rs +++ b/src/libstd/sync/mpsc/blocking.rs @@ -50,14 +50,14 @@ impl SignalToken { wake } - /// Convert to an unsafe usize value. Useful for storing in a pipe's state + /// Converts to an unsafe usize value. Useful for storing in a pipe's state /// flag. #[inline] pub unsafe fn cast_to_usize(self) -> usize { mem::transmute(self.inner) } - /// Convert from an unsafe usize value. Useful for retrieving a pipe's state + /// Converts from an unsafe usize value. Useful for retrieving a pipe's state /// flag. #[inline] pub unsafe fn cast_from_usize(signal_ptr: usize) -> SignalToken { @@ -72,7 +72,7 @@ impl WaitToken { } } - /// Returns true if we wake up normally, false otherwise. + /// Returns `true` if we wake up normally. pub fn wait_max_until(self, end: Instant) -> bool { while !self.inner.woken.load(Ordering::SeqCst) { let now = Instant::now(); diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 472df01fee3..bfde50f79ff 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -148,7 +148,7 @@ impl Select { } /// Waits for an event on this receiver set. The returned value is *not* an - /// index, but rather an id. This id can be queried against any active + /// index, but rather an ID. This ID can be queried against any active /// `Handle` structures (each one has an `id` method). The handle with /// the matching `id` will have some sort of event available on it. The /// event could either be that data is available or the corresponding @@ -251,7 +251,7 @@ impl Select { } impl<'rx, T: Send> Handle<'rx, T> { - /// Retrieves the id of this handle. + /// Retrieves the ID of this handle. #[inline] pub fn id(&self) -> usize { self.id } diff --git a/src/libstd/sync/mpsc/shared.rs b/src/libstd/sync/mpsc/shared.rs index af538b75b70..3da73ac0b82 100644 --- a/src/libstd/sync/mpsc/shared.rs +++ b/src/libstd/sync/mpsc/shared.rs @@ -1,4 +1,4 @@ -/// Shared channels +/// Shared channels. /// /// This is the flavor of channels which are not necessarily optimized for any /// particular use case, but are the most general in how they are used. Shared diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 59829db23cb..340dca7ce73 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -335,7 +335,7 @@ impl Mutex { /// Returns a mutable reference to the underlying data. /// /// Since this call borrows the `Mutex` mutably, no actual locking needs to - /// take place---the mutable borrow statically guarantees no locks exist. + /// take place -- the mutable borrow statically guarantees no locks exist. /// /// # Errors /// diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index fcab2ffe144..656389789d7 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -228,7 +228,7 @@ impl Once { /// result in an immediate panic. If `f` panics, the `Once` will remain /// in a poison state. If `f` does _not_ panic, the `Once` will no /// longer be in a poison state and all future calls to `call_once` or - /// `call_one_force` will no-op. + /// `call_one_force` will be no-ops. /// /// The closure `f` is yielded a [`OnceState`] structure which can be used /// to query the poison status of the `Once`. @@ -279,7 +279,7 @@ impl Once { }); } - /// Returns true if some `call_once` call has completed + /// Returns `true` if some `call_once` call has completed /// successfully. Specifically, `is_completed` will return false in /// the following situations: /// * `call_once` was not called at all, @@ -465,7 +465,7 @@ impl<'a> Drop for Finish<'a> { } impl OnceState { - /// Returns whether the associated [`Once`] was poisoned prior to the + /// Returns `true` if the associated [`Once`] was poisoned prior to the /// invocation of the closure passed to [`call_once_force`]. /// /// [`call_once_force`]: struct.Once.html#method.call_once_force diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 2b3bcb97d59..730362e2ac8 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -384,7 +384,7 @@ impl RwLock { /// Returns a mutable reference to the underlying data. /// /// Since this call borrows the `RwLock` mutably, no actual locking needs to - /// take place---the mutable borrow statically guarantees no locks exist. + /// take place -- the mutable borrow statically guarantees no locks exist. /// /// # Errors /// diff --git a/src/libstd/sys/cloudabi/abi/cloudabi.rs b/src/libstd/sys/cloudabi/abi/cloudabi.rs index 0bf8c2d5998..83d45b3547b 100644 --- a/src/libstd/sys/cloudabi/abi/cloudabi.rs +++ b/src/libstd/sys/cloudabi/abi/cloudabi.rs @@ -673,11 +673,11 @@ bitflags! { /// Methods of synchronizing memory with physical storage. #[repr(C)] pub struct msflags: u8 { - /// Perform asynchronous writes. + /// Performs asynchronous writes. const ASYNC = 0x01; - /// Invalidate cached data. + /// Invalidates cached data. const INVALIDATE = 0x02; - /// Perform synchronous writes. + /// Performs synchronous writes. const SYNC = 0x04; } } @@ -1750,11 +1750,9 @@ fn tcb_layout_test_64() { /// Entry point for additionally created threads. /// -/// **tid**: -/// Thread ID of the current thread. +/// `tid`: thread ID of the current thread. /// -/// **aux**: -/// Copy of the value stored in +/// `aux`: copy of the value stored in /// [`threadattr.argument`](struct.threadattr.html#structfield.argument). pub type threadentry = unsafe extern "C" fn( tid: tid, @@ -2590,7 +2588,7 @@ pub unsafe fn mem_map(addr_: *mut (), len_: usize, prot_: mprot, flags_: mflags, cloudabi_sys_mem_map(addr_, len_, prot_, flags_, fd_, off_, mem_) } -/// Change the protection of a memory mapping. +/// Changes the protection of a memory mapping. /// /// ## Parameters /// @@ -2604,7 +2602,7 @@ pub unsafe fn mem_protect(mapping_: &mut [u8], prot_: mprot) -> errno { cloudabi_sys_mem_protect(mapping_.as_mut_ptr() as *mut (), mapping_.len(), prot_) } -/// Synchronize a region of memory with its physical storage. +/// Synchronizes a region of memory with its physical storage. /// /// ## Parameters /// diff --git a/src/libstd/sys/mod.rs b/src/libstd/sys/mod.rs index 99ef74179c2..0a56f4fad6d 100644 --- a/src/libstd/sys/mod.rs +++ b/src/libstd/sys/mod.rs @@ -1,4 +1,4 @@ -//! Platform-dependent platform abstraction +//! Platform-dependent platform abstraction. //! //! The `std::sys` module is the abstracted interface through which //! `std` talks to the underlying operating system. It has different diff --git a/src/libstd/sys/redox/ext/fs.rs b/src/libstd/sys/redox/ext/fs.rs index 76fea656d13..8b81273f201 100644 --- a/src/libstd/sys/redox/ext/fs.rs +++ b/src/libstd/sys/redox/ext/fs.rs @@ -117,7 +117,7 @@ pub trait OpenOptionsExt { #[stable(feature = "fs_ext", since = "1.1.0")] fn mode(&mut self, mode: u32) -> &mut Self; - /// Pass custom flags to the `flags` argument of `open`. + /// Passes custom flags to the `flags` argument of `open`. /// /// The bits that define the access mode are masked out with `O_ACCMODE`, to /// ensure they do not interfere with the access mode set by Rusts options. diff --git a/src/libstd/sys/redox/ext/net.rs b/src/libstd/sys/redox/ext/net.rs index 76c68829b7f..7411b8e068f 100644 --- a/src/libstd/sys/redox/ext/net.rs +++ b/src/libstd/sys/redox/ext/net.rs @@ -60,7 +60,7 @@ impl SocketAddr { None } - /// Returns true if and only if the address is unnamed. + /// Returns `true` if the address is unnamed. /// /// # Examples /// @@ -374,7 +374,7 @@ impl UnixStream { /// ``` /// /// # Platform specific - /// On Redox this always returns None. + /// On Redox this always returns `None`. #[stable(feature = "unix_socket_redox", since = "1.29")] pub fn take_error(&self) -> io::Result> { Ok(None) @@ -635,7 +635,7 @@ impl UnixListener { /// ``` /// /// # Platform specific - /// On Redox this always returns None. + /// On Redox this always returns `None`. #[stable(feature = "unix_socket_redox", since = "1.29")] pub fn take_error(&self) -> io::Result> { Ok(None) diff --git a/src/libstd/sys/redox/ext/process.rs b/src/libstd/sys/redox/ext/process.rs index 941fba8755b..1dcc1169510 100644 --- a/src/libstd/sys/redox/ext/process.rs +++ b/src/libstd/sys/redox/ext/process.rs @@ -13,13 +13,13 @@ use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner}; /// [`process::Command`]: ../../../../std/process/struct.Command.html #[stable(feature = "rust1", since = "1.0.0")] pub trait CommandExt { - /// Sets the child process's user id. This translates to a + /// Sets the child process's user ID. This translates to a /// `setuid` call in the child process. Failure in the `setuid` /// call will cause the spawn to fail. #[stable(feature = "rust1", since = "1.0.0")] fn uid(&mut self, id: u32) -> &mut process::Command; - /// Similar to `uid`, but sets the group id of the child process. This has + /// Similar to `uid`, but sets the group ID of the child process. This has /// the same semantics as the `uid` field. #[stable(feature = "rust1", since = "1.0.0")] fn gid(&mut self, id: u32) -> &mut process::Command; diff --git a/src/libstd/sys/redox/mutex.rs b/src/libstd/sys/redox/mutex.rs index 42424da858f..bf39cc48591 100644 --- a/src/libstd/sys/redox/mutex.rs +++ b/src/libstd/sys/redox/mutex.rs @@ -50,7 +50,7 @@ pub struct Mutex { } impl Mutex { - /// Create a new mutex. + /// Creates a new mutex. pub const fn new() -> Self { Mutex { lock: UnsafeCell::new(0), diff --git a/src/libstd/sys/redox/process.rs b/src/libstd/sys/redox/process.rs index 4199ab98cf1..9e23c537f22 100644 --- a/src/libstd/sys/redox/process.rs +++ b/src/libstd/sys/redox/process.rs @@ -561,7 +561,7 @@ impl ExitCode { } } -/// The unique id of the process (this should never be negative). +/// The unique ID of the process (this should never be negative). pub struct Process { pid: usize, status: Option, diff --git a/src/libstd/sys/redox/syscall/call.rs b/src/libstd/sys/redox/syscall/call.rs index b9e2b476cec..b9abb48a8d3 100644 --- a/src/libstd/sys/redox/syscall/call.rs +++ b/src/libstd/sys/redox/syscall/call.rs @@ -25,7 +25,7 @@ pub unsafe fn brk(addr: usize) -> Result { syscall1(SYS_BRK, addr) } -/// Change the process's working directory +/// Changes the process's working directory. /// /// This function will attempt to set the process's working directory to `path`, which can be /// either a relative, scheme relative, or absolute path. @@ -47,90 +47,90 @@ pub fn chmod>(path: T, mode: usize) -> Result { unsafe { syscall3(SYS_CHMOD, path.as_ref().as_ptr() as usize, path.as_ref().len(), mode) } } -/// Produce a fork of the current process, or a new process thread +/// Produces a fork of the current process, or a new process thread. pub unsafe fn clone(flags: usize) -> Result { syscall1_clobber(SYS_CLONE, flags) } -/// Close a file +/// Closes a file. pub fn close(fd: usize) -> Result { unsafe { syscall1(SYS_CLOSE, fd) } } -/// Get the current system time +/// Gets the current system time. pub fn clock_gettime(clock: usize, tp: &mut TimeSpec) -> Result { unsafe { syscall2(SYS_CLOCK_GETTIME, clock, tp as *mut TimeSpec as usize) } } -/// Copy and transform a file descriptor +/// Copies and transforms a file descriptor. pub fn dup(fd: usize, buf: &[u8]) -> Result { unsafe { syscall3(SYS_DUP, fd, buf.as_ptr() as usize, buf.len()) } } -/// Copy and transform a file descriptor +/// Copies and transforms a file descriptor. pub fn dup2(fd: usize, newfd: usize, buf: &[u8]) -> Result { unsafe { syscall4(SYS_DUP2, fd, newfd, buf.as_ptr() as usize, buf.len()) } } -/// Exit the current process +/// Exits the current process. pub fn exit(status: usize) -> Result { unsafe { syscall1(SYS_EXIT, status) } } -/// Change file permissions +/// Changes file permissions. pub fn fchmod(fd: usize, mode: u16) -> Result { unsafe { syscall2(SYS_FCHMOD, fd, mode as usize) } } -/// Change file ownership +/// Changes file ownership. pub fn fchown(fd: usize, uid: u32, gid: u32) -> Result { unsafe { syscall3(SYS_FCHOWN, fd, uid as usize, gid as usize) } } -/// Change file descriptor flags +/// Changes file descriptor flags. pub fn fcntl(fd: usize, cmd: usize, arg: usize) -> Result { unsafe { syscall3(SYS_FCNTL, fd, cmd, arg) } } -/// Replace the current process with a new executable +/// Replaces the current process with a new executable. pub fn fexec(fd: usize, args: &[[usize; 2]], vars: &[[usize; 2]]) -> Result { unsafe { syscall5(SYS_FEXEC, fd, args.as_ptr() as usize, args.len(), vars.as_ptr() as usize, vars.len()) } } -/// Map a file into memory +/// Maps a file into memory. pub unsafe fn fmap(fd: usize, offset: usize, size: usize) -> Result { syscall3(SYS_FMAP, fd, offset, size) } -/// Unmap a memory-mapped file +/// Unmaps a memory-mapped file. pub unsafe fn funmap(addr: usize) -> Result { syscall1(SYS_FUNMAP, addr) } -/// Retrieve the canonical path of a file +/// Retrieves the canonical path of a file. pub fn fpath(fd: usize, buf: &mut [u8]) -> Result { unsafe { syscall3(SYS_FPATH, fd, buf.as_mut_ptr() as usize, buf.len()) } } -/// Rename a file +/// Renames a file. pub fn frename>(fd: usize, path: T) -> Result { unsafe { syscall3(SYS_FRENAME, fd, path.as_ref().as_ptr() as usize, path.as_ref().len()) } } -/// Get metadata about a file +/// Gets metadata about a file. pub fn fstat(fd: usize, stat: &mut Stat) -> Result { unsafe { syscall3(SYS_FSTAT, fd, stat as *mut Stat as usize, mem::size_of::()) } } -/// Get metadata about a filesystem +/// Gets metadata about a filesystem. pub fn fstatvfs(fd: usize, stat: &mut StatVfs) -> Result { unsafe { syscall3(SYS_FSTATVFS, fd, stat as *mut StatVfs as usize, mem::size_of::()) } } -/// Sync a file descriptor to its underlying medium +/// Syncs a file descriptor to its underlying medium. pub fn fsync(fd: usize) -> Result { unsafe { syscall1(SYS_FSYNC, fd) } } @@ -152,113 +152,113 @@ pub unsafe fn futex(addr: *mut i32, op: usize, val: i32, val2: usize, addr2: *mu syscall5(SYS_FUTEX, addr as usize, op, (val as isize) as usize, val2, addr2 as usize) } -/// Get the current working directory +/// Gets the current working directory. pub fn getcwd(buf: &mut [u8]) -> Result { unsafe { syscall2(SYS_GETCWD, buf.as_mut_ptr() as usize, buf.len()) } } -/// Get the effective group ID +/// Gets the effective group ID. pub fn getegid() -> Result { unsafe { syscall0(SYS_GETEGID) } } -/// Get the effective namespace +/// Gets the effective namespace. pub fn getens() -> Result { unsafe { syscall0(SYS_GETENS) } } -/// Get the effective user ID +/// Gets the effective user ID. pub fn geteuid() -> Result { unsafe { syscall0(SYS_GETEUID) } } -/// Get the current group ID +/// Gets the current group ID. pub fn getgid() -> Result { unsafe { syscall0(SYS_GETGID) } } -/// Get the current namespace +/// Gets the current namespace. pub fn getns() -> Result { unsafe { syscall0(SYS_GETNS) } } -/// Get the current process ID +/// Gets the current process ID. pub fn getpid() -> Result { unsafe { syscall0(SYS_GETPID) } } -/// Get the process group ID +/// Gets the process group ID. pub fn getpgid(pid: usize) -> Result { unsafe { syscall1(SYS_GETPGID, pid) } } -/// Get the parent process ID +/// Gets the parent process ID. pub fn getppid() -> Result { unsafe { syscall0(SYS_GETPPID) } } -/// Get the current user ID +/// Gets the current user ID. pub fn getuid() -> Result { unsafe { syscall0(SYS_GETUID) } } -/// Set the I/O privilege level +/// Sets the I/O privilege level pub unsafe fn iopl(level: usize) -> Result { syscall1(SYS_IOPL, level) } -/// Send a signal `sig` to the process identified by `pid` +/// Sends a signal `sig` to the process identified by `pid`. pub fn kill(pid: usize, sig: usize) -> Result { unsafe { syscall2(SYS_KILL, pid, sig) } } -/// Create a link to a file +/// Creates a link to a file. pub unsafe fn link(old: *const u8, new: *const u8) -> Result { syscall2(SYS_LINK, old as usize, new as usize) } -/// Seek to `offset` bytes in a file descriptor +/// Seeks to `offset` bytes in a file descriptor. pub fn lseek(fd: usize, offset: isize, whence: usize) -> Result { unsafe { syscall3(SYS_LSEEK, fd, offset as usize, whence) } } -/// Make a new scheme namespace +/// Makes a new scheme namespace. pub fn mkns(schemes: &[[usize; 2]]) -> Result { unsafe { syscall2(SYS_MKNS, schemes.as_ptr() as usize, schemes.len()) } } -/// Sleep for the time specified in `req` +/// Sleeps for the time specified in `req`. pub fn nanosleep(req: &TimeSpec, rem: &mut TimeSpec) -> Result { unsafe { syscall2(SYS_NANOSLEEP, req as *const TimeSpec as usize, rem as *mut TimeSpec as usize) } } -/// Open a file +/// Opens a file. pub fn open>(path: T, flags: usize) -> Result { unsafe { syscall3(SYS_OPEN, path.as_ref().as_ptr() as usize, path.as_ref().len(), flags) } } -/// Allocate pages, linearly in physical memory +/// Allocates pages, linearly in physical memory. pub unsafe fn physalloc(size: usize) -> Result { syscall1(SYS_PHYSALLOC, size) } -/// Free physically allocated pages +/// Frees physically allocated pages. pub unsafe fn physfree(physical_address: usize, size: usize) -> Result { syscall2(SYS_PHYSFREE, physical_address, size) } -/// Map physical memory to virtual memory +/// Maps physical memory to virtual memory. pub unsafe fn physmap(physical_address: usize, size: usize, flags: usize) -> Result { syscall3(SYS_PHYSMAP, physical_address, size, flags) } -/// Unmap previously mapped physical memory +/// Unmaps previously mapped physical memory. pub unsafe fn physunmap(virtual_address: usize) -> Result { syscall1(SYS_PHYSUNMAP, virtual_address) } -/// Create a pair of file descriptors referencing the read and write ends of a pipe +/// Creates a pair of file descriptors referencing the read and write ends of a pipe. pub fn pipe2(fds: &mut [usize; 2], flags: usize) -> Result { unsafe { syscall2(SYS_PIPE2, fds.as_ptr() as usize, flags) } } @@ -268,32 +268,32 @@ pub fn read(fd: usize, buf: &mut [u8]) -> Result { unsafe { syscall3(SYS_READ, fd, buf.as_mut_ptr() as usize, buf.len()) } } -/// Remove a directory +/// Removes a directory. pub fn rmdir>(path: T) -> Result { unsafe { syscall2(SYS_RMDIR, path.as_ref().as_ptr() as usize, path.as_ref().len()) } } -/// Set the process group ID +/// Sets the process group ID. pub fn setpgid(pid: usize, pgid: usize) -> Result { unsafe { syscall2(SYS_SETPGID, pid, pgid) } } -/// Set the current process group IDs +/// Sets the current process group IDs. pub fn setregid(rgid: usize, egid: usize) -> Result { unsafe { syscall2(SYS_SETREGID, rgid, egid) } } -/// Make a new scheme namespace +/// Makes a new scheme namespace. pub fn setrens(rns: usize, ens: usize) -> Result { unsafe { syscall2(SYS_SETRENS, rns, ens) } } -/// Set the current process user IDs +/// Sets the current process user IDs. pub fn setreuid(ruid: usize, euid: usize) -> Result { unsafe { syscall2(SYS_SETREUID, ruid, euid) } } -/// Set up a signal handler +/// Sets up a signal handler. pub fn sigaction(sig: usize, act: Option<&SigAction>, oldact: Option<&mut SigAction>) -> Result { unsafe { syscall4(SYS_SIGACTION, sig, @@ -302,27 +302,27 @@ pub fn sigaction(sig: usize, act: Option<&SigAction>, oldact: Option<&mut SigAct restorer as usize) } } -// Return from signal handler +/// Returns from signal handler. pub fn sigreturn() -> Result { unsafe { syscall0(SYS_SIGRETURN) } } -/// Remove a file +/// Removes a file. pub fn unlink>(path: T) -> Result { unsafe { syscall2(SYS_UNLINK, path.as_ref().as_ptr() as usize, path.as_ref().len()) } } -/// Convert a virtual address to a physical one +/// Converts a virtual address to a physical one. pub unsafe fn virttophys(virtual_address: usize) -> Result { syscall1(SYS_VIRTTOPHYS, virtual_address) } -/// Check if a child process has exited or received a signal +/// Checks if a child process has exited or received a signal. pub fn waitpid(pid: usize, status: &mut usize, options: usize) -> Result { unsafe { syscall3(SYS_WAITPID, pid, status as *mut usize as usize, options) } } -/// Write a buffer to a file descriptor +/// Writes a buffer to a file descriptor. /// /// The kernel will attempt to write the bytes in `buf` to the file descriptor `fd`, returning /// either an `Err`, explained below, or `Ok(count)` where `count` is the number of bytes which @@ -340,7 +340,7 @@ pub fn write(fd: usize, buf: &[u8]) -> Result { unsafe { syscall3(SYS_WRITE, fd, buf.as_ptr() as usize, buf.len()) } } -/// Yield the process's time slice to the kernel +/// Yields the process's time slice to the kernel. /// /// This function will return Ok(0) on success pub fn sched_yield() -> Result { diff --git a/src/libstd/sys/redox/syscall/flag.rs b/src/libstd/sys/redox/syscall/flag.rs index a41bc6d4a8b..5820f1ad03a 100644 --- a/src/libstd/sys/redox/syscall/flag.rs +++ b/src/libstd/sys/redox/syscall/flag.rs @@ -107,42 +107,42 @@ pub const WNOHANG: usize = 0x01; pub const WUNTRACED: usize = 0x02; pub const WCONTINUED: usize = 0x08; -/// True if status indicates the child is stopped. +/// Returns `true` if status indicates the child is stopped. pub fn wifstopped(status: usize) -> bool { (status & 0xff) == 0x7f } -/// If wifstopped(status), the signal that stopped the child. +/// If wifstopped(status), returns the signal that stopped the child. pub fn wstopsig(status: usize) -> usize { (status >> 8) & 0xff } -/// True if status indicates the child continued after a stop. +/// Returns `true` if status indicates the child continued after a stop. pub fn wifcontinued(status: usize) -> bool { status == 0xffff } -/// True if STATUS indicates termination by a signal. +/// Returns `true` if status indicates termination by a signal. pub fn wifsignaled(status: usize) -> bool { ((status & 0x7f) + 1) as i8 >= 2 } -/// If wifsignaled(status), the terminating signal. +/// If wifsignaled(status), returns the terminating signal. pub fn wtermsig(status: usize) -> usize { status & 0x7f } -/// True if status indicates normal termination. +/// Returns `true` if status indicates normal termination. pub fn wifexited(status: usize) -> bool { wtermsig(status) == 0 } -/// If wifexited(status), the exit status. +/// If wifexited(status), returns the exit status. pub fn wexitstatus(status: usize) -> usize { (status >> 8) & 0xff } -/// True if status indicates a core dump was created. +/// Returns `true` if status indicates a core dump was created. pub fn wcoredump(status: usize) -> bool { (status & 0x80) != 0 } diff --git a/src/libstd/sys/sgx/abi/thread.rs b/src/libstd/sys/sgx/abi/thread.rs index 588fbcd9d43..86fe09d0035 100644 --- a/src/libstd/sys/sgx/abi/thread.rs +++ b/src/libstd/sys/sgx/abi/thread.rs @@ -1,6 +1,6 @@ use fortanix_sgx_abi::Tcs; -/// Get the ID for the current thread. The ID is guaranteed to be unique among +/// Gets the ID for the current thread. The ID is guaranteed to be unique among /// all currently running threads in the enclave, and it is guaranteed to be /// constant for the lifetime of the thread. More specifically for SGX, there /// is a one-to-one correspondence of the ID to the address of the TCS. diff --git a/src/libstd/sys/sgx/abi/tls.rs b/src/libstd/sys/sgx/abi/tls.rs index b8e09d58deb..e1fc3696845 100644 --- a/src/libstd/sys/sgx/abi/tls.rs +++ b/src/libstd/sys/sgx/abi/tls.rs @@ -182,7 +182,7 @@ mod sync_bitset { self.0[hi].fetch_and(!lo, Ordering::Relaxed); } - /// Set any unset bit. Not atomic. Returns `None` if all bits were + /// Sets any unset bit. Not atomic. Returns `None` if all bits were /// observed to be set. pub fn set(&self) -> Option { 'elems: for (idx, elem) in self.0.iter().enumerate() { diff --git a/src/libstd/sys/sgx/abi/usercalls/alloc.rs b/src/libstd/sys/sgx/abi/usercalls/alloc.rs index 2efbaa9b148..0ccbbbc6501 100644 --- a/src/libstd/sys/sgx/abi/usercalls/alloc.rs +++ b/src/libstd/sys/sgx/abi/usercalls/alloc.rs @@ -63,44 +63,49 @@ pub unsafe trait UserSafe { /// Construct a pointer to `Self` given a memory range in user space. /// - /// NB. This takes a size, not a length! + /// N.B., this takes a size, not a length! /// /// # Safety + /// /// The caller must ensure the memory range is in user memory, is the /// correct size and is correctly aligned and points to the right type. unsafe fn from_raw_sized_unchecked(ptr: *mut u8, size: usize) -> *mut Self; /// Construct a pointer to `Self` given a memory range. /// - /// NB. This takes a size, not a length! + /// N.B., this takes a size, not a length! /// /// # Safety + /// /// The caller must ensure the memory range points to the correct type. /// /// # Panics + /// /// This function panics if: /// - /// * The pointer is not aligned - /// * The pointer is null - /// * The pointed-to range is not in user memory + /// * the pointer is not aligned. + /// * the pointer is null. + /// * the pointed-to range is not in user memory. unsafe fn from_raw_sized(ptr: *mut u8, size: usize) -> NonNull { let ret = Self::from_raw_sized_unchecked(ptr, size); Self::check_ptr(ret); NonNull::new_unchecked(ret as _) } - /// Check if a pointer may point to Self in user memory. + /// Checks if a pointer may point to `Self` in user memory. /// /// # Safety + /// /// The caller must ensure the memory range points to the correct type and /// length (if this is a slice). /// /// # Panics + /// /// This function panics if: /// - /// * The pointer is not aligned - /// * The pointer is null - /// * The pointed-to range is not in user memory + /// * the pointer is not aligned. + /// * the pointer is null. + /// * the pointed-to range is not in user memory. unsafe fn check_ptr(ptr: *const Self) { let is_aligned = |p| -> bool { 0 == (p as usize) & (Self::align_of() - 1) @@ -188,7 +193,7 @@ impl User where T: UserSafe { } } - /// Copy `val` into freshly allocated space in user memory. + /// Copies `val` into freshly allocated space in user memory. pub fn new_from_enclave(val: &T) -> Self { unsafe { let ret = Self::new_uninit_bytes(mem::size_of_val(val)); @@ -201,7 +206,7 @@ impl User where T: UserSafe { } } - /// Create an owned `User` from a raw pointer. + /// Creates an owned `User` from a raw pointer. /// /// # Safety /// The caller must ensure `ptr` points to `T`, is freeable with the `free` @@ -218,7 +223,7 @@ impl User where T: UserSafe { User(NonNull::new_userref(ptr)) } - /// Convert this value into a raw pointer. The value will no longer be + /// Converts this value into a raw pointer. The value will no longer be /// automatically freed. pub fn into_raw(self) -> *mut T { let ret = self.0; @@ -242,7 +247,7 @@ impl User<[T]> where [T]: UserSafe { Self::new_uninit_bytes(n * mem::size_of::()) } - /// Create an owned `User<[T]>` from a raw thin pointer and a slice length. + /// Creates an owned `User<[T]>` from a raw thin pointer and a slice length. /// /// # Safety /// The caller must ensure `ptr` points to `len` elements of `T`, is @@ -262,7 +267,7 @@ impl User<[T]> where [T]: UserSafe { #[unstable(feature = "sgx_platform", issue = "56975")] impl UserRef where T: UserSafe { - /// Create a `&UserRef<[T]>` from a raw pointer. + /// Creates a `&UserRef<[T]>` from a raw pointer. /// /// # Safety /// The caller must ensure `ptr` points to `T`. @@ -278,7 +283,7 @@ impl UserRef where T: UserSafe { &*(ptr as *const Self) } - /// Create a `&mut UserRef<[T]>` from a raw pointer. See the struct + /// Creates a `&mut UserRef<[T]>` from a raw pointer. See the struct /// documentation for the nuances regarding a `&mut UserRef`. /// /// # Safety @@ -295,7 +300,7 @@ impl UserRef where T: UserSafe { &mut*(ptr as *mut Self) } - /// Copy `val` into user memory. + /// Copies `val` into user memory. /// /// # Panics /// This function panics if the destination doesn't have the same size as @@ -311,7 +316,7 @@ impl UserRef where T: UserSafe { } } - /// Copy the value from user memory and place it into `dest`. + /// Copies the value from user memory and place it into `dest`. /// /// # Panics /// This function panics if the destination doesn't have the same size as @@ -340,7 +345,7 @@ impl UserRef where T: UserSafe { #[unstable(feature = "sgx_platform", issue = "56975")] impl UserRef where T: UserSafe { - /// Copy the value from user memory into enclave memory. + /// Copies the value from user memory into enclave memory. pub fn to_enclave(&self) -> T { unsafe { ptr::read(self.0.get()) } } @@ -348,7 +353,7 @@ impl UserRef where T: UserSafe { #[unstable(feature = "sgx_platform", issue = "56975")] impl UserRef<[T]> where [T]: UserSafe { - /// Create a `&UserRef<[T]>` from a raw thin pointer and a slice length. + /// Creates a `&UserRef<[T]>` from a raw thin pointer and a slice length. /// /// # Safety /// The caller must ensure `ptr` points to `n` elements of `T`. @@ -363,7 +368,7 @@ impl UserRef<[T]> where [T]: UserSafe { &*(<[T]>::from_raw_sized(ptr as _, len * mem::size_of::()).as_ptr() as *const Self) } - /// Create a `&mut UserRef<[T]>` from a raw thin pointer and a slice length. + /// Creates a `&mut UserRef<[T]>` from a raw thin pointer and a slice length. /// See the struct documentation for the nuances regarding a /// `&mut UserRef`. /// @@ -395,7 +400,7 @@ impl UserRef<[T]> where [T]: UserSafe { unsafe { (*self.0.get()).len() } } - /// Copy the value from user memory and place it into `dest`. Afterwards, + /// Copies the value from user memory and place it into `dest`. Afterwards, /// `dest` will contain exactly `self.len()` elements. /// /// # Panics @@ -411,7 +416,7 @@ impl UserRef<[T]> where [T]: UserSafe { } } - /// Copy the value from user memory into a vector in enclave memory. + /// Copies the value from user memory into a vector in enclave memory. pub fn to_enclave(&self) -> Vec { let mut ret = Vec::with_capacity(self.len()); self.copy_to_enclave_vec(&mut ret); @@ -526,7 +531,7 @@ impl> IndexMut for UserRef<[T]> where [T]: UserSafe, I: #[unstable(feature = "sgx_platform", issue = "56975")] impl UserRef { - /// Copy the user memory range pointed to by the user `ByteBuffer` to + /// Copies the user memory range pointed to by the user `ByteBuffer` to /// enclave memory. /// /// # Panics diff --git a/src/libstd/sys/sgx/abi/usercalls/raw.rs b/src/libstd/sys/sgx/abi/usercalls/raw.rs index 27f780ca224..004cf57602b 100644 --- a/src/libstd/sys/sgx/abi/usercalls/raw.rs +++ b/src/libstd/sys/sgx/abi/usercalls/raw.rs @@ -12,14 +12,16 @@ extern "C" { fn usercall(nr: u64, p1: u64, p2: u64, _ignore: u64, p3: u64, p4: u64) -> UsercallReturn; } -/// Perform the raw usercall operation as defined in the ABI calling convention. +/// Performs the raw usercall operation as defined in the ABI calling convention. /// /// # Safety +/// /// The caller must ensure to pass parameters appropriate for the usercall `nr` /// and to observe all requirements specified in the ABI. /// /// # Panics -/// Panics if `nr` is 0. +/// +/// Panics if `nr` is `0`. #[unstable(feature = "sgx_platform", issue = "56975")] pub unsafe fn do_usercall(nr: u64, p1: u64, p2: u64, p3: u64, p4: u64) -> (u64, u64) { if nr==0 { panic!("Invalid usercall number {}",nr) } diff --git a/src/libstd/sys/sgx/waitqueue.rs b/src/libstd/sys/sgx/waitqueue.rs index 51c00a1433e..aec643b3175 100644 --- a/src/libstd/sys/sgx/waitqueue.rs +++ b/src/libstd/sys/sgx/waitqueue.rs @@ -3,7 +3,7 @@ /// This queue is used to implement condition variable and mutexes. /// /// Users of this API are expected to use the `WaitVariable` type. Since -/// that type is not `Sync`, it needs to be protected by e.g. a `SpinMutex` to +/// that type is not `Sync`, it needs to be protected by e.g., a `SpinMutex` to /// allow shared access. /// /// Since userspace may send spurious wake-ups, the wakeup event state is @@ -136,7 +136,7 @@ impl WaitQueue { self.inner.is_empty() } - /// Add the calling thread to the WaitVariable's wait queue, then wait + /// Adds the calling thread to the `WaitVariable`'s wait queue, then wait /// until a wakeup event. /// /// This function does not return until this thread has been awoken. diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs index afeb756806f..abcce3ab829 100644 --- a/src/libstd/sys/unix/ext/fs.rs +++ b/src/libstd/sys/unix/ext/fs.rs @@ -684,7 +684,7 @@ impl MetadataExt for fs::Metadata { /// [`FileType`]: ../../../../std/fs/struct.FileType.html #[stable(feature = "file_type_ext", since = "1.5.0")] pub trait FileTypeExt { - /// Returns whether this file type is a block device. + /// Returns `true` if this file type is a block device. /// /// # Examples /// @@ -702,7 +702,7 @@ pub trait FileTypeExt { /// ``` #[stable(feature = "file_type_ext", since = "1.5.0")] fn is_block_device(&self) -> bool; - /// Returns whether this file type is a char device. + /// Returns `true` if this file type is a char device. /// /// # Examples /// @@ -720,7 +720,7 @@ pub trait FileTypeExt { /// ``` #[stable(feature = "file_type_ext", since = "1.5.0")] fn is_char_device(&self) -> bool; - /// Returns whether this file type is a fifo. + /// Returns `true` if this file type is a fifo. /// /// # Examples /// @@ -738,7 +738,7 @@ pub trait FileTypeExt { /// ``` #[stable(feature = "file_type_ext", since = "1.5.0")] fn is_fifo(&self) -> bool; - /// Returns whether this file type is a socket. + /// Returns `true` if this file type is a socket. /// /// # Examples /// diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index a3ae5943f60..acc064acfcd 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -134,7 +134,7 @@ impl SocketAddr { }) } - /// Returns true if and only if the address is unnamed. + /// Returns `true` if the address is unnamed. /// /// # Examples /// @@ -516,7 +516,7 @@ impl UnixStream { /// ``` /// /// # Platform specific - /// On Redox this always returns None. + /// On Redox this always returns `None`. #[stable(feature = "unix_socket", since = "1.10.0")] pub fn take_error(&self) -> io::Result> { self.0.take_error() @@ -841,7 +841,7 @@ impl UnixListener { /// ``` /// /// # Platform specific - /// On Redox this always returns None. + /// On Redox this always returns `None`. #[stable(feature = "unix_socket", since = "1.10.0")] pub fn take_error(&self) -> io::Result> { self.0.take_error() @@ -1047,7 +1047,7 @@ impl UnixDatagram { Ok(UnixDatagram(inner)) } - /// Create an unnamed pair of connected sockets. + /// Creates an unnamed pair of connected sockets. /// /// Returns two `UnixDatagrams`s which are connected to each other. /// diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs index 0282aaae909..2c5943fdac3 100644 --- a/src/libstd/sys/unix/ext/process.rs +++ b/src/libstd/sys/unix/ext/process.rs @@ -13,13 +13,13 @@ use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner}; /// [`process::Command`]: ../../../../std/process/struct.Command.html #[stable(feature = "rust1", since = "1.0.0")] pub trait CommandExt { - /// Sets the child process's user id. This translates to a + /// Sets the child process's user ID. This translates to a /// `setuid` call in the child process. Failure in the `setuid` /// call will cause the spawn to fail. #[stable(feature = "rust1", since = "1.0.0")] fn uid(&mut self, id: u32) -> &mut process::Command; - /// Similar to `uid`, but sets the group id of the child process. This has + /// Similar to `uid`, but sets the group ID of the child process. This has /// the same semantics as the `uid` field. #[stable(feature = "rust1", since = "1.0.0")] fn gid(&mut self, id: u32) -> &mut process::Command; diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index f0f8032b4b5..12d3e9b13b1 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -383,7 +383,7 @@ impl Command { // Processes //////////////////////////////////////////////////////////////////////////////// -/// The unique id of the process (this should never be negative). +/// The unique ID of the process (this should never be negative). pub struct Process { pid: pid_t, status: Option, diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs index 6342af46daf..89038da6295 100644 --- a/src/libstd/sys/windows/ext/fs.rs +++ b/src/libstd/sys/windows/ext/fs.rs @@ -441,10 +441,10 @@ impl MetadataExt for Metadata { /// [`FileType`]: ../../../../std/fs/struct.FileType.html #[unstable(feature = "windows_file_type_ext", issue = "0")] pub trait FileTypeExt { - /// Returns whether this file type is a symbolic link that is also a directory. + /// Returns `true` if this file type is a symbolic link that is also a directory. #[unstable(feature = "windows_file_type_ext", issue = "0")] fn is_symlink_dir(&self) -> bool; - /// Returns whether this file type is a symbolic link that is also a file. + /// Returns `true` if this file type is a symbolic link that is also a file. #[unstable(feature = "windows_file_type_ext", issue = "0")] fn is_symlink_file(&self) -> bool; } diff --git a/src/libstd/sys/windows/ext/io.rs b/src/libstd/sys/windows/ext/io.rs index 76143dee464..fbe0426ce5a 100644 --- a/src/libstd/sys/windows/ext/io.rs +++ b/src/libstd/sys/windows/ext/io.rs @@ -16,7 +16,7 @@ pub type RawHandle = raw::HANDLE; #[stable(feature = "rust1", since = "1.0.0")] pub type RawSocket = raw::SOCKET; -/// Extract raw handles. +/// Extracts raw handles. #[stable(feature = "rust1", since = "1.0.0")] pub trait AsRawHandle { /// Extracts the raw handle, without taking any ownership. @@ -98,7 +98,7 @@ impl IntoRawHandle for fs::File { } } -/// Extract raw sockets. +/// Extracts raw sockets. #[stable(feature = "rust1", since = "1.0.0")] pub trait AsRawSocket { /// Extracts the underlying raw socket from this object. @@ -106,7 +106,7 @@ pub trait AsRawSocket { fn as_raw_socket(&self) -> RawSocket; } -/// Create I/O objects from raw sockets. +/// Creates I/O objects from raw sockets. #[stable(feature = "from_raw_os", since = "1.1.0")] pub trait FromRawSocket { /// Creates a new I/O object from the given raw socket. diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 5f478827b43..7399dd41a41 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -1,4 +1,4 @@ -//! Implementation of `std::os` functionality for Windows +//! Implementation of `std::os` functionality for Windows. #![allow(nonstandard_style)] diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index 0d9195a5c97..d3b102268f6 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -282,7 +282,7 @@ impl<'a> AsyncPipe<'a> { /// Takes a parameter `wait` which indicates if this pipe is currently being /// read whether the function should block waiting for the read to complete. /// - /// Return values: + /// Returns values: /// /// * `true` - finished any pending read and the pipe is not at EOF (keep /// going) diff --git a/src/libstd/sys_common/backtrace.rs b/src/libstd/sys_common/backtrace.rs index 57f31cb726c..347244b0e0d 100644 --- a/src/libstd/sys_common/backtrace.rs +++ b/src/libstd/sys_common/backtrace.rs @@ -171,7 +171,7 @@ pub fn log_enabled() -> Option { val } -/// Print the symbol of the backtrace frame. +/// Prints the symbol of the backtrace frame. /// /// These output functions should now be used everywhere to ensure consistency. /// You may want to also use `output_fileline`. @@ -203,7 +203,7 @@ fn output(w: &mut dyn Write, idx: usize, frame: Frame, w.write_all(b"\n") } -/// Print the filename and line number of the backtrace frame. +/// Prints the filename and line number of the backtrace frame. /// /// See also `output`. #[allow(dead_code)] diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index 7f355fa7ec2..6d4594fe295 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -34,7 +34,7 @@ const UTF8_REPLACEMENT_CHARACTER: &str = "\u{FFFD}"; /// A Unicode code point: from U+0000 to U+10FFFF. /// -/// Compare with the `char` type, +/// Compares with the `char` type, /// which represents a Unicode scalar value: /// a code point that is not a surrogate (U+D800 to U+DFFF). #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy)] @@ -366,7 +366,7 @@ impl Wtf8Buf { } } -/// Create a new WTF-8 string from an iterator of code points. +/// Creates a new WTF-8 string from an iterator of code points. /// /// This replaces surrogate code point pairs with supplementary code points, /// like concatenating ill-formed UTF-16 strings effectively would. @@ -664,7 +664,7 @@ impl Wtf8 { } -/// Return a slice of the given string for the byte range [`begin`..`end`). +/// Returns a slice of the given string for the byte range [`begin`..`end`). /// /// # Panics /// @@ -686,7 +686,7 @@ impl ops::Index> for Wtf8 { } } -/// Return a slice of the given string from byte `begin` to its end. +/// Returns a slice of the given string from byte `begin` to its end. /// /// # Panics /// @@ -706,7 +706,7 @@ impl ops::Index> for Wtf8 { } } -/// Return a slice of the given string from its beginning to byte `end`. +/// Returns a slice of the given string from its beginning to byte `end`. /// /// # Panics /// diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index ae046f6d614..e753a74b925 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -328,7 +328,7 @@ pub fn test_main_static(tests: &[&TestDescAndFn]) { } /// Invoked when unit tests terminate. Should panic if the unit -/// test is considered a failure. By default, invokes `report()` +/// Tests is considered a failure. By default, invokes `report()` /// and checks for a `0` result. pub fn assert_test_result(result: T) { let code = result.report(); -- cgit 1.4.1-3-g733a5 From d3c212c5527f901fcb44d59d031695248762c340 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sun, 3 Feb 2019 12:55:00 +0100 Subject: Require a list of features to allow in `allow_internal_unstable` --- src/liballoc/macros.rs | 3 +- src/libcore/macros.rs | 6 ++-- src/librustc/hir/lowering.rs | 37 ++++++++++++++++++---- src/librustc/middle/stability.rs | 9 +++--- src/librustc_allocator/expand.rs | 4 ++- src/librustc_metadata/creader.rs | 2 +- src/librustc_metadata/cstore_impl.rs | 4 ++- src/librustc_mir/transform/qualify_consts.rs | 2 +- src/librustc_plugin/registry.rs | 6 ++-- src/libstd/macros.rs | 18 +++++++---- src/libstd/thread/local.rs | 8 +++-- src/libsyntax/ext/base.rs | 20 ++++++++---- src/libsyntax/ext/derive.rs | 5 ++- src/libsyntax/ext/expand.rs | 27 +++++++++------- src/libsyntax/ext/source_util.rs | 2 +- src/libsyntax/ext/tt/macro_rules.rs | 13 +++++++- src/libsyntax/feature_gate.rs | 24 +++++++------- src/libsyntax/std_inject.rs | 4 ++- src/libsyntax/test.rs | 6 +++- src/libsyntax_ext/deriving/mod.rs | 8 +++-- src/libsyntax_ext/format.rs | 2 +- src/libsyntax_ext/lib.rs | 10 ++++-- src/libsyntax_ext/proc_macro_decls.rs | 5 ++- src/libsyntax_ext/test.rs | 5 ++- src/libsyntax_ext/test_case.rs | 5 ++- src/libsyntax_pos/hygiene.rs | 6 ++-- src/libsyntax_pos/lib.rs | 4 +-- ...re-gate-allow-internal-unstable-nested-macro.rs | 2 +- ...ate-allow-internal-unstable-nested-macro.stderr | 4 +-- .../feature-gate-allow-internal-unstable-struct.rs | 2 +- ...ture-gate-allow-internal-unstable-struct.stderr | 4 +-- .../feature-gate-allow-internal-unstable.rs | 2 +- .../feature-gate-allow-internal-unstable.stderr | 4 +-- .../ui/internal/auxiliary/internal_unstable.rs | 10 +++--- src/test/ui/internal/internal-unstable.rs | 2 +- 35 files changed, 182 insertions(+), 93 deletions(-) (limited to 'src/libstd') diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs index db91b07fa71..7ae57a8dc79 100644 --- a/src/liballoc/macros.rs +++ b/src/liballoc/macros.rs @@ -34,7 +34,8 @@ #[cfg(not(test))] #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[allow_internal_unstable] +#[cfg_attr(not(stage0), allow_internal_unstable(box_syntax))] +#[cfg_attr(stage0, allow_internal_unstable)] macro_rules! vec { ($elem:expr; $n:expr) => ( $crate::vec::from_elem($elem, $n) diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 664490c1997..6b5fe84ff61 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -1,6 +1,7 @@ /// Entry point of thread panic, for details, see std::macros #[macro_export] -#[allow_internal_unstable] +#[cfg_attr(not(stage0), allow_internal_unstable(core_panic, __rust_unstable_column))] +#[cfg_attr(stage0, allow_internal_unstable)] #[stable(feature = "core", since = "1.6.0")] macro_rules! panic { () => ( @@ -409,7 +410,8 @@ macro_rules! write { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[allow_internal_unstable] +#[cfg_attr(stage0, allow_internal_unstable)] +#[cfg_attr(not(stage0), allow_internal_unstable(format_args_nl))] macro_rules! writeln { ($dst:expr) => ( write!($dst, "\n") diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 3de41b1665d..b01362b0ed4 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -681,13 +681,18 @@ impl<'a> LoweringContext<'a> { Ident::with_empty_ctxt(Symbol::gensym(s)) } - fn allow_internal_unstable(&self, reason: CompilerDesugaringKind, span: Span) -> Span { + fn allow_internal_unstable( + &self, + reason: CompilerDesugaringKind, + span: Span, + allow_internal_unstable: Vec, + ) -> Span { let mark = Mark::fresh(Mark::root()); mark.set_expn_info(source_map::ExpnInfo { call_site: span, def_site: Some(span), format: source_map::CompilerDesugaring(reason), - allow_internal_unstable: true, + allow_internal_unstable, allow_internal_unsafe: false, local_inner_macros: false, edition: source_map::hygiene::default_edition(), @@ -964,7 +969,13 @@ impl<'a> LoweringContext<'a> { attrs: ThinVec::new(), }; - let unstable_span = self.allow_internal_unstable(CompilerDesugaringKind::Async, span); + let unstable_span = self.allow_internal_unstable( + CompilerDesugaringKind::Async, + span, + vec![ + Symbol::intern("gen_future"), + ], + ); let gen_future = self.expr_std_path( unstable_span, &["future", "from_generator"], None, ThinVec::new()); hir::ExprKind::Call(P(gen_future), hir_vec![generator]) @@ -1363,6 +1374,7 @@ impl<'a> LoweringContext<'a> { let exist_ty_span = self.allow_internal_unstable( CompilerDesugaringKind::ExistentialReturnType, span, + Vec::new(), // doesn'c actually allow anything unstable ); let exist_ty_def_index = self @@ -3927,8 +3939,13 @@ impl<'a> LoweringContext<'a> { }), ExprKind::TryBlock(ref body) => { self.with_catch_scope(body.id, |this| { - let unstable_span = - this.allow_internal_unstable(CompilerDesugaringKind::TryBlock, body.span); + let unstable_span = this.allow_internal_unstable( + CompilerDesugaringKind::TryBlock, + body.span, + vec![ + Symbol::intern("try_trait"), + ], + ); let mut block = this.lower_block(body, true).into_inner(); let tail = block.expr.take().map_or_else( || { @@ -4363,6 +4380,7 @@ impl<'a> LoweringContext<'a> { let desugared_span = self.allow_internal_unstable( CompilerDesugaringKind::ForLoop, head_sp, + Vec::new(), ); let iter = self.str_to_ident("iter"); @@ -4525,8 +4543,13 @@ impl<'a> LoweringContext<'a> { // return Try::from_error(From::from(err)), // } - let unstable_span = - self.allow_internal_unstable(CompilerDesugaringKind::QuestionMark, e.span); + let unstable_span = self.allow_internal_unstable( + CompilerDesugaringKind::QuestionMark, + e.span, + vec![ + Symbol::intern("try_trait") + ], + ); // `Try::into_result()` let discr = { diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 34c77d08f5a..5d606abb3cd 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -561,11 +561,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// deprecated. If the item is indeed deprecated, we will emit a deprecation lint attached to /// `id`. pub fn eval_stability(self, def_id: DefId, id: Option, span: Span) -> EvalResult { - if span.allows_unstable() { - debug!("stability: skipping span={:?} since it is internal", span); - return EvalResult::Allow; - } - let lint_deprecated = |def_id: DefId, id: NodeId, note: Option, @@ -694,6 +689,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { match stability { Some(&Stability { level: attr::Unstable { reason, issue }, feature, .. }) => { + if span.allows_unstable(&feature.as_str()) { + debug!("stability: skipping span={:?} since it is internal", span); + return EvalResult::Allow; + } if self.stability().active_features.contains(&feature) { return EvalResult::Allow; } diff --git a/src/librustc_allocator/expand.rs b/src/librustc_allocator/expand.rs index d302e7646d1..b877c80af1a 100644 --- a/src/librustc_allocator/expand.rs +++ b/src/librustc_allocator/expand.rs @@ -91,7 +91,9 @@ impl MutVisitor for ExpandAllocatorDirectives<'_> { call_site: item.span, // use the call site of the static def_site: None, format: MacroAttribute(Symbol::intern(name)), - allow_internal_unstable: true, + allow_internal_unstable: vec![ + Symbol::intern("rustc_attrs"), + ], allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 0b4c8a5367c..9fca1a983c3 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -570,7 +570,7 @@ impl<'a> CrateLoader<'a> { ProcMacro::Bang { name, client } => { (name, SyntaxExtension::ProcMacro { expander: Box::new(BangProcMacro { client }), - allow_internal_unstable: false, + allow_internal_unstable: Vec::new(), edition: root.edition, }) } diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index b248c6bf656..f7c7c627959 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -425,7 +425,9 @@ impl cstore::CStore { let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote); let ext = SyntaxExtension::ProcMacro { expander: Box::new(BangProcMacro { client }), - allow_internal_unstable: true, + allow_internal_unstable: vec![ + Symbol::intern("proc_macro_def_site"), + ], edition: data.root.edition, }; return LoadedMacro::ProcMacro(Lrc::new(ext)); diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 76b8b83031a..d1b005ffb85 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -907,7 +907,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { // Check `#[unstable]` const fns or `#[rustc_const_unstable]` // functions without the feature gate active in this crate in // order to report a better error message than the one below. - if self.span.allows_unstable() { + if self.span.allows_unstable(&feature.as_str()) { // `allow_internal_unstable` can make such calls stable. is_const_fn = true; } else { diff --git a/src/librustc_plugin/registry.rs b/src/librustc_plugin/registry.rs index b53d956a9c0..14312f0b2f7 100644 --- a/src/librustc_plugin/registry.rs +++ b/src/librustc_plugin/registry.rs @@ -110,8 +110,8 @@ impl<'a> Registry<'a> { edition, } } - IdentTT(ext, _, allow_internal_unstable) => { - IdentTT(ext, Some(self.krate_span), allow_internal_unstable) + IdentTT { ext, span: _, allow_internal_unstable } => { + IdentTT { ext, span: Some(self.krate_span), allow_internal_unstable } } _ => extension, })); @@ -126,7 +126,7 @@ impl<'a> Registry<'a> { self.register_syntax_extension(Symbol::intern(name), NormalTT { expander: Box::new(expander), def_info: None, - allow_internal_unstable: false, + allow_internal_unstable: Vec::new(), allow_internal_unsafe: false, local_inner_macros: false, unstable_feature: None, diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index b87257188df..506b6d4e8e0 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -53,7 +53,8 @@ /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[allow_internal_unstable] +#[cfg_attr(stage0, allow_internal_unstable)] +#[cfg_attr(not(stage0), allow_internal_unstable(__rust_unstable_column, libstd_sys_internals))] macro_rules! panic { () => ({ panic!("explicit panic") @@ -111,7 +112,8 @@ macro_rules! panic { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[allow_internal_unstable] +#[cfg_attr(stage0, allow_internal_unstable)] +#[cfg_attr(not(stage0), allow_internal_unstable(print_internals))] macro_rules! print { ($($arg:tt)*) => ($crate::io::_print(format_args!($($arg)*))); } @@ -143,7 +145,8 @@ macro_rules! print { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[allow_internal_unstable] +#[cfg_attr(stage0, allow_internal_unstable)] +#[cfg_attr(not(stage0), allow_internal_unstable(print_internals, format_args_nl))] macro_rules! println { () => (print!("\n")); ($($arg:tt)*) => ({ @@ -174,7 +177,8 @@ macro_rules! println { /// ``` #[macro_export] #[stable(feature = "eprint", since = "1.19.0")] -#[allow_internal_unstable] +#[cfg_attr(stage0, allow_internal_unstable)] +#[cfg_attr(not(stage0), allow_internal_unstable(print_internals))] macro_rules! eprint { ($($arg:tt)*) => ($crate::io::_eprint(format_args!($($arg)*))); } @@ -202,7 +206,8 @@ macro_rules! eprint { /// ``` #[macro_export] #[stable(feature = "eprint", since = "1.19.0")] -#[allow_internal_unstable] +#[cfg_attr(stage0, allow_internal_unstable)] +#[cfg_attr(not(stage0), allow_internal_unstable(print_internals, format_args_nl))] macro_rules! eprintln { () => (eprint!("\n")); ($($arg:tt)*) => ({ @@ -325,7 +330,8 @@ macro_rules! dbg { /// A macro to await on an async call. #[macro_export] #[unstable(feature = "await_macro", issue = "50547")] -#[allow_internal_unstable] +#[cfg_attr(stage0, allow_internal_unstable)] +#[cfg_attr(not(stage0), allow_internal_unstable(gen_future, generators))] #[allow_internal_unsafe] macro_rules! await { ($e:expr) => { { diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 5d2eb5f8e73..8207709e1f9 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -126,7 +126,8 @@ impl fmt::Debug for LocalKey { /// [`std::thread::LocalKey`]: ../std/thread/struct.LocalKey.html #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[allow_internal_unstable] +#[cfg_attr(stage0, allow_internal_unstable)] +#[cfg_attr(not(stage0), allow_internal_unstable(thread_local_internals))] macro_rules! thread_local { // empty (base case for the recursion) () => {}; @@ -148,7 +149,10 @@ macro_rules! thread_local { reason = "should not be necessary", issue = "0")] #[macro_export] -#[allow_internal_unstable] +#[cfg_attr(stage0, allow_internal_unstable)] +#[cfg_attr(not(stage0), allow_internal_unstable( + thread_local_internals, cfg_target_thread_local, thread_local, +))] #[allow_internal_unsafe] macro_rules! __thread_local_inner { (@key $(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $init:expr) => { diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 465b53184dc..02d6d721873 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -621,7 +621,8 @@ pub enum SyntaxExtension { /// A function-like procedural macro. TokenStream -> TokenStream. ProcMacro { expander: Box, - allow_internal_unstable: bool, + /// Whitelist of unstable features that are treated as stable inside this macro + allow_internal_unstable: Vec, edition: Edition, }, @@ -638,8 +639,10 @@ pub enum SyntaxExtension { expander: Box, def_info: Option<(ast::NodeId, Span)>, /// Whether the contents of the macro can - /// directly use `#[unstable]` things (true == yes). - allow_internal_unstable: bool, + /// directly use `#[unstable]` things. + /// + /// Only allows things that require a feature gate in the given whitelist + allow_internal_unstable: Vec, /// Whether the contents of the macro can use `unsafe` /// without triggering the `unsafe_code` lint. allow_internal_unsafe: bool, @@ -654,8 +657,11 @@ pub enum SyntaxExtension { /// A function-like syntax extension that has an extra ident before /// the block. - /// - IdentTT(Box, Option, bool), + IdentTT { + ext: Box, + span: Option, + allow_internal_unstable: Vec, + }, /// An attribute-like procedural macro. TokenStream -> TokenStream. /// The input is the annotated item. @@ -682,7 +688,7 @@ impl SyntaxExtension { match *self { SyntaxExtension::DeclMacro { .. } | SyntaxExtension::NormalTT { .. } | - SyntaxExtension::IdentTT(..) | + SyntaxExtension::IdentTT { .. } | SyntaxExtension::ProcMacro { .. } => MacroKind::Bang, SyntaxExtension::NonMacroAttr { .. } | @@ -716,7 +722,7 @@ impl SyntaxExtension { SyntaxExtension::ProcMacroDerive(.., edition) => edition, // Unstable legacy stuff SyntaxExtension::NonMacroAttr { .. } | - SyntaxExtension::IdentTT(..) | + SyntaxExtension::IdentTT { .. } | SyntaxExtension::MultiDecorator(..) | SyntaxExtension::MultiModifier(..) | SyntaxExtension::BuiltinDerive(..) => hygiene::default_edition(), diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs index 50cec9e7908..03d68f4257f 100644 --- a/src/libsyntax/ext/derive.rs +++ b/src/libsyntax/ext/derive.rs @@ -58,7 +58,10 @@ pub fn add_derived_markers(cx: &mut ExtCtxt<'_>, span: Span, traits: &[ast::P call_site: span, def_site: None, format: ExpnFormat::MacroAttribute(Symbol::intern(&pretty_name)), - allow_internal_unstable: true, + allow_internal_unstable: vec![ + Symbol::intern("rustc_attrs"), + Symbol::intern("structural_match"), + ], allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 89d59478a5d..65500cd23bd 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -558,7 +558,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { call_site: attr.span, def_site: None, format: MacroAttribute(Symbol::intern(&attr.path.to_string())), - allow_internal_unstable: false, + allow_internal_unstable: Vec::new(), allow_internal_unsafe: false, local_inner_macros: false, edition: ext.edition(), @@ -725,7 +725,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { // don't stability-check macros in the same crate // (the only time this is null is for syntax extensions registered as macros) if def_site_span.map_or(false, |def_span| !crate_span.contains(def_span)) - && !span.allows_unstable() && this.cx.ecfg.features.map_or(true, |feats| { + && !span.allows_unstable(&feature.as_str()) + && this.cx.ecfg.features.map_or(true, |feats| { // macro features will count as lib features !feats.declared_lib_features.iter().any(|&(feat, _)| feat == feature) }) { @@ -757,7 +758,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let opt_expanded = match *ext { DeclMacro { ref expander, def_info, edition, .. } => { if let Err(dummy_span) = validate_and_set_expn_info(self, def_info.map(|(_, s)| s), - false, false, false, None, + Vec::new(), false, false, None, edition) { dummy_span } else { @@ -768,14 +769,14 @@ impl<'a, 'b> MacroExpander<'a, 'b> { NormalTT { ref expander, def_info, - allow_internal_unstable, + ref allow_internal_unstable, allow_internal_unsafe, local_inner_macros, unstable_feature, edition, } => { if let Err(dummy_span) = validate_and_set_expn_info(self, def_info.map(|(_, s)| s), - allow_internal_unstable, + allow_internal_unstable.clone(), allow_internal_unsafe, local_inner_macros, unstable_feature, @@ -791,7 +792,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { } } - IdentTT(ref expander, tt_span, allow_internal_unstable) => { + IdentTT { ext: ref expander, span: tt_span, ref allow_internal_unstable } => { if ident.name == keywords::Invalid.name() { self.cx.span_err(path.span, &format!("macro {}! expects an ident argument", path)); @@ -802,7 +803,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { call_site: span, def_site: tt_span, format: macro_bang_format(path), - allow_internal_unstable, + allow_internal_unstable: allow_internal_unstable.clone(), allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), @@ -827,7 +828,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { kind.dummy(span) } - SyntaxExtension::ProcMacro { ref expander, allow_internal_unstable, edition } => { + SyntaxExtension::ProcMacro { ref expander, ref allow_internal_unstable, edition } => { if ident.name != keywords::Invalid.name() { let msg = format!("macro {}! expects no ident argument, given '{}'", path, ident); @@ -843,7 +844,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { def_site: None, format: macro_bang_format(path), // FIXME probably want to follow macro_rules macros here. - allow_internal_unstable, + allow_internal_unstable: allow_internal_unstable.clone(), allow_internal_unsafe: false, local_inner_macros: false, edition, @@ -918,7 +919,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { call_site: span, def_site: None, format: MacroAttribute(pretty_name), - allow_internal_unstable: false, + allow_internal_unstable: Vec::new(), allow_internal_unsafe: false, local_inner_macros: false, edition: ext.edition(), @@ -937,7 +938,11 @@ impl<'a, 'b> MacroExpander<'a, 'b> { Some(invoc.fragment_kind.expect_from_annotatables(items)) } BuiltinDerive(func) => { - expn_info.allow_internal_unstable = true; + expn_info.allow_internal_unstable = vec![ + Symbol::intern("rustc_attrs"), + Symbol::intern("derive_clone_copy"), + Symbol::intern("derive_eq"), + ]; invoc.expansion_data.mark.set_expn_info(expn_info); let span = span.with_ctxt(self.cx.backtrace()); let mut items = Vec::new(); diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 31a134b856d..549de1628eb 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -44,7 +44,7 @@ pub fn expand_column(cx: &mut ExtCtxt<'_>, sp: Span, tts: &[tokenstream::TokenTr /* __rust_unstable_column!(): expands to the current column number */ pub fn expand_column_gated(cx: &mut ExtCtxt<'_>, sp: Span, tts: &[tokenstream::TokenTree]) -> Box { - if sp.allows_unstable() { + if sp.allows_unstable("__rust_unstable_column") { expand_column(cx, sp, tts) } else { cx.span_fatal(sp, "the __rust_unstable_column macro is unstable"); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 33ea675f9d1..4409bf13b6c 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -376,7 +376,18 @@ pub fn compile( }); if body.legacy { - let allow_internal_unstable = attr::contains_name(&def.attrs, "allow_internal_unstable"); + let allow_internal_unstable = attr::find_by_name(&def.attrs, "allow_internal_unstable") + .map_or(Vec::new(), |attr| attr + .meta_item_list() + .unwrap_or_else(|| sess.span_diagnostic.span_bug( + attr.span, "allow_internal_unstable expects list of feature names", + )) + .iter() + .map(|it| it.name().unwrap_or_else(|| sess.span_diagnostic.span_bug( + it.span, "allow internal unstable expects feature names", + ))) + .collect() + ); let allow_internal_unsafe = attr::contains_name(&def.attrs, "allow_internal_unsafe"); let mut local_inner_macros = false; if let Some(macro_export) = attr::find_by_name(&def.attrs, "macro_export") { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 0853b4399d2..1e1b315824f 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1091,7 +1091,7 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu stable", cfg_fn!(profiler_runtime))), - ("allow_internal_unstable", Normal, template!(Word), Gated(Stability::Unstable, + ("allow_internal_unstable", Normal, template!(List: "feat1, feat2"), Gated(Stability::Unstable, "allow_internal_unstable", EXPLAIN_ALLOW_INTERNAL_UNSTABLE, cfg_fn!(allow_internal_unstable))), @@ -1199,7 +1199,7 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu ("proc_macro", Normal, template!(Word), Ungated), ("rustc_proc_macro_decls", Normal, template!(Word), Gated(Stability::Unstable, - "rustc_proc_macro_decls", + "rustc_attrs", "used internally by rustc", cfg_fn!(rustc_attrs))), @@ -1284,7 +1284,7 @@ impl GatedCfg { pub fn check_and_emit(&self, sess: &ParseSess, features: &Features) { let (cfg, feature, has_feature) = GATED_CFGS[self.index]; - if !has_feature(features) && !self.span.allows_unstable() { + if !has_feature(features) && !self.span.allows_unstable(feature) { let explain = format!("`cfg({})` is experimental and subject to change", cfg); emit_feature_err(sess, feature, self.span, GateIssue::Language, &explain); } @@ -1303,7 +1303,7 @@ macro_rules! gate_feature_fn { name, explain, level) = ($cx, $has_feature, $span, $name, $explain, $level); let has_feature: bool = has_feature(&$cx.features); debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", name, span, has_feature); - if !has_feature && !span.allows_unstable() { + if !has_feature && !span.allows_unstable($name) { leveled_feature_err(cx.parse_sess, name, span, GateIssue::Language, explain, level) .emit(); } @@ -1328,7 +1328,11 @@ impl<'a> Context<'a> { for &(n, ty, _template, ref gateage) in BUILTIN_ATTRIBUTES { if name == n { if let Gated(_, name, desc, ref has_feature) = *gateage { - gate_feature_fn!(self, has_feature, attr.span, name, desc, GateStrength::Hard); + if !attr.span.allows_unstable(name) { + gate_feature_fn!( + self, has_feature, attr.span, name, desc, GateStrength::Hard + ); + } } else if name == "doc" { if let Some(content) = attr.meta_item_list() { if content.iter().any(|c| c.check_name("include")) { @@ -1493,13 +1497,13 @@ struct PostExpansionVisitor<'a> { macro_rules! gate_feature_post { ($cx: expr, $feature: ident, $span: expr, $explain: expr) => {{ let (cx, span) = ($cx, $span); - if !span.allows_unstable() { + if !span.allows_unstable(stringify!($feature)) { gate_feature!(cx.context, $feature, span, $explain) } }}; ($cx: expr, $feature: ident, $span: expr, $explain: expr, $level: expr) => {{ let (cx, span) = ($cx, $span); - if !span.allows_unstable() { + if !span.allows_unstable(stringify!($feature)) { gate_feature!(cx.context, $feature, span, $explain, $level) } }} @@ -1610,10 +1614,8 @@ impl<'a> PostExpansionVisitor<'a> { impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { fn visit_attribute(&mut self, attr: &ast::Attribute) { - if !attr.span.allows_unstable() { - // check for gated attributes - self.context.check_attribute(attr, false); - } + // check for gated attributes + self.context.check_attribute(attr, false); if attr.check_name("doc") { if let Some(content) = attr.meta_item_list() { diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 5b904fa86ad..91ec42a33b5 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -20,7 +20,9 @@ fn ignored_span(sp: Span) -> Span { call_site: DUMMY_SP, def_site: None, format: MacroAttribute(Symbol::intern("std_inject")), - allow_internal_unstable: true, + allow_internal_unstable: vec![ + Symbol::intern("prelude_import"), + ], allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 703c4f2db34..aa107130eee 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -285,7 +285,11 @@ fn generate_test_harness(sess: &ParseSess, call_site: DUMMY_SP, def_site: None, format: MacroAttribute(Symbol::intern("test_case")), - allow_internal_unstable: true, + allow_internal_unstable: vec![ + Symbol::intern("main"), + Symbol::intern("test"), + Symbol::intern("rustc_attrs"), + ], allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index 2c8a996cdb0..bc86ffa852b 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -136,11 +136,15 @@ fn call_intrinsic(cx: &ExtCtxt<'_>, intrinsic: &str, args: Vec>) -> P { - if cx.current_expansion.mark.expn_info().unwrap().allow_internal_unstable { + let intrinsic_allowed_via_allow_internal_unstable = cx + .current_expansion.mark.expn_info().unwrap() + .allow_internal_unstable.iter() + .any(|&s| s == "core_intrinsics"); + if intrinsic_allowed_via_allow_internal_unstable { span = span.with_ctxt(cx.backtrace()); } else { // Avoid instability errors with user defined curstom derives, cc #36316 let mut info = cx.current_expansion.mark.expn_info().unwrap(); - info.allow_internal_unstable = true; + info.allow_internal_unstable = vec![Symbol::intern("core_intrinsics")]; let mark = Mark::fresh(Mark::root()); mark.set_expn_info(info); span = span.with_ctxt(SyntaxContext::empty().apply_mark(mark)); diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 6bb7ee1d5dd..1b17fc0d040 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -711,7 +711,7 @@ pub fn expand_format_args_nl<'cx>( //if !ecx.ecfg.enable_allow_internal_unstable() { // For some reason, the only one that actually works for `println` is the first check - if !sp.allows_unstable() // the enclosing span is marked as `#[allow_insternal_unsable]` + if !sp.allows_unstable("format_args_nl") // the span is marked as `#[allow_insternal_unsable]` && !ecx.ecfg.enable_allow_internal_unstable() // NOTE: when is this enabled? && !ecx.ecfg.enable_format_args_nl() // enabled using `#[feature(format_args_nl]` { diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 670d71fe25b..dacc54d272b 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -60,7 +60,7 @@ pub fn register_builtins(resolver: &mut dyn syntax::ext::base::Resolver, NormalTT { expander: Box::new($f as MacroExpanderFn), def_info: None, - allow_internal_unstable: false, + allow_internal_unstable: Vec::new(), allow_internal_unsafe: false, local_inner_macros: false, unstable_feature: None, @@ -103,7 +103,9 @@ pub fn register_builtins(resolver: &mut dyn syntax::ext::base::Resolver, NormalTT { expander: Box::new(format::expand_format_args), def_info: None, - allow_internal_unstable: true, + allow_internal_unstable: vec![ + Symbol::intern("fmt_internals"), + ], allow_internal_unsafe: false, local_inner_macros: false, unstable_feature: None, @@ -113,7 +115,9 @@ pub fn register_builtins(resolver: &mut dyn syntax::ext::base::Resolver, NormalTT { expander: Box::new(format::expand_format_args_nl), def_info: None, - allow_internal_unstable: true, + allow_internal_unstable: vec![ + Symbol::intern("fmt_internals"), + ], allow_internal_unsafe: false, local_inner_macros: false, unstable_feature: None, diff --git a/src/libsyntax_ext/proc_macro_decls.rs b/src/libsyntax_ext/proc_macro_decls.rs index 24d09514520..f198739d104 100644 --- a/src/libsyntax_ext/proc_macro_decls.rs +++ b/src/libsyntax_ext/proc_macro_decls.rs @@ -333,7 +333,10 @@ fn mk_decls( call_site: DUMMY_SP, def_site: None, format: MacroAttribute(Symbol::intern("proc_macro")), - allow_internal_unstable: true, + allow_internal_unstable: vec![ + Symbol::intern("rustc_attrs"), + Symbol::intern("proc_macro_internals"), + ], allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs index 832bebb6113..e2bea0c8b07 100644 --- a/src/libsyntax_ext/test.rs +++ b/src/libsyntax_ext/test.rs @@ -66,7 +66,10 @@ pub fn expand_test_or_bench( call_site: DUMMY_SP, def_site: None, format: MacroAttribute(Symbol::intern("test")), - allow_internal_unstable: true, + allow_internal_unstable: vec![ + Symbol::intern("rustc_attrs"), + Symbol::intern("test"), + ], allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax_ext/test_case.rs b/src/libsyntax_ext/test_case.rs index 63417b702d5..a581c282193 100644 --- a/src/libsyntax_ext/test_case.rs +++ b/src/libsyntax_ext/test_case.rs @@ -41,7 +41,10 @@ pub fn expand( call_site: DUMMY_SP, def_site: None, format: MacroAttribute(Symbol::intern("test_case")), - allow_internal_unstable: true, + allow_internal_unstable: vec![ + Symbol::intern("test"), + Symbol::intern("rustc_attrs"), + ], allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index 0c645fc678c..f9394826c9b 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -550,10 +550,10 @@ pub struct ExpnInfo { pub def_site: Option, /// The format with which the macro was invoked. pub format: ExpnFormat, - /// Whether the macro is allowed to use #[unstable]/feature-gated - /// features internally without forcing the whole crate to opt-in + /// List of #[unstable]/feature-gated features that the macro is allowed to use + /// internally without forcing the whole crate to opt-in /// to them. - pub allow_internal_unstable: bool, + pub allow_internal_unstable: Vec, /// Whether the macro is allowed to use `unsafe` internally /// even if the user crate has `#![forbid(unsafe_code)]`. pub allow_internal_unsafe: bool, diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 70c45f7f9a7..efb21e06f34 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -385,9 +385,9 @@ impl Span { /// Check if a span is "internal" to a macro in which `#[unstable]` /// items can be used (that is, a macro marked with /// `#[allow_internal_unstable]`). - pub fn allows_unstable(&self) -> bool { + pub fn allows_unstable(&self, feature: &str) -> bool { match self.ctxt().outer().expn_info() { - Some(info) => info.allow_internal_unstable, + Some(info) => info.allow_internal_unstable.iter().any(|&f| f == feature), None => false, } } diff --git a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.rs b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.rs index cf320b2747c..ee48f951629 100644 --- a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.rs +++ b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.rs @@ -5,7 +5,7 @@ macro_rules! bar { () => { // more layers don't help: - #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps + #[allow_internal_unstable()] //~ ERROR allow_internal_unstable side-steps macro_rules! baz { () => {} } diff --git a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.stderr b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.stderr index 7cdf743b279..802c74239d7 100644 --- a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.stderr +++ b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.stderr @@ -1,8 +1,8 @@ error[E0658]: allow_internal_unstable side-steps feature gating and stability checks --> $DIR/feature-gate-allow-internal-unstable-nested-macro.rs:8:9 | -LL | #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[allow_internal_unstable()] //~ ERROR allow_internal_unstable side-steps + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... LL | bar!(); | ------- in this macro invocation diff --git a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs index c9ea6c338b5..ede969097d5 100644 --- a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs +++ b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs @@ -1,7 +1,7 @@ // checks that this attribute is caught on non-macro items. // this needs a different test since this is done after expansion -#[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps +#[allow_internal_unstable()] //~ ERROR allow_internal_unstable side-steps struct S; fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr index 485c00ad42b..d619f1e3239 100644 --- a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr +++ b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr @@ -1,8 +1,8 @@ error[E0658]: allow_internal_unstable side-steps feature gating and stability checks --> $DIR/feature-gate-allow-internal-unstable-struct.rs:4:1 | -LL | #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[allow_internal_unstable()] //~ ERROR allow_internal_unstable side-steps + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(allow_internal_unstable)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable.rs b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable.rs index bea60fc012e..0a1b6acd9bf 100644 --- a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable.rs +++ b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable.rs @@ -1,6 +1,6 @@ #![allow(unused_macros)] -#[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps +#[allow_internal_unstable()] //~ ERROR allow_internal_unstable side-steps macro_rules! foo { () => {} } diff --git a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable.stderr b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable.stderr index 0533d071de3..aa4f6648c4f 100644 --- a/src/test/ui/feature-gates/feature-gate-allow-internal-unstable.stderr +++ b/src/test/ui/feature-gates/feature-gate-allow-internal-unstable.stderr @@ -1,8 +1,8 @@ error[E0658]: allow_internal_unstable side-steps feature gating and stability checks --> $DIR/feature-gate-allow-internal-unstable.rs:3:1 | -LL | #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[allow_internal_unstable()] //~ ERROR allow_internal_unstable side-steps + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(allow_internal_unstable)] to the crate attributes to enable diff --git a/src/test/ui/internal/auxiliary/internal_unstable.rs b/src/test/ui/internal/auxiliary/internal_unstable.rs index 7cf54c3e6a6..7c79dcb7522 100644 --- a/src/test/ui/internal/auxiliary/internal_unstable.rs +++ b/src/test/ui/internal/auxiliary/internal_unstable.rs @@ -23,14 +23,14 @@ pub struct Bar { } #[stable(feature = "stable", since = "1.0.0")] -#[allow_internal_unstable] +#[allow_internal_unstable(function)] #[macro_export] macro_rules! call_unstable_allow { () => { $crate::unstable() } } #[stable(feature = "stable", since = "1.0.0")] -#[allow_internal_unstable] +#[allow_internal_unstable(struct_field)] #[macro_export] macro_rules! construct_unstable_allow { ($e: expr) => { @@ -39,21 +39,21 @@ macro_rules! construct_unstable_allow { } #[stable(feature = "stable", since = "1.0.0")] -#[allow_internal_unstable] +#[allow_internal_unstable(method)] #[macro_export] macro_rules! call_method_allow { ($e: expr) => { $e.method() } } #[stable(feature = "stable", since = "1.0.0")] -#[allow_internal_unstable] +#[allow_internal_unstable(struct_field, struct2_field)] #[macro_export] macro_rules! access_field_allow { ($e: expr) => { $e.x } } #[stable(feature = "stable", since = "1.0.0")] -#[allow_internal_unstable] +#[allow_internal_unstable()] #[macro_export] macro_rules! pass_through_allow { ($e: expr) => { $e } diff --git a/src/test/ui/internal/internal-unstable.rs b/src/test/ui/internal/internal-unstable.rs index 34fef33bfeb..e09a5d89172 100644 --- a/src/test/ui/internal/internal-unstable.rs +++ b/src/test/ui/internal/internal-unstable.rs @@ -13,7 +13,7 @@ macro_rules! foo { }} } -#[allow_internal_unstable] +#[allow_internal_unstable(function)] macro_rules! bar { ($e: expr) => {{ foo!($e, -- cgit 1.4.1-3-g733a5 From a83e73dce4f0e80ff7559b3816f4f24391d4ff53 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 6 Feb 2019 10:58:06 +0100 Subject: Move out tests of a deprecated module to work around `#[test]` bugs https://github.com/rust-lang/rust/issues/47238 --- src/libstd/sync/mpsc/mod.rs | 3 + src/libstd/sync/mpsc/select.rs | 414 ----------------------------------- src/libstd/sync/mpsc/select_tests.rs | 413 ++++++++++++++++++++++++++++++++++ 3 files changed, 416 insertions(+), 414 deletions(-) create mode 100644 src/libstd/sync/mpsc/select_tests.rs (limited to 'src/libstd') diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 446c164965d..a8843549b8a 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -279,6 +279,9 @@ use self::select::StartResult; use self::select::StartResult::*; use self::blocking::SignalToken; +#[cfg(all(test, not(target_os = "emscripten")))] +mod select_tests; + mod blocking; mod oneshot; mod select; diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 8f41680a818..9487c0cf674 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -352,417 +352,3 @@ impl<'rx, T:Send+'rx> fmt::Debug for Handle<'rx, T> { f.debug_struct("Handle").finish() } } - -#[allow(unused_imports)] -#[cfg(all(test, not(target_os = "emscripten")))] -mod tests { - use thread; - use sync::mpsc::*; - - // Don't use the libstd version so we can pull in the right Select structure - // (std::comm points at the wrong one) - macro_rules! select { - ( - $($name:pat = $rx:ident.$meth:ident() => $code:expr),+ - ) => ({ - let sel = Select::new(); - $( let mut $rx = sel.handle(&$rx); )+ - unsafe { - $( $rx.add(); )+ - } - let ret = sel.wait(); - $( if ret == $rx.id() { let $name = $rx.$meth(); $code } else )+ - { unreachable!() } - }) - } - - #[test] - fn smoke() { - let (tx1, rx1) = channel::(); - let (tx2, rx2) = channel::(); - tx1.send(1).unwrap(); - select! { - foo = rx1.recv() => { assert_eq!(foo.unwrap(), 1); }, - _bar = rx2.recv() => { panic!() } - } - tx2.send(2).unwrap(); - select! { - _foo = rx1.recv() => { panic!() }, - bar = rx2.recv() => { assert_eq!(bar.unwrap(), 2) } - } - drop(tx1); - select! { - foo = rx1.recv() => { assert!(foo.is_err()); }, - _bar = rx2.recv() => { panic!() } - } - drop(tx2); - select! { - bar = rx2.recv() => { assert!(bar.is_err()); } - } - } - - #[test] - fn smoke2() { - let (_tx1, rx1) = channel::(); - let (_tx2, rx2) = channel::(); - let (_tx3, rx3) = channel::(); - let (_tx4, rx4) = channel::(); - let (tx5, rx5) = channel::(); - tx5.send(4).unwrap(); - select! { - _foo = rx1.recv() => { panic!("1") }, - _foo = rx2.recv() => { panic!("2") }, - _foo = rx3.recv() => { panic!("3") }, - _foo = rx4.recv() => { panic!("4") }, - foo = rx5.recv() => { assert_eq!(foo.unwrap(), 4); } - } - } - - #[test] - fn closed() { - let (_tx1, rx1) = channel::(); - let (tx2, rx2) = channel::(); - drop(tx2); - - select! { - _a1 = rx1.recv() => { panic!() }, - a2 = rx2.recv() => { assert!(a2.is_err()); } - } - } - - #[test] - fn unblocks() { - let (tx1, rx1) = channel::(); - let (_tx2, rx2) = channel::(); - let (tx3, rx3) = channel::(); - - let _t = thread::spawn(move|| { - for _ in 0..20 { thread::yield_now(); } - tx1.send(1).unwrap(); - rx3.recv().unwrap(); - for _ in 0..20 { thread::yield_now(); } - }); - - select! { - a = rx1.recv() => { assert_eq!(a.unwrap(), 1); }, - _b = rx2.recv() => { panic!() } - } - tx3.send(1).unwrap(); - select! { - a = rx1.recv() => { assert!(a.is_err()) }, - _b = rx2.recv() => { panic!() } - } - } - - #[test] - fn both_ready() { - let (tx1, rx1) = channel::(); - let (tx2, rx2) = channel::(); - let (tx3, rx3) = channel::<()>(); - - let _t = thread::spawn(move|| { - for _ in 0..20 { thread::yield_now(); } - tx1.send(1).unwrap(); - tx2.send(2).unwrap(); - rx3.recv().unwrap(); - }); - - select! { - a = rx1.recv() => { assert_eq!(a.unwrap(), 1); }, - a = rx2.recv() => { assert_eq!(a.unwrap(), 2); } - } - select! { - a = rx1.recv() => { assert_eq!(a.unwrap(), 1); }, - a = rx2.recv() => { assert_eq!(a.unwrap(), 2); } - } - assert_eq!(rx1.try_recv(), Err(TryRecvError::Empty)); - assert_eq!(rx2.try_recv(), Err(TryRecvError::Empty)); - tx3.send(()).unwrap(); - } - - #[test] - fn stress() { - const AMT: i32 = 10000; - let (tx1, rx1) = channel::(); - let (tx2, rx2) = channel::(); - let (tx3, rx3) = channel::<()>(); - - let _t = thread::spawn(move|| { - for i in 0..AMT { - if i % 2 == 0 { - tx1.send(i).unwrap(); - } else { - tx2.send(i).unwrap(); - } - rx3.recv().unwrap(); - } - }); - - for i in 0..AMT { - select! { - i1 = rx1.recv() => { assert!(i % 2 == 0 && i == i1.unwrap()); }, - i2 = rx2.recv() => { assert!(i % 2 == 1 && i == i2.unwrap()); } - } - tx3.send(()).unwrap(); - } - } - - #[allow(unused_must_use)] - #[test] - fn cloning() { - let (tx1, rx1) = channel::(); - let (_tx2, rx2) = channel::(); - let (tx3, rx3) = channel::<()>(); - - let _t = thread::spawn(move|| { - rx3.recv().unwrap(); - tx1.clone(); - assert_eq!(rx3.try_recv(), Err(TryRecvError::Empty)); - tx1.send(2).unwrap(); - rx3.recv().unwrap(); - }); - - tx3.send(()).unwrap(); - select! { - _i1 = rx1.recv() => {}, - _i2 = rx2.recv() => panic!() - } - tx3.send(()).unwrap(); - } - - #[allow(unused_must_use)] - #[test] - fn cloning2() { - let (tx1, rx1) = channel::(); - let (_tx2, rx2) = channel::(); - let (tx3, rx3) = channel::<()>(); - - let _t = thread::spawn(move|| { - rx3.recv().unwrap(); - tx1.clone(); - assert_eq!(rx3.try_recv(), Err(TryRecvError::Empty)); - tx1.send(2).unwrap(); - rx3.recv().unwrap(); - }); - - tx3.send(()).unwrap(); - select! { - _i1 = rx1.recv() => {}, - _i2 = rx2.recv() => panic!() - } - tx3.send(()).unwrap(); - } - - #[test] - fn cloning3() { - let (tx1, rx1) = channel::<()>(); - let (tx2, rx2) = channel::<()>(); - let (tx3, rx3) = channel::<()>(); - let _t = thread::spawn(move|| { - let s = Select::new(); - let mut h1 = s.handle(&rx1); - let mut h2 = s.handle(&rx2); - unsafe { h2.add(); } - unsafe { h1.add(); } - assert_eq!(s.wait(), h2.id); - tx3.send(()).unwrap(); - }); - - for _ in 0..1000 { thread::yield_now(); } - drop(tx1.clone()); - tx2.send(()).unwrap(); - rx3.recv().unwrap(); - } - - #[test] - fn preflight1() { - let (tx, rx) = channel(); - tx.send(()).unwrap(); - select! { - _n = rx.recv() => {} - } - } - - #[test] - fn preflight2() { - let (tx, rx) = channel(); - tx.send(()).unwrap(); - tx.send(()).unwrap(); - select! { - _n = rx.recv() => {} - } - } - - #[test] - fn preflight3() { - let (tx, rx) = channel(); - drop(tx.clone()); - tx.send(()).unwrap(); - select! { - _n = rx.recv() => {} - } - } - - #[test] - fn preflight4() { - let (tx, rx) = channel(); - tx.send(()).unwrap(); - let s = Select::new(); - let mut h = s.handle(&rx); - unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); - } - - #[test] - fn preflight5() { - let (tx, rx) = channel(); - tx.send(()).unwrap(); - tx.send(()).unwrap(); - let s = Select::new(); - let mut h = s.handle(&rx); - unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); - } - - #[test] - fn preflight6() { - let (tx, rx) = channel(); - drop(tx.clone()); - tx.send(()).unwrap(); - let s = Select::new(); - let mut h = s.handle(&rx); - unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); - } - - #[test] - fn preflight7() { - let (tx, rx) = channel::<()>(); - drop(tx); - let s = Select::new(); - let mut h = s.handle(&rx); - unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); - } - - #[test] - fn preflight8() { - let (tx, rx) = channel(); - tx.send(()).unwrap(); - drop(tx); - rx.recv().unwrap(); - let s = Select::new(); - let mut h = s.handle(&rx); - unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); - } - - #[test] - fn preflight9() { - let (tx, rx) = channel(); - drop(tx.clone()); - tx.send(()).unwrap(); - drop(tx); - rx.recv().unwrap(); - let s = Select::new(); - let mut h = s.handle(&rx); - unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); - } - - #[test] - fn oneshot_data_waiting() { - let (tx1, rx1) = channel(); - let (tx2, rx2) = channel(); - let _t = thread::spawn(move|| { - select! { - _n = rx1.recv() => {} - } - tx2.send(()).unwrap(); - }); - - for _ in 0..100 { thread::yield_now() } - tx1.send(()).unwrap(); - rx2.recv().unwrap(); - } - - #[test] - fn stream_data_waiting() { - let (tx1, rx1) = channel(); - let (tx2, rx2) = channel(); - tx1.send(()).unwrap(); - tx1.send(()).unwrap(); - rx1.recv().unwrap(); - rx1.recv().unwrap(); - let _t = thread::spawn(move|| { - select! { - _n = rx1.recv() => {} - } - tx2.send(()).unwrap(); - }); - - for _ in 0..100 { thread::yield_now() } - tx1.send(()).unwrap(); - rx2.recv().unwrap(); - } - - #[test] - fn shared_data_waiting() { - let (tx1, rx1) = channel(); - let (tx2, rx2) = channel(); - drop(tx1.clone()); - tx1.send(()).unwrap(); - rx1.recv().unwrap(); - let _t = thread::spawn(move|| { - select! { - _n = rx1.recv() => {} - } - tx2.send(()).unwrap(); - }); - - for _ in 0..100 { thread::yield_now() } - tx1.send(()).unwrap(); - rx2.recv().unwrap(); - } - - #[test] - fn sync1() { - let (tx, rx) = sync_channel::(1); - tx.send(1).unwrap(); - select! { - n = rx.recv() => { assert_eq!(n.unwrap(), 1); } - } - } - - #[test] - fn sync2() { - let (tx, rx) = sync_channel::(0); - let _t = thread::spawn(move|| { - for _ in 0..100 { thread::yield_now() } - tx.send(1).unwrap(); - }); - select! { - n = rx.recv() => { assert_eq!(n.unwrap(), 1); } - } - } - - #[test] - fn sync3() { - let (tx1, rx1) = sync_channel::(0); - let (tx2, rx2): (Sender, Receiver) = channel(); - let _t = thread::spawn(move|| { tx1.send(1).unwrap(); }); - let _t = thread::spawn(move|| { tx2.send(2).unwrap(); }); - select! { - n = rx1.recv() => { - let n = n.unwrap(); - assert_eq!(n, 1); - assert_eq!(rx2.recv().unwrap(), 2); - }, - n = rx2.recv() => { - let n = n.unwrap(); - assert_eq!(n, 2); - assert_eq!(rx1.recv().unwrap(), 1); - } - } - } -} diff --git a/src/libstd/sync/mpsc/select_tests.rs b/src/libstd/sync/mpsc/select_tests.rs new file mode 100644 index 00000000000..4f9ce20fc34 --- /dev/null +++ b/src/libstd/sync/mpsc/select_tests.rs @@ -0,0 +1,413 @@ +#![allow(unused_imports)] + +/// This file exists to hack around https://github.com/rust-lang/rust/issues/47238 + +use thread; +use sync::mpsc::*; + +// Don't use the libstd version so we can pull in the right Select structure +// (std::comm points at the wrong one) +macro_rules! select { + ( + $($name:pat = $rx:ident.$meth:ident() => $code:expr),+ + ) => ({ + let sel = Select::new(); + $( let mut $rx = sel.handle(&$rx); )+ + unsafe { + $( $rx.add(); )+ + } + let ret = sel.wait(); + $( if ret == $rx.id() { let $name = $rx.$meth(); $code } else )+ + { unreachable!() } + }) +} + +#[test] +fn smoke() { + let (tx1, rx1) = channel::(); + let (tx2, rx2) = channel::(); + tx1.send(1).unwrap(); + select! { + foo = rx1.recv() => { assert_eq!(foo.unwrap(), 1); }, + _bar = rx2.recv() => { panic!() } + } + tx2.send(2).unwrap(); + select! { + _foo = rx1.recv() => { panic!() }, + bar = rx2.recv() => { assert_eq!(bar.unwrap(), 2) } + } + drop(tx1); + select! { + foo = rx1.recv() => { assert!(foo.is_err()); }, + _bar = rx2.recv() => { panic!() } + } + drop(tx2); + select! { + bar = rx2.recv() => { assert!(bar.is_err()); } + } +} + +#[test] +fn smoke2() { + let (_tx1, rx1) = channel::(); + let (_tx2, rx2) = channel::(); + let (_tx3, rx3) = channel::(); + let (_tx4, rx4) = channel::(); + let (tx5, rx5) = channel::(); + tx5.send(4).unwrap(); + select! { + _foo = rx1.recv() => { panic!("1") }, + _foo = rx2.recv() => { panic!("2") }, + _foo = rx3.recv() => { panic!("3") }, + _foo = rx4.recv() => { panic!("4") }, + foo = rx5.recv() => { assert_eq!(foo.unwrap(), 4); } + } +} + +#[test] +fn closed() { + let (_tx1, rx1) = channel::(); + let (tx2, rx2) = channel::(); + drop(tx2); + + select! { + _a1 = rx1.recv() => { panic!() }, + a2 = rx2.recv() => { assert!(a2.is_err()); } + } +} + +#[test] +fn unblocks() { + let (tx1, rx1) = channel::(); + let (_tx2, rx2) = channel::(); + let (tx3, rx3) = channel::(); + + let _t = thread::spawn(move|| { + for _ in 0..20 { thread::yield_now(); } + tx1.send(1).unwrap(); + rx3.recv().unwrap(); + for _ in 0..20 { thread::yield_now(); } + }); + + select! { + a = rx1.recv() => { assert_eq!(a.unwrap(), 1); }, + _b = rx2.recv() => { panic!() } + } + tx3.send(1).unwrap(); + select! { + a = rx1.recv() => { assert!(a.is_err()) }, + _b = rx2.recv() => { panic!() } + } +} + +#[test] +fn both_ready() { + let (tx1, rx1) = channel::(); + let (tx2, rx2) = channel::(); + let (tx3, rx3) = channel::<()>(); + + let _t = thread::spawn(move|| { + for _ in 0..20 { thread::yield_now(); } + tx1.send(1).unwrap(); + tx2.send(2).unwrap(); + rx3.recv().unwrap(); + }); + + select! { + a = rx1.recv() => { assert_eq!(a.unwrap(), 1); }, + a = rx2.recv() => { assert_eq!(a.unwrap(), 2); } + } + select! { + a = rx1.recv() => { assert_eq!(a.unwrap(), 1); }, + a = rx2.recv() => { assert_eq!(a.unwrap(), 2); } + } + assert_eq!(rx1.try_recv(), Err(TryRecvError::Empty)); + assert_eq!(rx2.try_recv(), Err(TryRecvError::Empty)); + tx3.send(()).unwrap(); +} + +#[test] +fn stress() { + const AMT: i32 = 10000; + let (tx1, rx1) = channel::(); + let (tx2, rx2) = channel::(); + let (tx3, rx3) = channel::<()>(); + + let _t = thread::spawn(move|| { + for i in 0..AMT { + if i % 2 == 0 { + tx1.send(i).unwrap(); + } else { + tx2.send(i).unwrap(); + } + rx3.recv().unwrap(); + } + }); + + for i in 0..AMT { + select! { + i1 = rx1.recv() => { assert!(i % 2 == 0 && i == i1.unwrap()); }, + i2 = rx2.recv() => { assert!(i % 2 == 1 && i == i2.unwrap()); } + } + tx3.send(()).unwrap(); + } +} + +#[allow(unused_must_use)] +#[test] +fn cloning() { + let (tx1, rx1) = channel::(); + let (_tx2, rx2) = channel::(); + let (tx3, rx3) = channel::<()>(); + + let _t = thread::spawn(move|| { + rx3.recv().unwrap(); + tx1.clone(); + assert_eq!(rx3.try_recv(), Err(TryRecvError::Empty)); + tx1.send(2).unwrap(); + rx3.recv().unwrap(); + }); + + tx3.send(()).unwrap(); + select! { + _i1 = rx1.recv() => {}, + _i2 = rx2.recv() => panic!() + } + tx3.send(()).unwrap(); +} + +#[allow(unused_must_use)] +#[test] +fn cloning2() { + let (tx1, rx1) = channel::(); + let (_tx2, rx2) = channel::(); + let (tx3, rx3) = channel::<()>(); + + let _t = thread::spawn(move|| { + rx3.recv().unwrap(); + tx1.clone(); + assert_eq!(rx3.try_recv(), Err(TryRecvError::Empty)); + tx1.send(2).unwrap(); + rx3.recv().unwrap(); + }); + + tx3.send(()).unwrap(); + select! { + _i1 = rx1.recv() => {}, + _i2 = rx2.recv() => panic!() + } + tx3.send(()).unwrap(); +} + +#[test] +fn cloning3() { + let (tx1, rx1) = channel::<()>(); + let (tx2, rx2) = channel::<()>(); + let (tx3, rx3) = channel::<()>(); + let _t = thread::spawn(move|| { + let s = Select::new(); + let mut h1 = s.handle(&rx1); + let mut h2 = s.handle(&rx2); + unsafe { h2.add(); } + unsafe { h1.add(); } + assert_eq!(s.wait(), h2.id); + tx3.send(()).unwrap(); + }); + + for _ in 0..1000 { thread::yield_now(); } + drop(tx1.clone()); + tx2.send(()).unwrap(); + rx3.recv().unwrap(); +} + +#[test] +fn preflight1() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + select! { + _n = rx.recv() => {} + } +} + +#[test] +fn preflight2() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + tx.send(()).unwrap(); + select! { + _n = rx.recv() => {} + } +} + +#[test] +fn preflight3() { + let (tx, rx) = channel(); + drop(tx.clone()); + tx.send(()).unwrap(); + select! { + _n = rx.recv() => {} + } +} + +#[test] +fn preflight4() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + let s = Select::new(); + let mut h = s.handle(&rx); + unsafe { h.add(); } + assert_eq!(s.wait2(false), h.id); +} + +#[test] +fn preflight5() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + tx.send(()).unwrap(); + let s = Select::new(); + let mut h = s.handle(&rx); + unsafe { h.add(); } + assert_eq!(s.wait2(false), h.id); +} + +#[test] +fn preflight6() { + let (tx, rx) = channel(); + drop(tx.clone()); + tx.send(()).unwrap(); + let s = Select::new(); + let mut h = s.handle(&rx); + unsafe { h.add(); } + assert_eq!(s.wait2(false), h.id); +} + +#[test] +fn preflight7() { + let (tx, rx) = channel::<()>(); + drop(tx); + let s = Select::new(); + let mut h = s.handle(&rx); + unsafe { h.add(); } + assert_eq!(s.wait2(false), h.id); +} + +#[test] +fn preflight8() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + drop(tx); + rx.recv().unwrap(); + let s = Select::new(); + let mut h = s.handle(&rx); + unsafe { h.add(); } + assert_eq!(s.wait2(false), h.id); +} + +#[test] +fn preflight9() { + let (tx, rx) = channel(); + drop(tx.clone()); + tx.send(()).unwrap(); + drop(tx); + rx.recv().unwrap(); + let s = Select::new(); + let mut h = s.handle(&rx); + unsafe { h.add(); } + assert_eq!(s.wait2(false), h.id); +} + +#[test] +fn oneshot_data_waiting() { + let (tx1, rx1) = channel(); + let (tx2, rx2) = channel(); + let _t = thread::spawn(move|| { + select! { + _n = rx1.recv() => {} + } + tx2.send(()).unwrap(); + }); + + for _ in 0..100 { thread::yield_now() } + tx1.send(()).unwrap(); + rx2.recv().unwrap(); +} + +#[test] +fn stream_data_waiting() { + let (tx1, rx1) = channel(); + let (tx2, rx2) = channel(); + tx1.send(()).unwrap(); + tx1.send(()).unwrap(); + rx1.recv().unwrap(); + rx1.recv().unwrap(); + let _t = thread::spawn(move|| { + select! { + _n = rx1.recv() => {} + } + tx2.send(()).unwrap(); + }); + + for _ in 0..100 { thread::yield_now() } + tx1.send(()).unwrap(); + rx2.recv().unwrap(); +} + +#[test] +fn shared_data_waiting() { + let (tx1, rx1) = channel(); + let (tx2, rx2) = channel(); + drop(tx1.clone()); + tx1.send(()).unwrap(); + rx1.recv().unwrap(); + let _t = thread::spawn(move|| { + select! { + _n = rx1.recv() => {} + } + tx2.send(()).unwrap(); + }); + + for _ in 0..100 { thread::yield_now() } + tx1.send(()).unwrap(); + rx2.recv().unwrap(); +} + +#[test] +fn sync1() { + let (tx, rx) = sync_channel::(1); + tx.send(1).unwrap(); + select! { + n = rx.recv() => { assert_eq!(n.unwrap(), 1); } + } +} + +#[test] +fn sync2() { + let (tx, rx) = sync_channel::(0); + let _t = thread::spawn(move|| { + for _ in 0..100 { thread::yield_now() } + tx.send(1).unwrap(); + }); + select! { + n = rx.recv() => { assert_eq!(n.unwrap(), 1); } + } +} + +#[test] +fn sync3() { + let (tx1, rx1) = sync_channel::(0); + let (tx2, rx2): (Sender, Receiver) = channel(); + let _t = thread::spawn(move|| { tx1.send(1).unwrap(); }); + let _t = thread::spawn(move|| { tx2.send(2).unwrap(); }); + select! { + n = rx1.recv() => { + let n = n.unwrap(); + assert_eq!(n, 1); + assert_eq!(rx2.recv().unwrap(), 2); + }, + n = rx2.recv() => { + let n = n.unwrap(); + assert_eq!(n, 2); + assert_eq!(rx1.recv().unwrap(), 1); + } + } +} -- cgit 1.4.1-3-g733a5 From 1dba7cb20224b5bb3a22641b2f4f2f73e5157dee Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 6 Feb 2019 10:58:29 +0100 Subject: Fiddle through the module visibilities for tests --- src/libstd/sync/mpsc/select.rs | 2 +- src/libstd/sync/mpsc/select_tests.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 9487c0cf674..e34fc5487cf 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -158,7 +158,7 @@ impl Select { } /// Helper method for skipping the preflight checks during testing - fn wait2(&self, do_preflight_checks: bool) -> usize { + pub(super) fn wait2(&self, do_preflight_checks: bool) -> usize { // Note that this is currently an inefficient implementation. We in // theory have knowledge about all receivers in the set ahead of time, // so this method shouldn't really have to iterate over all of them yet diff --git a/src/libstd/sync/mpsc/select_tests.rs b/src/libstd/sync/mpsc/select_tests.rs index 4f9ce20fc34..be048511caa 100644 --- a/src/libstd/sync/mpsc/select_tests.rs +++ b/src/libstd/sync/mpsc/select_tests.rs @@ -210,7 +210,7 @@ fn cloning3() { let mut h2 = s.handle(&rx2); unsafe { h2.add(); } unsafe { h1.add(); } - assert_eq!(s.wait(), h2.id); + assert_eq!(s.wait(), h2.id()); tx3.send(()).unwrap(); }); @@ -256,7 +256,7 @@ fn preflight4() { let s = Select::new(); let mut h = s.handle(&rx); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + assert_eq!(s.wait2(false), h.id()); } #[test] @@ -267,7 +267,7 @@ fn preflight5() { let s = Select::new(); let mut h = s.handle(&rx); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + assert_eq!(s.wait2(false), h.id()); } #[test] @@ -278,7 +278,7 @@ fn preflight6() { let s = Select::new(); let mut h = s.handle(&rx); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + assert_eq!(s.wait2(false), h.id()); } #[test] @@ -288,7 +288,7 @@ fn preflight7() { let s = Select::new(); let mut h = s.handle(&rx); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + assert_eq!(s.wait2(false), h.id()); } #[test] @@ -300,7 +300,7 @@ fn preflight8() { let s = Select::new(); let mut h = s.handle(&rx); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + assert_eq!(s.wait2(false), h.id()); } #[test] @@ -313,7 +313,7 @@ fn preflight9() { let s = Select::new(); let mut h = s.handle(&rx); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + assert_eq!(s.wait2(false), h.id()); } #[test] -- cgit 1.4.1-3-g733a5 From 34052a19a24325e525296e97f9b56e77d7fb4020 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Mon, 11 Feb 2019 15:36:45 -0500 Subject: remove "experimental" wording from std::os::unix --- src/libstd/sys/unix/ext/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/unix/ext/mod.rs b/src/libstd/sys/unix/ext/mod.rs index 36e9370b713..ccbac1a3e4b 100644 --- a/src/libstd/sys/unix/ext/mod.rs +++ b/src/libstd/sys/unix/ext/mod.rs @@ -1,4 +1,4 @@ -//! Experimental extensions to `std` for Unix platforms. +//! Platform-specific extensions to `std` for Unix platforms. //! //! Provides access to platform-level information on Unix platforms, and //! exposes Unix-specific functions that would otherwise be inappropriate as -- cgit 1.4.1-3-g733a5