Skip to content

Update subtree/library to 2025-06-17 #391

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

Open
wants to merge 70 commits into
base: subtree/library
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
15c9113
Added `Clone` implementation for `ChunkBy`
nwoods-cimpress Mar 4, 2025
63b6269
Changing #[stable] tag
nwoods-cimpress Mar 6, 2025
18c317f
Update ABI compatibility docs about null-pointer-optimized enums.
zachs18 Jun 3, 2025
da05950
add Vec::peek_mut
Qelxiros Jun 4, 2025
c6bfd75
fix tests
Qelxiros Jun 6, 2025
78367f4
float tests: use assert_biteq in more places
RalfJung Jun 9, 2025
42d5214
float tests: deduplicate min, max, and rounding tests
RalfJung Jun 9, 2025
4794332
make the default float comparison tolerance type-dependent
RalfJung Jun 9, 2025
b734b89
float midpoint tests: add missing NAN cases
RalfJung Jun 9, 2025
d232aa2
compiler-builtins: Remove unused `lints.rust` table
tgross35 Jun 10, 2025
3e892fc
ci: Fix a typo that was causing a command failure
tgross35 Jun 10, 2025
cdfe508
core docs: improve clarity of considerations about atomic CAS operations
fu5ha Jun 10, 2025
2b61cdc
Fix Debug for Location.
m-ou-se Jun 11, 2025
c842466
Update dependencies in `library/Cargo.lock`
tgross35 Jun 10, 2025
743d005
Upgrade the standard library `object` version
tgross35 Jun 10, 2025
b8e0586
Upgrade the standard library `addr2line` version
tgross35 Jun 10, 2025
9901c63
Upgrade the standard library `unwinding` version
tgross35 Jun 11, 2025
fcb45d0
update docs, test
Qelxiros Jun 12, 2025
8c8ed8f
Allow `unpredictable_function_pointer_comparisons` lint in more places
Urgau Dec 19, 2024
fd45ff2
chore(doctest): Remove redundant blank lines
sorairolake Jun 12, 2025
e51e83b
Update the stdarch submodule
tgross35 Jun 10, 2025
05269b7
Tracking the old name of renamed unstable library attribute
xizheyin Jun 7, 2025
0cc8ed7
intrinsics: rename min_align_of to align_of
RalfJung Jun 12, 2025
d304405
Delegate `<CStr as Debug>` to `ByteStr`
tamird Apr 18, 2025
3e87680
Rollup merge of #138016 - nwoods-cimpress:slice_chunkby_clone, r=dtolnay
matthiaskrgr Jun 12, 2025
f0c3afe
Rollup merge of #141947 - zachs18:patch-4, r=workingjubilee,traviscross
matthiaskrgr Jun 12, 2025
058c23d
Rollup merge of #142252 - fu5ha:doc-cas-ops, r=ibraheemdev
matthiaskrgr Jun 12, 2025
250a301
Rollup merge of #134536 - Urgau:fn-ptr-option, r=compiler-errors,trav…
matthiaskrgr Jun 12, 2025
a78ed82
Rollup merge of #142402 - sorairolake:remove-blank-line, r=workingjub…
matthiaskrgr Jun 12, 2025
83376b4
Delegate `<SocketAddr as Debug>` to `ByteStr`
tamird May 24, 2025
1b28bd0
Unimplement unsized_locals
mejrs Jun 12, 2025
5c3c860
Rollup merge of #141491 - tamird:cstr-debug-bstr, r=joshtriplett
matthiaskrgr Jun 13, 2025
d430461
Rollup merge of #142158 - xizheyin:141617, r=jdonszelmann
matthiaskrgr Jun 13, 2025
2d34b82
Rollup merge of #142410 - RalfJung:align_of, r=WaffleLapkin,workingju…
matthiaskrgr Jun 13, 2025
9298508
Rollup merge of #142274 - tgross35:update-stdarch, r=Amanieu
matthiaskrgr Jun 13, 2025
5442843
Rollup merge of #142276 - tgross35:update-library-lockfile, r=Mark-Si…
matthiaskrgr Jun 13, 2025
7cbbd14
Rollup merge of #142308 - tgross35:upgrade-library-object, r=Mark-Sim…
matthiaskrgr Jun 13, 2025
eadae1c
Auto merge of #142432 - matthiaskrgr:rollup-ziuls9y, r=matthiaskrgr
bors Jun 13, 2025
34cc200
Eliminate `build.rs`-generated Aarch64 atomic macros (#951)
qinghon Jun 13, 2025
3ab6f9e
tweak runtime/const macro management
RalfJung Jun 13, 2025
f3f8717
Remove "intermittent" wording from `ReadDir`
ChrisDenton Jun 13, 2025
0c78395
Auto merge of #142442 - matthiaskrgr:rollup-6yodjfx, r=matthiaskrgr
bors Jun 13, 2025
cd55106
doc: mention that intrinsics should not be called in user code
scrabsha Jun 13, 2025
654284e
fmaximum,fminimum: Fix incorrect result and add tests
tgross35 Jun 2, 2025
25c15fc
Clean up and sort manifest keys
tgross35 Jun 13, 2025
8a585bf
Auto merge of #142443 - matthiaskrgr:rollup-l1l6d0v, r=matthiaskrgr
bors Jun 13, 2025
c8e789e
Mark compiler-builtins as `publish = false`
tgross35 Jun 13, 2025
3aeeea5
Remove unneeded lifetimes from signature of BTreeSet::extract_if
dtolnay Jun 14, 2025
3a28dcf
Delete `.release-plz.toml`
tgross35 Jun 14, 2025
9fc5828
Rollup merge of #142046 - Qelxiros:122742-vec_peek_mut, r=cuviper
workingjubilee Jun 14, 2025
ad9a9a5
Rollup merge of #142439 - scrabsha:rust/sasha/uwkqrkztvqry, r=RalfJung
workingjubilee Jun 14, 2025
4115287
Rollup merge of #142452 - ChrisDenton:intermittent, r=Noratrieb
workingjubilee Jun 14, 2025
2beeeab
Update the upstream Rust version
tgross35 Jun 14, 2025
ab08040
Merge ref 'd087f112b7d1:/library/compiler-builtins' from https://gith…
tgross35 Jun 14, 2025
7f084e8
Work around out-of-tree testing with a shim crate
tgross35 Jun 14, 2025
2506df3
Rollup merge of #141493 - tamird:addreskind-bytestr, r=joshtriplett
matthiaskrgr Jun 14, 2025
a19aee9
Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errors
matthiaskrgr Jun 14, 2025
d4119db
Rollup merge of #142243 - RalfJung:float-test-dedup, r=tgross35
matthiaskrgr Jun 14, 2025
1ac4f86
Rollup merge of #142484 - dtolnay:bsetextract, r=m-ou-se
matthiaskrgr Jun 14, 2025
8ef42ec
Rollup merge of #142489 - tgross35:update-builtins, r=tgross35
matthiaskrgr Jun 14, 2025
7204ad4
Remove all support for wasm's legacy ABI
bjorn3 Dec 6, 2024
4136fda
Stabilize "file_lock" feature
cberner May 29, 2025
871de6e
Rollup merge of #133952 - bjorn3:remove_wasm_legacy_abi, r=alexcrichton
fmease Jun 15, 2025
2037fc5
Test Debug for Location.
m-ou-se Jun 11, 2025
d91ee16
Update the `backtrace` submodule
tgross35 Jun 16, 2025
1ac5cf0
Add documentation for `PathBuf`'s `FromIterator` and `Extend` impls
yotamofek Jun 9, 2025
febe645
Rollup merge of #142125 - cberner:file_lock_stable, r=ChrisDenton
Kobzol Jun 16, 2025
ea6401f
Rollup merge of #142236 - yotamofek:pr/std/pathbuf-extend-docs, r=tgr…
Kobzol Jun 16, 2025
1befb80
Rollup merge of #142373 - m-ou-se:debug-for-location, r=tgross35
Kobzol Jun 16, 2025
3b96c9b
Rollup merge of #142562 - tgross35:update-backtrace, r=workingjubilee
Kobzol Jun 16, 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
69 changes: 28 additions & 41 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,11 +1220,11 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
/// assert_eq!(high.into_iter().collect::<Vec<_>>(), [4, 5, 6, 7]);
/// ```
#[unstable(feature = "btree_extract_if", issue = "70530")]
pub fn extract_if<'a, F, R>(&'a mut self, range: R, pred: F) -> ExtractIf<'a, T, R, F, A>
pub fn extract_if<F, R>(&mut self, range: R, pred: F) -> ExtractIf<'_, T, R, F, A>
where
T: Ord,
R: RangeBounds<T>,
F: 'a + FnMut(&T) -> bool,
F: FnMut(&T) -> bool,
{
let (inner, alloc) = self.map.extract_if_inner(range);
ExtractIf { pred, inner, alloc }
Expand Down Expand Up @@ -1585,11 +1585,11 @@ where
}

