diff options
| author | bors <bors@rust-lang.org> | 2017-12-06 14:53:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-12-06 14:53:37 +0000 |
| commit | 833785b090c30d4a359d901fb41bfafbe1607ce9 (patch) | |
| tree | 3bae34d8913ec84c8325bd31096b16368fcdca41 | |
| parent | 632ad19135a1f38c42761270ffc8a0d977b1db4c (diff) | |
| parent | bb239e294ee35aab4ddd7c7a306d0bf5bd8518b6 (diff) | |
| download | rust-833785b090c30d4a359d901fb41bfafbe1607ce9.tar.gz rust-833785b090c30d4a359d901fb41bfafbe1607ce9.zip | |
Auto merge of #46538 - frewsxcv:rollup, r=frewsxcv
Rollup of 7 pull requests - Successful merges: #46136, #46378, #46431, #46483, #46495, #46502, #46512 - Failed merges:
| -rw-r--r-- | CONTRIBUTING.md | 2 | ||||
| -rw-r--r-- | src/liballoc/benches/btree/map.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/benches/slice.rs | 2 | ||||
| -rw-r--r-- | src/libcore/macros.rs | 4 | ||||
| -rw-r--r-- | src/libcore/ptr.rs | 42 | ||||
| -rw-r--r-- | src/libcore/result.rs | 8 | ||||
| -rw-r--r-- | src/librustc_driver/lib.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/html/static/rustdoc.css | 11 | ||||
| -rw-r--r-- | src/libstd/macros.rs | 29 |
9 files changed, 87 insertions, 15 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e3767df2808..b8fea40090f 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 744afb991b0..20b9091a07b 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 d99270e7f31..17538d885f8 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 6e3dbcbec9d..fe2df226115 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 5e70c8283f4..20f054f5a77 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -91,8 +91,12 @@ pub const fn null<T>() -> *const T { 0 as *const T } pub const fn null_mut<T>() -> *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<T>() -> *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<T>(x: *mut T, y: *mut T) { diff --git a/src/libcore/result.rs b/src/libcore/result.rs index db5bffced10..959935242dc 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 bda721d0783..d9b67e2d27f 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<lint::LintId>)>| { for (name, to) in lints { diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 679f5f6e3fd..f32252b726c 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 7d62f94056f..b36473d9b75 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 */ }) } |
