Skip to content

Commit effea9a

Browse files
committed
Auto merge of #87689 - JohnTitor:rollup-ns38b56, r=JohnTitor
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
2 parents 24bbf7a + 0851841 commit effea9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+571
-579
lines changed

Cargo.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,9 @@ dependencies = [
646646

647647
[[package]]
648648
name = "compiler_builtins"
649-
version = "0.1.47"
649+
version = "0.1.49"
650650
source = "registry+https://github.com/rust-lang/crates.io-index"
651-
checksum = "fd4ed89e0a5c3e50b15c0045fbe1ff8567b703bc07544faf935ddff0aaa7b65f"
651+
checksum = "20b1438ef42c655665a8ab2c1c6d605a305f031d38d9be689ddfef41a20f3aa2"
652652
dependencies = [
653653
"cc",
654654
"rustc-std-workspace-core",
@@ -1495,9 +1495,9 @@ dependencies = [
14951495

14961496
[[package]]
14971497
name = "handlebars"
1498-
version = "3.4.0"
1498+
version = "4.1.0"
14991499
source = "registry+https://github.com/rust-lang/crates.io-index"
1500-
checksum = "5deefd4816fb852b1ff3cb48f6c41da67be2d0e1d20b26a7a3b076da11f064b1"
1500+
checksum = "72a0ffab8c36d0436114310c7e10b59b3307e650ddfabf6d006028e29a70c6e6"
15011501
dependencies = [
15021502
"log",
15031503
"pest",
@@ -2100,9 +2100,9 @@ dependencies = [
21002100

21012101
[[package]]
21022102
name = "mdbook"
2103-
version = "0.4.7"
2103+
version = "0.4.11"
21042104
source = "registry+https://github.com/rust-lang/crates.io-index"
2105-
checksum = "28f6a882f3880ec68e96f60d6b543c34941e2f307ad10e2992e4db9acfe96529"
2105+
checksum = "4ee73932975c44c485e541416d7c30abb31a053af7e49682f6e856f1e4d6ab2a"
21062106
dependencies = [
21072107
"ammonia",
21082108
"anyhow",

compiler/rustc_session/src/session.rs

-5
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,6 @@ pub struct Session {
198198
/// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`.
199199
pub confused_type_with_std_module: Lock<FxHashMap<Span, Span>>,
200200

201-
/// Path for libraries that will take preference over libraries shipped by Rust.
202-
/// Used by windows-gnu targets to priortize system mingw-w64 libraries.
203-
pub system_library_path: OneThread<RefCell<Option<Option<PathBuf>>>>,
204-
205201
/// Tracks the current behavior of the CTFE engine when an error occurs.
206202
/// Options range from returning the error without a backtrace to returning an error
207203
/// and immediately printing the backtrace to stderr.
@@ -1375,7 +1371,6 @@ pub fn build_session(
13751371
driver_lint_caps,
13761372
trait_methods_not_found: Lock::new(Default::default()),
13771373
confused_type_with_std_module: Lock::new(Default::default()),
1378-
system_library_path: OneThread::new(RefCell::new(Default::default())),
13791374
ctfe_backtrace,
13801375
miri_unleashed_features: Lock::new(Default::default()),
13811376
asm_arch,

library/alloc/src/vec/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,12 @@ impl<T, A: Allocator> Vec<T, A> {
13601360
/// Removes and returns the element at position `index` within the vector,
13611361
/// shifting all elements after it to the left.
13621362
///
1363+
/// Note: Because this shifts over the remaining elements, it has a
1364+
/// worst-case performance of O(n). If you don't need the order of elements
1365+
/// to be preserved, use [`swap_remove`] instead.
1366+
///
1367+
/// [`swap_remove`]: Vec::swap_remove
1368+
///
13631369
/// # Panics
13641370
///
13651371
/// Panics if `index` is out of bounds.

library/core/src/alloc/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,9 @@ pub unsafe trait Allocator {
338338
Ok(new_ptr)
339339
}
340340

341-
/// Creates a "by reference" adaptor for this instance of `Allocator`.
341+
/// Creates a "by reference" adapter for this instance of `Allocator`.
342342
///
343-
/// The returned adaptor also implements `Allocator` and will simply borrow this.
343+
/// The returned adapter also implements `Allocator` and will simply borrow this.
344344
#[inline(always)]
345345
fn by_ref(&self) -> &Self
346346
where

library/core/src/iter/traits/iterator.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ pub trait Iterator {
694694
/// more idiomatic to use a `for` loop, but `for_each` may be more legible
695695
/// when processing items at the end of longer iterator chains. In some
696696
/// cases `for_each` may also be faster than a loop, because it will use
697-
/// internal iteration on adaptors like `Chain`.
697+
/// internal iteration on adapters like `Chain`.
698698
///
699699
/// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
700700
///
@@ -1293,7 +1293,7 @@ pub trait Iterator {
12931293
Take::new(self, n)
12941294
}
12951295

1296-
/// An iterator adaptor similar to [`fold`] that holds internal state and
1296+
/// An iterator adapter similar to [`fold`] that holds internal state and
12971297
/// produces a new iterator.
12981298
///
12991299
/// [`fold`]: Iterator::fold
@@ -1604,7 +1604,7 @@ pub trait Iterator {
16041604

16051605
/// Borrows an iterator, rather than consuming it.
16061606
///
1607-
/// This is useful to allow applying iterator adaptors while still
1607+
/// This is useful to allow applying iterator adapters while still
16081608
/// retaining ownership of the original iterator.
16091609
///
16101610
/// # Examples

library/core/src/ptr/non_null.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,14 @@ impl<T: ?Sized> NonNull<T> {
173173
///
174174
/// let mut x = 0u32;
175175
/// let ptr = unsafe { NonNull::new_unchecked(&mut x as *mut _) };
176+
/// ```
177+
///
178+
/// *Incorrect* usage of this function:
179+
///
180+
/// ```rust,no_run
181+
/// use std::ptr::NonNull;
176182
///
177-
/// // NEVER DO THAT!!!
183+
/// // NEVER DO THAT!!! This is undefined behavior. ⚠️
178184
/// let ptr = unsafe { NonNull::<u32>::new_unchecked(std::ptr::null_mut()) };
179185
/// ```
180186
#[stable(feature = "nonnull", since = "1.25.0")]

library/core/src/slice/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl<T> [T] {
139139
/// assert_eq!(None, w.first());
140140
/// ```
141141
#[stable(feature = "rust1", since = "1.0.0")]
142-
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
142+
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
143143
#[inline]
144144
pub const fn first(&self) -> Option<&T> {
145145
if let [first, ..] = self { Some(first) } else { None }
@@ -177,7 +177,7 @@ impl<T> [T] {
177177
/// }
178178
/// ```
179179
#[stable(feature = "slice_splits", since = "1.5.0")]
180-
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
180+
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
181181
#[inline]
182182
pub const fn split_first(&self) -> Option<(&T, &[T])> {
183183
if let [first, tail @ ..] = self { Some((first, tail)) } else { None }
@@ -217,7 +217,7 @@ impl<T> [T] {
217217
/// }
218218
/// ```
219219
#[stable(feature = "slice_splits", since = "1.5.0")]
220-
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
220+
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
221221
#[inline]
222222
pub const fn split_last(&self) -> Option<(&T, &[T])> {
223223
if let [init @ .., last] = self { Some((last, init)) } else { None }
@@ -256,7 +256,7 @@ impl<T> [T] {
256256
/// assert_eq!(None, w.last());
257257
/// ```
258258
#[stable(feature = "rust1", since = "1.0.0")]
259-
#[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")]
259+
#[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]
260260
#[inline]
261261
pub const fn last(&self) -> Option<&T> {
262262
if let [.., last] = self { Some(last) } else { None }

library/core/tests/iter/adapters/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use core::cell::Cell;
2424

2525
/// An iterator that panics whenever `next` or next_back` is called
2626
/// after `None` has already been returned. This does not violate
27-
/// `Iterator`'s contract. Used to test that iterator adaptors don't
27+
/// `Iterator`'s contract. Used to test that iterator adapters don't
2828
/// poll their inner iterators after exhausting them.
2929
pub struct NonFused<I> {
3030
iter: I,

library/std/src/env.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,9 @@ impl fmt::Debug for VarsOs {
185185
///
186186
/// # Errors
187187
///
188-
/// Errors if the environment variable is not present.
189-
/// Errors if the environment variable is not valid Unicode. If this is not desired, consider using
190-
/// [`var_os`].
191-
///
192-
/// # Panics
193-
///
194-
/// This function may panic if `key` is empty, contains an ASCII equals sign
195-
/// `'='` or the NUL character `'\0'`, or when the value contains the NUL
196-
/// character.
188+
/// Returns `[None]` if the environment variable isn't set.
189+
/// Returns `[None]` if the environment variable is not valid Unicode. If this is not
190+
/// desired, consider using [`var_os`].
197191
///
198192
/// # Examples
199193
///
@@ -219,18 +213,17 @@ fn _var(key: &OsStr) -> Result<String, VarError> {
219213
}
220214

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

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

255247
/// The error type for operations interacting with environment variables.

library/std/src/io/mod.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,9 @@ pub trait Read {
810810
default_read_exact(self, buf)
811811
}
812812

813-
/// Creates a "by reference" adaptor for this instance of `Read`.
813+
/// Creates a "by reference" adapter for this instance of `Read`.
814814
///
815-
/// The returned adaptor also implements `Read` and will simply borrow this
815+
/// The returned adapter also implements `Read` and will simply borrow this
816816
/// current reader.
817817
///
818818
/// # Examples
@@ -889,7 +889,7 @@ pub trait Read {
889889
Bytes { inner: self }
890890
}
891891

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

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

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

1666-
let mut output = Adaptor { inner: self, error: Ok(()) };
1666+
let mut output = Adapter { inner: self, error: Ok(()) };
16671667
match fmt::write(&mut output, fmt) {
16681668
Ok(()) => Ok(()),
16691669
Err(..) => {
@@ -1677,9 +1677,9 @@ pub trait Write {
16771677
}
16781678
}
16791679

1680-
/// Creates a "by reference" adaptor for this instance of `Write`.
1680+
/// Creates a "by reference" adapter for this instance of `Write`.
16811681
///
1682-
/// The returned adaptor also implements `Write` and will simply borrow this
1682+
/// The returned adapter also implements `Write` and will simply borrow this
16831683
/// current writer.
16841684
///
16851685
/// # Examples
@@ -2263,7 +2263,7 @@ pub trait BufRead: Read {
22632263
}
22642264
}
22652265

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

2417-
/// Reader adaptor which limits the bytes read from an underlying reader.
2417+
/// Reader adapter which limits the bytes read from an underlying reader.
24182418
///
24192419
/// This struct is generally created by calling [`take`] on a reader.
24202420
/// Please see the documentation of [`take`] for more details.

0 commit comments

Comments
 (0)