From 8affcb7bd4a6f012941b07e5fb53dce44da24107 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Mon, 20 Nov 2017 22:16:38 +0100 Subject: [PATCH 01/10] Clarify what `-D warnings` or `-F warnings` does They set all lints currently on the warning level to `deny` or `forbid`, respectively. --- src/librustc_driver/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index c5cce70c94566..f67c4ae17187a 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -980,7 +980,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 activated to the warning level"); let print_lint_groups = |lints: Vec<(&'static str, Vec)>| { for (name, to) in lints { From 9bea79bd5ef492cf2c24e098ac93638446cb4860 Mon Sep 17 00:00:00 2001 From: John-John Tedro Date: Tue, 28 Nov 2017 17:03:33 +0100 Subject: [PATCH 02/10] Fix use of rand in liballoc benches --- src/liballoc/benches/btree/map.rs | 2 +- src/liballoc/benches/slice.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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; From e1e1dcc8d8e6ed6b62439d0a947b8e5308ff4216 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Fri, 1 Dec 2017 20:28:01 +0100 Subject: [PATCH 03/10] Changed the wording for the `warnings` lint --- src/librustc_driver/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index f67c4ae17187a..910a2694668cc 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -980,7 +980,7 @@ Available lint options: println!("Lint groups provided by rustc:\n"); println!(" {} {}", padded("name"), "sub-lints"); println!(" {} {}", padded("----"), "---------"); - println!(" {} {}", padded("warnings"), "all lints activated to the warning level"); + 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 { From 38ef72306fac91b435e6e143cf03d4fb2fb4d212 Mon Sep 17 00:00:00 2001 From: Timo Date: Mon, 4 Dec 2017 11:35:08 -0500 Subject: [PATCH 04/10] Update old link This page currently links to an old wiki page in rust-lang/rust-wiki-backup. There is a more up-to-date page in-tree so I changed the link to point there so new contributors can find it more easily. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 611d0e6ccef8b60fa86ff5aa8fe3571cd36c444a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 4 Dec 2017 22:11:21 +0100 Subject: [PATCH 05/10] Improve search style --- src/librustdoc/html/static/rustdoc.css | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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; From f3662275e45271b6f0f1d30d572a21e19f3261a1 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 3 Dec 2017 18:02:17 -0500 Subject: [PATCH 06/10] Document behavior of `ptr::swap` with overlapping regions of memory. Fixes https://github.com/rust-lang/rust/issues/44479. --- src/libcore/ptr.rs | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) 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) { From 44c343be45ef0ef68f456eeb8f5a07fa46eb599b Mon Sep 17 00:00:00 2001 From: Havvy Date: Mon, 4 Dec 2017 21:55:24 -0800 Subject: [PATCH 07/10] Give compile_error macro examples --- src/libcore/macros.rs | 4 ++-- src/libstd/macros.rs | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) 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/libstd/macros.rs b/src/libstd/macros.rs index 7d62f94056fb2..85785270811b2 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -282,9 +282,26 @@ 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. + /// + /// ``` + /// macro_rules! give_me_foo_or_bar { + /// (foo) => {}; + /// (bar) => {}; + /// ($x:ident) => { + /// compile_error!("This macro only accepts `foo` or `bar`"); + /// } + /// } + /// ``` + /// + /// ```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 */ }) } From 3f0b766c35f6822f1f69ec23630496bbe11a707f Mon Sep 17 00:00:00 2001 From: Havvy Date: Tue, 5 Dec 2017 01:47:47 -0800 Subject: [PATCH 08/10] No unused macro warning in compile_error example. --- src/libstd/macros.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 85785270811b2..e2028883f231a 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -288,7 +288,7 @@ pub mod builtin { /// # Examples /// Two such examples are macros and `#[cfg]` environments. /// - /// ``` + /// ```compile_fail /// macro_rules! give_me_foo_or_bar { /// (foo) => {}; /// (bar) => {}; @@ -296,6 +296,9 @@ pub mod builtin { /// 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`" /// ``` /// /// ```compile_fail From 893474ea6d16497b23503582f5b85be2ea2bab0b Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Fri, 1 Dec 2017 13:00:45 -0500 Subject: [PATCH 09/10] Mention the name of ? in Result's docs Fixes #42725 or at least, this is the best we can really do. #35946 is tracking better errors already, so that should cover the other part of it. --- src/libcore/result.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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: //! From aaaea2c562dc5638e8fcaa00371492ae71b07e46 Mon Sep 17 00:00:00 2001 From: Havvy Date: Tue, 5 Dec 2017 14:01:09 -0800 Subject: [PATCH 10/10] compile_error example blurbs --- src/libstd/macros.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index e2028883f231a..b36473d9b75f0 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -286,8 +286,11 @@ pub mod builtin { /// better error messages for errornous conditions. /// /// # 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) => {}; @@ -301,6 +304,8 @@ pub mod builtin { /// // ^ 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.")