Skip to content

Update subtree/library to 2025-05-26 #366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 61 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
58be659
Guarantee behavior of transmuting Option::<T>::None subject to NPO
joshlf Feb 20, 2025
98480d8
Stabilize <[T; N]>::as_mut_slice as const
thaliaarchi Apr 20, 2025
df655c4
docs: Specify that common sort functions sort in an ascending direction
Natr1x Apr 30, 2025
c6d86b4
Update std doctests for android
ehuss May 15, 2025
50e05bd
Updated std doctests for wasm
ehuss May 16, 2025
477fdff
Implement `advance_by` via `try_fold` for `Sized` iterators
a1phyr May 16, 2025
e2664af
additional edge cases tests for `path.rs`
GrantBirki May 16, 2025
4db4525
Docs(lib/alloc/vec): Add the missing `an` to `extract_if`'s first sen…
PaulDance May 17, 2025
7b939b7
Docs(lib/coll/hm): Reword `extract_if` to use `element` instead of `v…
PaulDance May 17, 2025
908e4aa
Docs(lib/coll/btm): Split `extract_if`'s first sentence from the foll…
PaulDance May 17, 2025
550dcf6
Docs(lib/extract_if): Unify paragraph about closure actions
PaulDance May 17, 2025
dd5aae9
Docs(lib/extract_if): Unify paragraph about elements mutation
PaulDance May 17, 2025
792ebed
Docs(lib/coll/hm): Add kv pair to `extract_if`'s first sentence
PaulDance May 17, 2025
323be04
Docs(lib/extract_if): Unify example description
PaulDance May 17, 2025
b3dc829
discuss deadlocks in the std::io::pipe() example
oconnor663 May 17, 2025
62637c1
remove `test_embedded_null_byte()` test for now
GrantBirki May 17, 2025
90ffcdc
Switch library rustc_unimplemented to use `Self` and `This`
mejrs May 17, 2025
6acf8f4
revert forward slash to backslash
GrantBirki May 17, 2025
14b7e26
remove extra tests that really might not be all that useful
GrantBirki May 17, 2025
dda44a2
Rename `cfg_match!` to `cfg_select!`
tgross35 Feb 18, 2025
1bf1c7d
bump stdarch
RalfJung May 21, 2025
de6bde3
limit impls of `VaArgSafe` to just types that are actually safe
folkertdev May 21, 2025
8b9e244
std: fix doctest and explain for as_slices and as_mut_slices in VecDeque
xizheyin May 18, 2025
b0c6d88
Rollup merge of #140526 - Natr1x:sort-direction-documentation, r=dtolnay
matthiaskrgr May 21, 2025
365198a
Rollup merge of #141230 - xizheyin:issue-141217, r=tgross35
matthiaskrgr May 21, 2025
2cfee4d
Rollup merge of #141341 - folkertdev:limit-VaArgSafe-impls, r=working…
matthiaskrgr May 21, 2025
66dc879
add doc alias `replace_first` for `str::replacen`
WaffleLapkin May 21, 2025
6669d52
Auto merge of #137198 - tgross35:cfg-match-rename, r=Amanieu
bors May 22, 2025
6101e4f
Rollup merge of #141337 - RalfJung:stdarch, r=Amanieu
matthiaskrgr May 22, 2025
dc9f842
Rollup merge of #141370 - WaffleLapkin:hiiii, r=jhpratt
matthiaskrgr May 22, 2025
25d0864
Auto merge of #141379 - matthiaskrgr:rollup-g1cz0ic, r=matthiaskrgr
bors May 22, 2025
c653602
try_cast_aligned: avoid bare int-to-ptr casts
RalfJung May 22, 2025
03098d2
Rollup merge of #141130 - mejrs:use_self, r=compiler-errors
matthiaskrgr May 22, 2025
afb6519
Rollup merge of #141381 - RalfJung:try_cast_aligned-strict-provenance…
matthiaskrgr May 22, 2025
0dd69e0
docs: fix typos
Dannyyy93 May 22, 2025
10ed7f5
Auto merge of #141396 - matthiaskrgr:rollup-feg050g, r=matthiaskrgr
bors May 22, 2025
5725a5b
Remove #![feature(let_chains)] from libcore
est31 May 22, 2025
381fab5
use `cfg_select!` to select the right `VaListImpl` definition
folkertdev May 21, 2025
525ef2f
Rollup merge of #141019 - ehuss:android-doctest-xcompile, r=Mark-Simu…
matthiaskrgr May 23, 2025
4c69136
Rollup merge of #141109 - oconnor663:pipe_example, r=Mark-Simulacrum
matthiaskrgr May 23, 2025
ac71cd2
std: fix aliasing bug in UNIX process implementation
joboet Mar 24, 2025
469428a
std: add safety comments to `CStringArray`
joboet Apr 21, 2025
b47ddfa
std: sys: net: uefi: Implement TCP4 connect
Ayush1325 Apr 2, 2025
1d0a148
Rollup merge of #138896 - joboet:process_noalias, r=Noratrieb
matthiaskrgr May 23, 2025
3308e19
Rollup merge of #141065 - ehuss:wasm-doctest-xcompile, r=Mark-Simulacrum
matthiaskrgr May 23, 2025
d0b9882
Rollup merge of #141398 - Dannyyy93:typos, r=Noratrieb
matthiaskrgr May 23, 2025
48c1553
GetUserProfileDirectoryW is now documented to always store the size
RalfJung May 22, 2025
6034214
Auto merge of #141415 - est31:let_chains_libcore, r=tgross35
bors May 24, 2025
074bf43
Rollup merge of #141405 - RalfJung:GetUserProfileDirectoryW, r=ChrisD…
matthiaskrgr May 24, 2025
04c1a04
Auto merge of #141484 - matthiaskrgr:rollup-dc58owu, r=matthiaskrgr
bors May 24, 2025
0cc8a77
Use C-string literals to reduce boilerplate
tamird May 24, 2025
e4f7384
Rollup merge of #137323 - joshlf:transmute-npo, r=RalfJung
matthiaskrgr May 24, 2025
e2b0757
Rollup merge of #139254 - Ayush1325:uefi-tcp4-connect, r=joboet
matthiaskrgr May 24, 2025
dd3584c
rename internal panicking::try to catch_unwind
RalfJung May 24, 2025
5255409
Rollup merge of #140066 - thaliaarchi:const-array-as-mut-slice, r=jhp…
GuillaumeGomez May 24, 2025
24c8767
Rollup merge of #141105 - GrantBirki:grantbirki/path-tests, r=jhpratt
GuillaumeGomez May 24, 2025
b517086
Rollup merge of #141498 - tamird:cstr-example-noise, r=jhpratt
GuillaumeGomez May 24, 2025
265aa85
Rollup merge of #141505 - RalfJung:catch_unwind, r=Noratrieb
GuillaumeGomez May 24, 2025
546dd13
Rollup merge of #141108 - PaulDance:fix-extract_if-docs, r=Mark-Simul…
jhpratt May 25, 2025
1d9af0c
Rollup merge of #141361 - folkertdev:varargs-cfg, r=workingjubilee
jhpratt May 25, 2025
725b0db
Auto merge of #141086 - a1phyr:spec_advance_by, r=jhpratt
bors May 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1398,10 +1398,12 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
}

/// Creates an iterator that visits all elements (key-value pairs) in
/// ascending key order and uses a closure to determine if an element should
/// be removed. If the closure returns `true`, the element is removed from
/// the map and yielded. If the closure returns `false`, or panics, the
/// element remains in the map and will not be yielded.
/// ascending key order and uses a closure to determine if an element
/// should be removed.
///
/// If the closure returns `true`, the element is removed from the map and
/// yielded. If the closure returns `false`, or panics, the element remains
/// in the map and will not be yielded.
///
/// The iterator also lets you mutate the value of each element in the
/// closure, regardless of whether you choose to keep or remove it.
Expand Down
12 changes: 6 additions & 6 deletions alloc/src/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,20 +1124,20 @@ impl<T, A: Allocator> LinkedList<T, A> {

/// Creates an iterator which uses a closure to determine if an element should be removed.
///
/// If the closure returns true, then the element is removed and yielded.
/// If the closure returns false, the element will remain in the list and will not be yielded
/// by the iterator.
/// If the closure returns `true`, the element is removed from the list and
/// yielded. If the closure returns `false`, or panics, the element remains
/// in the list and will not be yielded.
///
/// If the returned `ExtractIf` is not exhausted, e.g. because it is dropped without iterating
/// or the iteration short-circuits, then the remaining elements will be retained.
/// Use `extract_if().for_each(drop)` if you do not need the returned iterator.
///
/// Note that `extract_if` lets you mutate every element in the filter closure, regardless of
/// whether you choose to keep or remove it.
/// The iterator also lets you mutate the value of each element in the
/// closure, regardless of whether you choose to keep or remove it.
///
/// # Examples
///
/// Splitting a list into evens and odds, reusing the original list:
/// Splitting a list into even and odd values, reusing the original list:
///
/// ```
/// use std::collections::LinkedList;
Expand Down
33 changes: 28 additions & 5 deletions alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
///
/// If [`make_contiguous`] was previously called, all elements of the
/// deque will be in the first slice and the second slice will be empty.
/// Otherwise, the exact split point depends on implementation details
/// and is not guaranteed.
///
/// [`make_contiguous`]: VecDeque::make_contiguous
///
Expand All @@ -1326,12 +1328,18 @@ impl<T, A: Allocator> VecDeque<T, A> {
/// deque.push_back(1);
/// deque.push_back(2);
///
/// assert_eq!(deque.as_slices(), (&[0, 1, 2][..], &[][..]));
/// let expected = [0, 1, 2];
/// let (front, back) = deque.as_slices();
/// assert_eq!(&expected[..front.len()], front);
/// assert_eq!(&expected[front.len()..], back);
///
/// deque.push_front(10);
/// deque.push_front(9);
///
/// assert_eq!(deque.as_slices(), (&[9, 10][..], &[0, 1, 2][..]));
/// let expected = [9, 10, 0, 1, 2];
/// let (front, back) = deque.as_slices();
/// assert_eq!(&expected[..front.len()], front);
/// assert_eq!(&expected[front.len()..], back);
/// ```
#[inline]
#[stable(feature = "deque_extras_15", since = "1.5.0")]
Expand All @@ -1347,6 +1355,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
///
/// If [`make_contiguous`] was previously called, all elements of the
/// deque will be in the first slice and the second slice will be empty.
/// Otherwise, the exact split point depends on implementation details
/// and is not guaranteed.
///
/// [`make_contiguous`]: VecDeque::make_contiguous
///
Expand All @@ -1363,9 +1373,22 @@ impl<T, A: Allocator> VecDeque<T, A> {
/// deque.push_front(10);
/// deque.push_front(9);
///
/// deque.as_mut_slices().0[0] = 42;
/// deque.as_mut_slices().1[0] = 24;
/// assert_eq!(deque.as_slices(), (&[42, 10][..], &[24, 1][..]));
/// // Since the split point is not guaranteed, we may need to update
/// // either slice.
/// let mut update_nth = |index: usize, val: u32| {
/// let (front, back) = deque.as_mut_slices();
/// if index > front.len() - 1 {
/// back[index - front.len()] = val;
/// } else {
/// front[index] = val;
/// }
/// };
///
/// update_nth(0, 42);
/// update_nth(2, 24);
///
/// let v: Vec<_> = deque.into();
/// assert_eq!(v, [42, 10, 24, 1]);
/// ```
#[inline]
#[stable(feature = "deque_extras_15", since = "1.5.0")]
Expand Down
11 changes: 7 additions & 4 deletions alloc/src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ use crate::boxed::Box;
use crate::vec::Vec;

impl<T> [T] {
/// Sorts the slice, preserving initial order of equal elements.
/// Sorts the slice in ascending order, preserving initial order of equal elements.
///
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*n* \* log(*n*))
/// worst-case.
Expand Down Expand Up @@ -137,7 +137,8 @@ impl<T> [T] {
stable_sort(self, T::lt);
}

/// Sorts the slice with a comparison function, preserving initial order of equal elements.
/// Sorts the slice in ascending order with a comparison function, preserving initial order of
/// equal elements.
///
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*n* \* log(*n*))
/// worst-case.
Expand Down Expand Up @@ -197,7 +198,8 @@ impl<T> [T] {
stable_sort(self, |a, b| compare(a, b) == Less);
}

/// Sorts the slice with a key extraction function, preserving initial order of equal elements.
/// Sorts the slice in ascending order with a key extraction function, preserving initial order
/// of equal elements.
///
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*m* \* *n* \* log(*n*))
/// worst-case, where the key function is *O*(*m*).
Expand Down Expand Up @@ -252,7 +254,8 @@ impl<T> [T] {
stable_sort(self, |a, b| f(a).lt(&f(b)));
}