#[unstable(feature = "btree_extract_if", issue = "70530")]
impl<'a, T, R, F, A: Allocator + Clone> Iterator for ExtractIf<'_, T, R, F, A>
impl<T, R, F, A: Allocator + Clone> Iterator for ExtractIf<'_, T, R, F, A>
where
T: PartialOrd,
R: RangeBounds<T>,
F: 'a + FnMut(&T) -> bool,
F: FnMut(&T) -> bool,
{
type Item = T;

Expand Down
2 changes: 2 additions & 0 deletions alloc/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ impl ops::Deref for CString {
}
}

/// Delegates to the [`CStr`] implementation of [`fmt::Debug`],
/// showing invalid UTF-8 as hex escapes.
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for CString {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
32 changes: 32 additions & 0 deletions alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ mod in_place_collect;

mod partial_eq;

#[unstable(feature = "vec_peek_mut", issue = "122742")]
pub use self::peek_mut::PeekMut;

mod peek_mut;

#[cfg(not(no_global_oom_handling))]
use self::spec_from_elem::SpecFromElem;

Expand Down Expand Up @@ -729,6 +734,33 @@ impl<T> Vec<T> {
pub unsafe fn from_parts(ptr: NonNull<T>, length: usize, capacity: usize) -> Self {
unsafe { Self::from_parts_in(ptr, length, capacity, Global) }
}

/// Returns a mutable reference to the last item in the vector, or
/// `None` if it is empty.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(vec_peek_mut)]
/// let mut vec = Vec::new();
/// assert!(vec.peek_mut().is_none());
///
/// vec.push(1);
/// vec.push(5);
/// vec.push(2);
/// assert_eq!(vec.last(), Some(&2));
/// if let Some(mut val) = vec.peek_mut() {
/// *val = 0;
/// }
/// assert_eq!(vec.last(), Some(&0));
/// ```
#[inline]
#[unstable(feature = "vec_peek_mut", issue = "122742")]
pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T>> {
PeekMut::new(self)
}
}

impl<T, A: Allocator> Vec<T, A> {
Expand Down
55 changes: 55 additions & 0 deletions alloc/src/vec/peek_mut.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
use core::ops::{Deref, DerefMut};

use super::Vec;
use crate::fmt;

/// Structure wrapping a mutable reference to the last item in a
/// `Vec`.
///
/// This `struct` is created by the [`peek_mut`] method on [`Vec`]. See
/// its documentation for more.
///
/// [`peek_mut`]: Vec::peek_mut
#[unstable(feature = "vec_peek_mut", issue = "122742")]
pub struct PeekMut<'a, T> {
vec: &'a mut Vec<T>,
}

#[unstable(feature = "vec_peek_mut", issue = "122742")]
impl<T: fmt::Debug> fmt::Debug for PeekMut<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("PeekMut").field(self.deref()).finish()
}
}

