Skip to content

Commit 833785b

Browse files
committed
Auto merge of #46538 - frewsxcv:rollup, r=frewsxcv
Rollup of 7 pull requests - Successful merges: #46136, #46378, #46431, #46483, #46495, #46502, #46512 - Failed merges:
2 parents 632ad19 + bb239e2 commit 833785b

File tree

9 files changed

+87
-15
lines changed

9 files changed

+87
-15
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ will run all the tests on every platform we support. If it all works out,
336336

337337
Speaking of tests, Rust has a comprehensive test suite. More information about
338338
it can be found
339-
[here](https://github.com/rust-lang/rust-wiki-backup/blob/master/Note-testsuite.md).
339+
[here](https://github.com/rust-lang/rust/blob/master/src/test/COMPILER_TESTS.md).
340340

341341
### External Dependencies
342342
[external-dependencies]: #external-dependencies

src/liballoc/benches/btree/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use std::iter::Iterator;
1313
use std::vec::Vec;
1414
use std::collections::BTreeMap;
15-
use std::__rand::{Rng, thread_rng};
15+
use rand::{Rng, thread_rng};
1616
use test::{Bencher, black_box};
1717

1818
macro_rules! map_insert_rand_bench {

src/liballoc/benches/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::__rand::{thread_rng};
11+
use rand::{thread_rng};
1212
use std::mem;
1313
use std::ptr;
1414

src/libcore/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,9 @@ mod builtin {
596596

597597
/// Unconditionally causes compilation to fail with the given error message when encountered.
598598
///
599-
/// For more information, see the [RFC].
599+
/// For more information, see the documentation for [`std::compile_error!`].
600600
///
601-
/// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md
601+
/// [`std::compile_error!`]: ../std/macro.compile_error.html
602602
#[stable(feature = "compile_error_macro", since = "1.20.0")]
603603
#[macro_export]
604604
#[cfg(dox)]

src/libcore/ptr.rs

+40-2
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,53 @@ pub const fn null<T>() -> *const T { 0 as *const T }
9191
pub const fn null_mut<T>() -> *mut T { 0 as *mut T }
9292

9393
/// Swaps the values at two mutable locations of the same type, without
94-
/// deinitializing either. They may overlap, unlike `mem::swap` which is
95-
/// otherwise equivalent.
94+
/// deinitializing either.
95+
///
96+
/// The values pointed at by `x` and `y` may overlap, unlike `mem::swap` which
97+
/// is otherwise equivalent. If the values do overlap, then the overlapping
98+
/// region of memory from `x` will be used. This is demonstrated in the
99+
/// examples section below.
96100
///
97101
/// # Safety
98102
///
99103
/// This function copies the memory through the raw pointers passed to it
100104
/// as arguments.
101105
///
102106
/// Ensure that these pointers are valid before calling `swap`.
107+
///
108+
/// # Examples
109+
///
110+
/// Swapping two non-overlapping regions:
111+
///
112+
/// ```
113+
/// use std::ptr;
114+
///
115+
/// let mut array = [0, 1, 2, 3];
116+
///
117+
/// let x = array[0..].as_mut_ptr() as *mut [u32; 2];
118+
/// let y = array[2..].as_mut_ptr() as *mut [u32; 2];
119+
///
120+
/// unsafe {
121+
/// ptr::swap(x, y);
122+
/// assert_eq!([2, 3, 0, 1], array);
123+
/// }
124+
/// ```
125+
///
126+
/// Swapping two overlapping regions:
127+
///
128+
/// ```
129+
/// use std::ptr;
130+
///
131+
/// let mut array = [0, 1, 2, 3];
132+
///
133+
/// let x = array[0..].as_mut_ptr() as *mut [u32; 3];
134+
/// let y = array[1..].as_mut_ptr() as *mut [u32; 3];
135+
///
136+
/// unsafe {
137+
/// ptr::swap(x, y);
138+
/// assert_eq!([1, 0, 1, 2], array);
139+
/// }
140+
/// ```
103141
#[inline]
104142
#[stable(feature = "rust1", since = "1.0.0")]
105143
pub unsafe fn swap<T>(x: *mut T, y: *mut T) {

src/libcore/result.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@
153153
//! }
154154
//! ```
155155
//!
156-
//! # The `?` syntax
156+
//! # The question mark operator, `?`
157157
//!
158158
//! When writing code that calls many functions that return the
159-
//! [`Result`] type, the error handling can be tedious. The [`?`]
160-
//! syntax hides some of the boilerplate of propagating errors up the
161-
//! call stack.
159+
//! [`Result`] type, the error handling can be tedious. The question mark
160+
//! operator, [`?`], hides some of the boilerplate of propagating errors
161+
//! up the call stack.
162162
//!
163163
//! It replaces this:
164164
//!

src/librustc_driver/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ Available lint options:
982982
println!("Lint groups provided by rustc:\n");
983983
println!(" {} {}", padded("name"), "sub-lints");
984984
println!(" {} {}", padded("----"), "---------");
985-
println!(" {} {}", padded("warnings"), "all built-in lints");
985+
println!(" {} {}", padded("warnings"), "all lints that are set to issue warnings");
986986

987987
let print_lint_groups = |lints: Vec<(&'static str, Vec<lint::LintId>)>| {
988988
for (name, to) in lints {

src/librustdoc/html/static/rustdoc.css

+10-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ nav.sub {
179179
top: 0;
180180
height: 100vh;
181181
overflow: auto;
182-
z-index: 1;
183182
}
184183

185184
.sidebar .current {
@@ -273,9 +272,19 @@ nav.sub {
273272
overflow: auto;
274273
padding-left: 0;
275274
}
275+
276276
#search {
277277
margin-left: 230px;
278+
position: relative;
279+
}
280+
281+
#results {
282+
position: absolute;
283+
right: 0;
284+
left: 0;
285+
overflow: auto;
278286
}
287+
279288
.content pre.line-numbers {
280289
float: left;
281290
border: none;

src/libstd/macros.rs

+27-2
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,34 @@ pub mod builtin {
282282

283283
/// Unconditionally causes compilation to fail with the given error message when encountered.
284284
///
285-
/// For more information, see the [RFC].
285+
/// This macro should be used when a crate uses a conditional compilation strategy to provide
286+
/// better error messages for errornous conditions.
286287
///
287-
/// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md
288+
/// # Examples
289+
///
290+
/// Two such examples are macros and `#[cfg]` environments.
291+
///
292+
/// Emit better compiler error if a macro is passed invalid values.
293+
///
294+
/// ```compile_fail
295+
/// macro_rules! give_me_foo_or_bar {
296+
/// (foo) => {};
297+
/// (bar) => {};
298+
/// ($x:ident) => {
299+
/// compile_error!("This macro only accepts `foo` or `bar`");
300+
/// }
301+
/// }
302+
///
303+
/// give_me_foo_or_bar!(neither);
304+
/// // ^ will fail at compile time with message "This macro only accepts `foo` or `bar`"
305+
/// ```
306+
///
307+
/// Emit compiler error if one of a number of features isn't available.
308+
///
309+
/// ```compile_fail
310+
/// #[cfg(not(any(feature = "foo", feature = "bar")))]
311+
/// compile_error!("Either feature \"foo\" or \"bar\" must be enabled for this crate.")
312+
/// ```
288313
#[stable(feature = "compile_error_macro", since = "1.20.0")]
289314
#[macro_export]
290315
macro_rules! compile_error { ($msg:expr) => ({ /* compiler built-in */ }) }

0 commit comments

Comments
 (0)