/// Sorts the slice with a key extraction function, preserving initial order of equal elements.
/// Sorts the slice in ascending order with a key extraction function, preserving initial order
/// of equal elements.
///
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*m* \* *n* + *n* \*
/// log(*n*)) worst-case, where the key function is *O*(*m*).
Expand Down
1 change: 1 addition & 0 deletions alloc/src/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ impl str {
/// ```
#[cfg(not(no_global_oom_handling))]
#[rustc_allow_incoherent_impl]
#[doc(alias = "replace_first")]
#[must_use = "this returns the replaced string as a new allocation, \
without modifying the original"]
#[stable(feature = "str_replacen", since = "1.16.0")]
Expand Down
14 changes: 7 additions & 7 deletions alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3648,11 +3648,11 @@ impl<T, A: Allocator> Vec<T, A> {
Splice { drain: self.drain(range), replace_with: replace_with.into_iter() }
}

/// Creates an iterator which uses a closure to determine if element in the range should be removed.
/// Creates an iterator which uses a closure to determine if an element in the range should be removed.
///
/// If the closure returns true, then the element is removed and yielded.
/// If the closure returns false, the element will remain in the vector and will not be yielded
/// by the iterator.
/// If the closure returns `true`, the element is removed from the vector
/// and yielded. If the closure returns `false`, or panics, the element
/// remains in the vector and will not be yielded.
///
/// Only elements that fall in the provided range are considered for extraction, but any elements
/// after the range will still have to be moved if any element has been extracted.
Expand Down Expand Up @@ -3692,16 +3692,16 @@ impl<T, A: Allocator> Vec<T, A> {
/// But `extract_if` is easier to use. `extract_if` is also more efficient,
/// because it can backshift the elements of the array in bulk.
///
/// Note that `extract_if` also lets you mutate the elements passed to the filter closure,
/// regardless of whether you choose to keep or remove them.
/// The iterator also lets you mutate the value of each element in the
/// closure, regardless of whether you choose to keep or remove it.
///
/// # Panics
///
/// If `range` is out of bounds.
///
/// # Examples
///
/// Splitting an array into evens and odds, reusing the original allocation:
/// Splitting a vector into even and odd values, reusing the original vector:
///
/// ```
/// let mut numbers = vec![1, 2, 3, 4, 5, 6, 8, 9, 11, 13, 14, 15];
Expand Down
2 changes: 1 addition & 1 deletion core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ impl<T, const N: usize> [T; N] {
/// Returns a mutable slice containing the entire array. Equivalent to
/// `&mut s[..]`.
#[stable(feature = "array_as_slice", since = "1.57.0")]
#[rustc_const_unstable(feature = "const_array_as_mut_slice", issue = "133333")]
#[rustc_const_stable(feature = "const_array_as_mut_slice", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_mut_slice(&mut self) -> &mut [T] {
self
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ pub trait Into<T>: Sized {
#[rustc_diagnostic_item = "From"]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_on_unimplemented(on(
all(_Self = "&str", T = "alloc::string::String"),
all(Self = "&str", T = "alloc::string::String"),
note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix",
))]
#[doc(search_unbox)]
Expand Down
41 changes: 7 additions & 34 deletions core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,13 +511,8 @@ impl CStr {
/// # Examples
///
/// ```
/// use std::ffi::CStr;
///
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").unwrap();
/// assert_eq!(cstr.count_bytes(), 3);
///
/// let cstr = CStr::from_bytes_with_nul(b"\0").unwrap();
/// assert_eq!(cstr.count_bytes(), 0);
/// assert_eq!(c"foo".count_bytes(), 3);
/// assert_eq!(c"".count_bytes(), 0);
/// ```
#[inline]
#[must_use]
Expand All @@ -533,19 +528,8 @@ impl CStr {
/// # Examples
///
/// ```
/// use std::ffi::CStr;
/// # use std::ffi::FromBytesWithNulError;
///
/// # fn main() { test().unwrap(); }
/// # fn test() -> Result<(), FromBytesWithNulError> {
/// let cstr = CStr::from_bytes_with_nul(b"foo\0")?;
/// assert!(!cstr.is_empty());
///
/// let empty_cstr = CStr::from_bytes_with_nul(b"\0")?;
/// assert!(empty_cstr.is_empty());
/// assert!(!c"foo".is_empty());
/// assert!(c"".is_empty());
/// # Ok(())
/// # }
/// ```
#[inline]
#[stable(feature = "cstr_is_empty", since = "1.71.0")]
Expand All @@ -569,10 +553,7 @@ impl CStr {
/// # Examples
///
/// ```
/// use std::ffi::CStr;
///
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
/// assert_eq!(cstr.to_bytes(), b"foo");
/// assert_eq!(c"foo".to_bytes(), b"foo");
/// ```
#[inline]
#[must_use = "this returns the result of the operation, \
Expand All @@ -598,10 +579,7 @@ impl CStr {
/// # Examples
///
/// ```
/// use std::ffi::CStr;
///
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
/// assert_eq!(cstr.to_bytes_with_nul(), b"foo\0");
/// assert_eq!(c"foo".to_bytes_with_nul(), b"foo\0");
/// ```
#[inline]
#[must_use = "this returns the result of the operation, \
Expand All @@ -623,10 +601,8 @@ impl CStr {
///
/// ```
/// #![feature(cstr_bytes)]
/// use std::ffi::CStr;
///
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
/// assert!(cstr.bytes().eq(*b"foo"));
/// assert!(c"foo".bytes().eq(*b"foo"));
/// ```
#[inline]
#[unstable(feature = "cstr_bytes", issue = "112115")]
Expand All @@ -645,10 +621,7 @@ impl CStr {
/// # Examples
///
/// ```
/// use std::ffi::CStr;
///
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
/// assert_eq!(cstr.to_str(), Ok("foo"));
/// assert_eq!(c"foo".to_str(), Ok("foo"));
/// ```
#[stable(feature = "cstr_to_str", since = "1.4.0")]
#[rustc_const_stable(feature = "const_cstr_methods", since = "1.72.0")]
Expand Down
2 changes: 1 addition & 1 deletion core/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub mod c_str;
issue = "44930",
reason = "the `c_variadic` feature has not been properly tested on all supported platforms"
)]
pub use self::va_list::{VaList, VaListImpl};
pub use self::va_list::{VaArgSafe, VaList, VaListImpl};

#[unstable(
feature = "c_variadic",
Expand Down
6 changes: 3 additions & 3 deletions core/src/ffi/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type_alias! { "c_float.md", c_float = f32; }
type_alias! { "c_double.md", c_double = f64; }

mod c_char_definition {
crate::cfg_match! {
crate::cfg_select! {
// These are the targets on which c_char is unsigned. Usually the
// signedness is the same for all target_os values on a given architecture
// but there are some exceptions (see isSignedCharDefault() in clang).
Expand Down Expand Up @@ -133,7 +133,7 @@ mod c_char_definition {
}

mod c_long_definition {
crate::cfg_match! {
crate::cfg_select! {
any(
all(target_pointer_width = "64", not(windows)),
// wasm32 Linux ABI uses 64-bit long
Expand Down Expand Up @@ -172,7 +172,7 @@ pub type c_ptrdiff_t = isize;
pub type c_ssize_t = isize;

mod c_int_definition {
crate::cfg_match! {
crate::cfg_select! {
any(target_arch = "avr", target_arch = "msp430") => {
pub(super) type c_int = i16;
pub(super) type c_uint = u16;
Expand Down
Loading