impl<'a, T> PeekMut<'a, T> {
pub(crate) fn new(vec: &'a mut Vec<T>) -> Option<Self> {
if vec.is_empty() { None } else { Some(Self { vec }) }
}

/// Removes the peeked value from the vector and returns it.
#[unstable(feature = "vec_peek_mut", issue = "122742")]
pub fn pop(self) -> T {
// SAFETY: PeekMut is only constructed if the vec is non-empty
unsafe { self.vec.pop().unwrap_unchecked() }
}
}

#[unstable(feature = "vec_peek_mut", issue = "122742")]
impl<'a, T> Deref for PeekMut<'a, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
// SAFETY: PeekMut is only constructed if the vec is non-empty
unsafe { self.vec.get_unchecked(self.vec.len() - 1) }
}
}

#[unstable(feature = "vec_peek_mut", issue = "122742")]
impl<'a, T> DerefMut for PeekMut<'a, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
let idx = self.vec.len() - 1;
// SAFETY: PeekMut is only constructed if the vec is non-empty
unsafe { self.vec.get_unchecked_mut(idx) }
}
}
1 change: 1 addition & 0 deletions alloctests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#![feature(vec_deque_truncate_front)]
#![feature(unique_rc_arc)]
#![feature(macro_metavar_expr_concat)]
#![feature(vec_peek_mut)]
#![allow(internal_features)]
#![deny(fuzzy_provenance_casts)]
#![deny(unsafe_op_in_unsafe_fn)]
Expand Down
13 changes: 13 additions & 0 deletions alloctests/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,19 @@ fn test_chunk_by() {
assert_eq!(iter.next_back(), Some(&[1][..]));
assert_eq!(iter.next(), Some(&[2, 2, 2][..]));
assert_eq!(iter.next_back(), None);

let mut iter = slice.chunk_by(|a, b| a == b);
assert_eq!(iter.next(), Some(&[1, 1, 1][..]));
assert_eq!(iter.next(), Some(&[3, 3][..]));
let mut iter_clone = iter.clone();
assert_eq!(iter.next(), Some(&[2, 2, 2][..]));
assert_eq!(iter.next(), Some(&[1][..]));
assert_eq!(iter.next(), Some(&[0][..]));
assert_eq!(iter.next(), None);
assert_eq!(iter_clone.next(), Some(&[2, 2, 2][..]));
assert_eq!(iter_clone.next(), Some(&[1][..]));
assert_eq!(iter_clone.next(), Some(&[0][..]));
assert_eq!(iter_clone.next(), None);
}

#[test]
Expand Down
17 changes: 17 additions & 0 deletions alloctests/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2698,6 +2698,23 @@ fn test_pop_if_mutates() {
assert_eq!(v, [2]);
}

#[test]
fn test_peek_mut() {
let mut vec = Vec::new();
assert!(vec.peek_mut().is_none());
vec.push(1);
vec.push(2);
if let Some(mut p) = vec.peek_mut() {
assert_eq!(*p, 2);
*p = 0;
assert_eq!(*p, 0);
p.pop();
assert_eq!(vec.len(), 1);
} else {
unreachable!()
}
}

/// This assortment of tests, in combination with miri, verifies we handle UB on fishy arguments
/// in the stdlib. Draining and extending the allocation are fairly well-tested earlier, but
/// `vec.insert(usize::MAX, val)` once slipped by!
Expand Down
2 changes: 1 addition & 1 deletion backtrace
Submodule backtrace updated from 6c882e to b65ab9
Loading