diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e3767df2808fa..b8fea40090fab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -336,7 +336,7 @@ will run all the tests on every platform we support. If it all works out, Speaking of tests, Rust has a comprehensive test suite. More information about it can be found -[here](https://github.com/rust-lang/rust-wiki-backup/blob/master/Note-testsuite.md). +[here](https://github.com/rust-lang/rust/blob/master/src/test/COMPILER_TESTS.md). ### External Dependencies [external-dependencies]: #external-dependencies diff --git a/src/liballoc/benches/btree/map.rs b/src/liballoc/benches/btree/map.rs index 744afb991b00e..20b9091a07bfc 100644 --- a/src/liballoc/benches/btree/map.rs +++ b/src/liballoc/benches/btree/map.rs @@ -12,7 +12,7 @@ use std::iter::Iterator; use std::vec::Vec; use std::collections::BTreeMap; -use std::__rand::{Rng, thread_rng}; +use rand::{Rng, thread_rng}; use test::{Bencher, black_box}; macro_rules! map_insert_rand_bench { diff --git a/src/liballoc/benches/slice.rs b/src/liballoc/benches/slice.rs index d99270e7f311e..17538d885f8f4 100644 --- a/src/liballoc/benches/slice.rs +++ b/src/liballoc/benches/slice.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::__rand::{thread_rng}; +use rand::{thread_rng}; use std::mem; use std::ptr; diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 6e3dbcbec9dc9..fe2df2261156a 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -596,9 +596,9 @@ mod builtin { /// Unconditionally causes compilation to fail with the given error message when encountered. /// - /// For more information, see the [RFC]. + /// For more information, see the documentation for [`std::compile_error!`]. /// - /// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md + /// [`std::compile_error!`]: ../std/macro.compile_error.html #[stable(feature = "compile_error_macro", since = "1.20.0")] #[macro_export] #[cfg(dox)] diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 5e70c8283f454..20f054f5a77f2 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -91,8 +91,12 @@ pub const fn null() -> *const T { 0 as *const T } pub const fn null_mut() -> *mut T { 0 as *mut T } /// Swaps the values at two mutable locations of the same type, without -/// deinitializing either. They may overlap, unlike `mem::swap` which is -/// otherwise equivalent. +/// deinitializing either. +/// +/// The values pointed at by `x` and `y` may overlap, unlike `mem::swap` which +/// is otherwise equivalent. If the values do overlap, then the overlapping +/// region of memory from `x` will be used. This is demonstrated in the +/// examples section below. /// /// # Safety /// @@ -100,6 +104,40 @@ pub const fn null_mut() -> *mut T { 0 as *mut T } /// as arguments. /// /// Ensure that these pointers are valid before calling `swap`. +/// +/// # Examples +/// +/// Swapping two non-overlapping regions: +/// +/// ``` +/// use std::ptr; +/// +/// let mut array = [0, 1, 2, 3]; +/// +/// let x = array[0..].as_mut_ptr() as *mut [u32; 2]; +/// let y = array[2..].as_mut_ptr() as *mut [u32; 2]; +/// +/// unsafe { +/// ptr::swap(x, y); +/// assert_eq!([2, 3, 0, 1], array); +/// } +/// ``` +/// +/// Swapping two overlapping regions: +/// +/// ``` +/// use std::ptr; +/// +/// let mut array = [0, 1, 2, 3]; +/// +/// let x = array[0..].as_mut_ptr() as *mut [u32; 3]; +/// let y = array[1..].as_mut_ptr() as *mut [u32; 3]; +/// +/// unsafe { +/// ptr::swap(x, y); +/// assert_eq!([1, 0, 1, 2], array); +/// } +/// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn swap(x: *mut T, y: *mut T) { diff --git a/src/libcore/result.rs b/src/libcore/result.rs index db5bffced10cc..959935242dcc5 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -153,12 +153,12 @@ //! } //! ``` //! -//! # The `?` syntax +//! # The question mark operator, `?` //! //! When writing code that calls many functions that return the -//! [`Result`] type, the error handling can be tedious. The [`?`] -//! syntax hides some of the boilerplate of propagating errors up the -//! call stack. +//! [`Result`] type, the error handling can be tedious. The question mark +//! operator, [`?`], hides some of the boilerplate of propagating errors +//! up the call stack. //! //! It replaces this: //! diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index bda721d078310..d9b67e2d27f0c 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -982,7 +982,7 @@ Available lint options: println!("Lint groups provided by rustc:\n"); println!(" {} {}", padded("name"), "sub-lints"); println!(" {} {}", padded("----"), "---------"); - println!(" {} {}", padded("warnings"), "all built-in lints"); + println!(" {} {}", padded("warnings"), "all lints that are set to issue warnings"); let print_lint_groups = |lints: Vec<(&'static str, Vec)>| { for (name, to) in lints { diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 679f5f6e3fde9..f32252b726c8f 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -179,7 +179,6 @@ nav.sub { top: 0; height: 100vh; overflow: auto; - z-index: 1; } .sidebar .current { @@ -273,9 +272,19 @@ nav.sub { overflow: auto; padding-left: 0; } + #search { margin-left: 230px; + position: relative; +} + +#results { + position: absolute; + right: 0; + left: 0; + overflow: auto; } + .content pre.line-numbers { float: left; border: none; diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 7d62f94056fb2..b36473d9b75f0 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -282,9 +282,34 @@ pub mod builtin { /// Unconditionally causes compilation to fail with the given error message when encountered. /// - /// For more information, see the [RFC]. + /// This macro should be used when a crate uses a conditional compilation strategy to provide + /// better error messages for errornous conditions. /// - /// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md + /// # Examples + /// + /// Two such examples are macros and `#[cfg]` environments. + /// + /// Emit better compiler error if a macro is passed invalid values. + /// + /// ```compile_fail + /// macro_rules! give_me_foo_or_bar { + /// (foo) => {}; + /// (bar) => {}; + /// ($x:ident) => { + /// compile_error!("This macro only accepts `foo` or `bar`"); + /// } + /// } + /// + /// give_me_foo_or_bar!(neither); + /// // ^ will fail at compile time with message "This macro only accepts `foo` or `bar`" + /// ``` + /// + /// Emit compiler error if one of a number of features isn't available. + /// + /// ```compile_fail + /// #[cfg(not(any(feature = "foo", feature = "bar")))] + /// compile_error!("Either feature \"foo\" or \"bar\" must be enabled for this crate.") + /// ``` #[stable(feature = "compile_error_macro", since = "1.20.0")] #[macro_export] macro_rules! compile_error { ($msg:expr) => ({ /* compiler built-in */ }) }