Skip to content

Commit

Permalink
Auto merge of #87689 - JohnTitor:rollup-ns38b56, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 13 pull requests

Successful merges:

 - #86183 (Change environment variable getters to error recoverably)
 - #86439 (Remove `Ipv4Addr::is_ietf_protocol_assignment`)
 - #86509 (Move `os_str_bytes` to `sys::unix`)
 - #86593 (Partially stabilize `const_slice_first_last`)
 - #86936 (Add documentation for `Ipv6MulticastScope`)
 - #87282 (Ensure `./x.py dist` adheres to `build.tools`)
 - #87468 (Update rustfmt)
 - #87504 (Update mdbook.)
 - #87608 (Remove unused field `Session.system_library_path`)
 - #87629 (Consistent spelling of "adapter" in the standard library)
 - #87633 (Update compiler_builtins to fix i128 shift/mul on thumbv6m)
 - #87644 (Recommend `swap_remove` in `Vec::remove` docs)
 - #87653 (mark a UB doctest as no_run)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Aug 2, 2021
2 parents 24bbf7a + 0851841 commit effea9a
Show file tree
Hide file tree
Showing 72 changed files with 571 additions and 579 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.47"
version = "0.1.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd4ed89e0a5c3e50b15c0045fbe1ff8567b703bc07544faf935ddff0aaa7b65f"
checksum = "20b1438ef42c655665a8ab2c1c6d605a305f031d38d9be689ddfef41a20f3aa2"
dependencies = [
"cc",
"rustc-std-workspace-core",
Expand Down Expand Up @@ -1495,9 +1495,9 @@ dependencies = [

[[package]]
name = "handlebars"
version = "3.4.0"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5deefd4816fb852b1ff3cb48f6c41da67be2d0e1d20b26a7a3b076da11f064b1"
checksum = "72a0ffab8c36d0436114310c7e10b59b3307e650ddfabf6d006028e29a70c6e6"
dependencies = [
"log",
"pest",
Expand Down Expand Up @@ -2100,9 +2100,9 @@ dependencies = [

[[package]]
name = "mdbook"
version = "0.4.7"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28f6a882f3880ec68e96f60d6b543c34941e2f307ad10e2992e4db9acfe96529"
checksum = "4ee73932975c44c485e541416d7c30abb31a053af7e49682f6e856f1e4d6ab2a"
dependencies = [
"ammonia",
"anyhow",
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ pub struct Session {
/// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`.
pub confused_type_with_std_module: Lock<FxHashMap<Span, Span>>,

/// Path for libraries that will take preference over libraries shipped by Rust.
/// Used by windows-gnu targets to priortize system mingw-w64 libraries.
pub system_library_path: OneThread<RefCell<Option<Option<PathBuf>>>>,

/// Tracks the current behavior of the CTFE engine when an error occurs.
/// Options range from returning the error without a backtrace to returning an error
/// and immediately printing the backtrace to stderr.
Expand Down Expand Up @@ -1375,7 +1371,6 @@ pub fn build_session(
driver_lint_caps,
trait_methods_not_found: Lock::new(Default::default()),
confused_type_with_std_module: Lock::new(Default::default()),
system_library_path: OneThread::new(RefCell::new(Default::default())),
ctfe_backtrace,
miri_unleashed_features: Lock::new(Default::default()),
asm_arch,
Expand Down
6 changes: 6 additions & 0 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,12 @@ impl<T, A: Allocator> Vec<T, A> {
/// Removes and returns the element at position `index` within the vector,
/// shifting all elements after it to the left.
///
/// Note: Because this shifts over the remaining elements, it has a
/// worst-case performance of O(n). If you don't need the order of elements
/// to be preserved, use [`swap_remove`] instead.
///
/// [`swap_remove`]: Vec::swap_remove
///
/// # Panics
///
/// Panics if `index` is out of bounds.
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/alloc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ pub unsafe trait Allocator {
Ok(new_ptr)
}

/// Creates a "by reference" adaptor for this instance of `Allocator`.
/// Creates a "by reference" adapter for this instance of `Allocator`.
///
/// The returned adaptor also implements `Allocator` and will simply borrow this.
/// The returned adapter also implements `Allocator` and will simply borrow this.
#[inline(always)]
fn by_ref(&self) -> &Self
where
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ pub trait Iterator {
/// 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
/// cases `for_each` may also be faster than a loop, because it will use
/// internal iteration on adaptors like `Chain`.
/// internal iteration on adapters like `Chain`.
///
/// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
///
Expand Down Expand Up @@ -1293,7 +1293,7 @@ pub trait Iterator {
Take::new(self, n)
}

/// An iterator adaptor similar to [`fold`] that holds internal state and
/// An iterator adapter similar to [`fold`] that holds internal state and
/// produces a new iterator.
///
/// [`fold`]: Iterator::fold
Expand Down Expand Up @@ -1604,7 +1604,7 @@ pub trait Iterator {

/// Borrows an iterator, rather than consuming it.
///
/// This is useful to allow applying iterator adaptors while still
/// This is useful to allow applying iterator adapters while still
/// retaining ownership of the original iterator.
///
/// # Examples
Expand Down
8 changes: 7 additions & 1 deletion library/core/src/ptr/non_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,14 @@ impl<T: ?Sized> NonNull<T> {
///
/// let mut x = 0u32;
/// let ptr = unsafe { NonNull::new_unchecked(&mut x as *mut _) };
/// ```
///
/// *Incorrect* usage of this function:
///
/// ```rust,no_run
/// use std::ptr::NonNull;
///
/// // NEVER DO THAT!!!
/// // NEVER DO THAT!!! This is undefined behavior. ⚠️
/// let ptr = unsafe { NonNull::<u32>::new_unchecked(std::ptr::null_mut()) };
/// ```
#[stable(feature = "nonnull", since = "1.25.0")]
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl<T> [T] {
/// assert_eq!(None, w.first());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
#[inline]
pub const fn first(&self) -> Option<&T> {
if let [first, ..] = self { Some(first) } else { None }
Expand Down Expand Up @@ -177,7 +177,7 @@ impl<T> [T] {
/// }
/// ```
#[stable(feature = "slice_splits", since = "1.5.0")]
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
#[inline]
pub const fn split_first(&self) -> Option<(&T, &[T])> {
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
Expand Down Expand Up @@ -217,7 +217,7 @@ impl<T> [T] {
/// }
/// ```
#[stable(feature = "slice_splits", since = "1.5.0")]
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
#[inline]
pub const fn split_last(&self) -> Option<(&T, &[T])> {
if let [init @ .., last] = self { Some((last, init)) } else { None }
Expand Down Expand Up @@ -256,7 +256,7 @@ impl<T> [T] {
/// assert_eq!(None, w.last());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
#[inline]
pub const fn last(&self) -> Option<&T> {
if let [.., last] = self { Some(last) } else { None }
Expand Down
2 changes: 1 addition & 1 deletion library/core/tests/iter/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use core::cell::Cell;

/// An iterator that panics whenever `next` or next_back` is called
/// after `None` has already been returned. This does not violate
/// `Iterator`'s contract. Used to test that iterator adaptors don't
/// `Iterator`'s contract. Used to test that iterator adapters don't
/// poll their inner iterators after exhausting them.
pub struct NonFused<I> {
iter: I,
Expand Down
26 changes: 9 additions & 17 deletions library/std/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,9 @@ impl fmt::Debug for VarsOs {
///
/// # Errors
///
/// Errors if the environment variable is not present.
/// Errors if the environment variable is not valid Unicode. If this is not desired, consider using
/// [`var_os`].
///
/// # Panics
///
/// This function may panic if `key` is empty, contains an ASCII equals sign
/// `'='` or the NUL character `'\0'`, or when the value contains the NUL
/// character.
/// Returns `[None]` if the environment variable isn't set.
/// Returns `[None]` if the environment variable is not valid Unicode. If this is not
/// desired, consider using [`var_os`].
///
/// # Examples
///
Expand All @@ -219,18 +213,17 @@ fn _var(key: &OsStr) -> Result<String, VarError> {
}

/// Fetches the environment variable `key` from the current process, returning
/// [`None`] if the variable isn't set.
///
/// # Panics
///
/// This function may panic if `key` is empty, contains an ASCII equals sign
/// `'='` or the NUL character `'\0'`, or when the value contains the NUL
/// character.
/// [`None`] if the variable isn't set or there's another error.
///
/// Note that the method will not check if the environment variable
/// is valid Unicode. If you want to have an error on invalid UTF-8,
/// use the [`var`] function instead.
///
/// # Errors
///
/// Returns `[None]` if the variable isn't set.
/// May return `[None]` if the variable value contains the NUL character.
///
/// # Examples
///
/// ```
Expand All @@ -249,7 +242,6 @@ pub fn var_os<K: AsRef<OsStr>>(key: K) -> Option<OsString> {

fn _var_os(key: &OsStr) -> Option<OsString> {
os_imp::getenv(key)
.unwrap_or_else(|e| panic!("failed to get environment variable `{:?}`: {}", key, e))
}

/// The error type for operations interacting with environment variables.
Expand Down
24 changes: 12 additions & 12 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,9 @@ pub trait Read {
default_read_exact(self, buf)
}

/// Creates a "by reference" adaptor for this instance of `Read`.
/// Creates a "by reference" adapter for this instance of `Read`.
///
/// The returned adaptor also implements `Read` and will simply borrow this
/// The returned adapter also implements `Read` and will simply borrow this
/// current reader.
///
/// # Examples
Expand Down Expand Up @@ -889,7 +889,7 @@ pub trait Read {
Bytes { inner: self }
}

/// Creates an adaptor which will chain this stream with another.
/// Creates an adapter which will chain this stream with another.
///
/// The returned `Read` instance will first read all bytes from this object
/// until EOF is encountered. Afterwards the output is equivalent to the
Expand Down Expand Up @@ -927,7 +927,7 @@ pub trait Read {
Chain { first: self, second: next, done_first: false }
}

/// Creates an adaptor which will read at most `limit` bytes from it.
/// Creates an adapter which will read at most `limit` bytes from it.
///
/// This function returns a new instance of `Read` which will read at most
/// `limit` bytes, after which it will always return EOF ([`Ok(0)`]). Any
Expand Down Expand Up @@ -1326,7 +1326,7 @@ impl Initializer {
/// * The [`write`] method will attempt to write some data into the object,
/// returning how many bytes were successfully written.
///
/// * The [`flush`] method is useful for adaptors and explicit buffers
/// * The [`flush`] method is useful for adapters and explicit buffers
/// themselves for ensuring that all buffered data has been pushed out to the
/// 'true sink'.
///
Expand Down Expand Up @@ -1646,12 +1646,12 @@ pub trait Write {
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> Result<()> {
// Create a shim which translates a Write to a fmt::Write and saves
// off I/O errors. instead of discarding them
struct Adaptor<'a, T: ?Sized + 'a> {
struct Adapter<'a, T: ?Sized + 'a> {
inner: &'a mut T,
error: Result<()>,
}

impl<T: Write + ?Sized> fmt::Write for Adaptor<'_, T> {
impl<T: Write + ?Sized> fmt::Write for Adapter<'_, T> {
fn write_str(&mut self, s: &str) -> fmt::Result {
match self.inner.write_all(s.as_bytes()) {
Ok(()) => Ok(()),
Expand All @@ -1663,7 +1663,7 @@ pub trait Write {
}
}

let mut output = Adaptor { inner: self, error: Ok(()) };
let mut output = Adapter { inner: self, error: Ok(()) };
match fmt::write(&mut output, fmt) {
Ok(()) => Ok(()),
Err(..) => {
Expand All @@ -1677,9 +1677,9 @@ pub trait Write {
}
}

/// Creates a "by reference" adaptor for this instance of `Write`.
/// Creates a "by reference" adapter for this instance of `Write`.
///
/// The returned adaptor also implements `Write` and will simply borrow this
/// The returned adapter also implements `Write` and will simply borrow this
/// current writer.
///
/// # Examples
Expand Down Expand Up @@ -2263,7 +2263,7 @@ pub trait BufRead: Read {
}
}

/// Adaptor to chain together two readers.
/// Adapter to chain together two readers.
///
/// This struct is generally created by calling [`chain`] on a reader.
/// Please see the documentation of [`chain`] for more details.
Expand Down Expand Up @@ -2414,7 +2414,7 @@ impl<T, U> SizeHint for Chain<T, U> {
}
}

/// Reader adaptor which limits the bytes read from an underlying reader.
/// Reader adapter which limits the bytes read from an underlying reader.
///
/// This struct is generally created by calling [`take`] on a reader.
/// Please see the documentation of [`take`] for more details.
Expand Down
Loading

0 comments on commit effea9a

Please sign in to comment.