Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
8f480dc
[std][BTree] Create tests for keys which can be `==` without being id…
tinnamchoi Aug 19, 2025
c5b673f
[std][BTree] Fix behavior of `::append` to match documentation and `:…
tinnamchoi Aug 19, 2025
f6da636
[std][BTree] Update tests
tinnamchoi Aug 19, 2025
c7e3867
[std][BTree] Update doc-comment
tinnamchoi Aug 20, 2025
8dca377
[std][BTree] Update `::append` docs
tinnamchoi Aug 21, 2025
e45d954
Stabilize maybe_uninit_write_slice
thaliaarchi Oct 22, 2025
5fdae2c
`DropGuard::into_inner` -> `DropGuard::dismiss`
yoshuawuyts Nov 6, 2025
77e087b
Fix tests
yoshuawuyts Nov 6, 2025
dd74346
Update drop_guard.rs
yoshuawuyts Nov 6, 2025
c2b0f92
Add Command::get_env_clear
schneems Nov 19, 2025
395ab82
Stabilize `unchecked_neg` and `unchecked_shifts`
nxsaken Nov 19, 2025
ef0ff5b
In `BTreeMap::eq`, do not compare the elements if the sizes are diffe…
zachs18 Nov 20, 2025
83018d0
Add regression test for collections' PartialEq::eq impls not comparin…
zachs18 Nov 20, 2025
d6d165b
Revise the notes about atomics on Arm.
thejpster Nov 23, 2025
8981b94
intrinsics: clarify float min/max behavios for NaNs and signed zeros
RalfJung Nov 23, 2025
04cb2f9
add NaN examples to public min/max functions
RalfJung Nov 24, 2025
42aa610
implement and test `Iterator::{exactly_one, collect_array}`
jdonszelmann Nov 24, 2025
f608ed2
num: Implement `uint_gather_scatter_bits` feature for unsigned integers
okaneco Nov 19, 2025
f8dfb21
Suggest _bytes versions of endian-converting methods
kornelski Nov 25, 2025
fba1b88
Motor OS: make decode_error_kind more comprehensive
lasiotus Nov 25, 2025
997f256
Add a diagnostic attribute for special casing const bound errors for …
oli-obk Nov 6, 2025
4620a83
float::clamp: make treatment of signed zeros unspecified
RalfJung Nov 23, 2025
13cb0c4
Fix typo in comment.
m-ou-se Nov 26, 2025
e3153fa
Show backtrace on allocation failures when possible
bjorn3 Oct 15, 2025
47d26d9
optimize slice::Iter::next_chunk
bend-n Nov 20, 2025
430b4c5
Rollup merge of #148048 - thaliaarchi:stabilize-maybeuninit-write-sli…
Zalathar Nov 27, 2025
f0a5a4b
Rollup merge of #148641 - oli-obk:push-olzwqxsmnxmz, r=jackh726
Zalathar Nov 27, 2025
d4f62b6
Rollup merge of #149074 - schneems:schneems/get_env_clear, r=Mark-Sim…
Zalathar Nov 27, 2025
887145f
Rollup merge of #149097 - okaneco:gather_scatter_bits, r=Mark-Simulacrum
Zalathar Nov 27, 2025
e39c6d6
Rollup merge of #149131 - bend-n:optimize_slice_iter_next_chunk, r=Ma…
Zalathar Nov 27, 2025
7291847
Rollup merge of #149239 - RalfJung:float-intrinsics, r=tgross35
Zalathar Nov 27, 2025
d7a927c
Rollup merge of #149301 - moturus:main, r=Mark-Simulacrum
Zalathar Nov 27, 2025
f33718f
Rollup merge of #149238 - RalfJung:clamp-signed-zeros, r=Amanieu
Zalathar Nov 27, 2025
5f1ac62
Rollup merge of #149270 - jdonszelmann:exact-length-collection, r=Mar…
Zalathar Nov 27, 2025
072eb13
Rollup merge of #149295 - kornelski:endian_bytes, r=Mark-Simulacrum
Zalathar Nov 27, 2025
dd5d58e
Rollup merge of #149349 - m-ou-se:fmt-arg-comment-typo, r=Mark-Simula…
Zalathar Nov 27, 2025
e052b65
Auto merge of #149370 - Zalathar:rollup-6fkk5x4, r=Zalathar
bors Nov 27, 2025
410eeb8
stabilize maybe_uninit_slice
bend-n Nov 19, 2025
fcf4e97
fix
bend-n Nov 19, 2025
d9a0d71
Add `impl TrustedLen` on `BTree{Map,Set}` iterators
yotamofek Nov 27, 2025
c46aaed
tests
bend-n Sep 26, 2025
419b3fd
constify from_fn, try_from_fn, try_map, map
bend-n Oct 12, 2025
8684698
redo the drain
bend-n Nov 24, 2025
f3f1687
Rollup merge of #148589 - yoshuawuyts:DropGuard-dismiss, r=joshtriplett
matthiaskrgr Nov 27, 2025
473f8c2
float::minimum/maximum: say which exact IEEE operation this correspon…
RalfJung Nov 27, 2025
0b464e2
Remove outdated comment
yotamofek Nov 27, 2025
0391420
Rollup merge of #149381 - yotamofek:pr/library/btree-iter-trustedlen,…
matthiaskrgr Nov 27, 2025
57220a5
Auto merge of #149397 - matthiaskrgr:rollup-go79y6a, r=matthiaskrgr
bors Nov 27, 2025
5932f10
Use System allocator for thread-local storage
orlp Jul 25, 2025
e307e6c
Use spinlock for ThreadId if 64-bit atomic unavailable
orlp Jul 26, 2025
2b5fe5f
Add documentation guaranteeing global allocator use of TLS
orlp Jul 29, 2025
da9c797
Ensure set_current is called early during thread init
orlp Sep 21, 2025
323be84
Address review comments
orlp Oct 1, 2025
033b726
Use checked_add instead of manual overflow check
orlp Oct 1, 2025
f7a7e9e
Fix SGX implementation
orlp Oct 2, 2025
74da5ae
Add inline(never) to prevent reordering after TLS has been destroyed
orlp Oct 2, 2025
eeb2c5d
Silence dead code warning for ThreadInit::init
orlp Nov 27, 2025
fa06284
Add missing feature flag
orlp Nov 28, 2025
206df2d
Rollup merge of #149087 - nxsaken:unchecked_neg_shifts_stabilize, r=A…
Zalathar Nov 28, 2025
60b354a
Auto merge of #148020 - bjorn3:oom_backtrace, r=Mark-Simulacrum
bors Nov 28, 2025
7cb04de
Auto merge of #144465 - orlp:system-alloc-tls, r=Mark-Simulacrum
bors Nov 29, 2025
938b82c
Rollup merge of #149395 - RalfJung:float-minimum, r=scottmcm
jhpratt Nov 29, 2025
6537bf9
Rollup merge of #149396 - yotamofek:pr/library/outdated-comment, r=ch…
jhpratt Nov 29, 2025
b5dacca
Auto merge of #149441 - jhpratt:rollup-4hmqc0z, r=jhpratt
bors Nov 29, 2025
500b8aa
std: sys: fs: uefi: Implement rmdir and unlink
Ayush1325 Nov 18, 2025
c2befae
std: split up the `thread` module (preparation)
joboet Nov 29, 2025
c241fbc
std: split up the `thread` module
joboet Nov 9, 2025
32fb499
std: update broken links in `thread` module
joboet Nov 9, 2025
6be62c9
Rollup merge of #148765 - joboet:split-up-thread, r=ChrisDenton
matthiaskrgr Nov 29, 2025
2804b7b
Clarify edge cases for Barrier::new
tisonkun Nov 23, 2025
1732c00
float::min/max: reference NaN bit pattern rules
RalfJung Nov 30, 2025
539ebbd
Rollup merge of #149236 - tisonkun:patch-1, r=tgross35
matthiaskrgr Nov 30, 2025
aa5eba6
Rollup merge of #149475 - RalfJung:min-max-nan, r=tgross35
matthiaskrgr Nov 30, 2025
a74fc42
ThreadId generation fallback path: avoid spurious yields
RalfJung Nov 30, 2025
7957796
Implement `clamp_magnitude` for floats & signed integers
IntegralPilot Nov 8, 2025
4fc95c1
Auto merge of #149481 - RalfJung:threadid-fallback, r=joboet
bors Dec 1, 2025
b390083
Rollup merge of #148690 - IntegralPilot:clamp-mag, r=joboet
matthiaskrgr Dec 1, 2025
dd2f90f
Rollup merge of #149102 - bend-n:maybe_uninit_slice, r=joboet
matthiaskrgr Dec 1, 2025
a785e96
Rollup merge of #145628 - tinnamchoi:fix-btree-append, r=Amanieu
Zalathar Dec 2, 2025
b8a027a
Rollup merge of #149241 - thejpster:fix-armv4t-armv5te-bare-metal, r=…
Zalathar Dec 2, 2025
88f8387
Auto merge of #149125 - zachs18:btreemap-eq-perf, r=workingjubilee
bors Dec 2, 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
4 changes: 2 additions & 2 deletions Cargo.lock

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

9 changes: 7 additions & 2 deletions alloc/src/collections/btree/append.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,14 @@ where
{
type Item = (K, V);

/// If two keys are equal, returns the key-value pair from the right source.
/// If two keys are equal, returns the key from the left and the value from the right.
fn next(&mut self) -> Option<(K, V)> {
let (a_next, b_next) = self.0.nexts(|a: &(K, V), b: &(K, V)| K::cmp(&a.0, &b.0));
b_next.or(a_next)
match (a_next, b_next) {
(Some((a_k, _)), Some((_, b_v))) => Some((a_k, b_v)),
(Some(a), None) => Some(a),
(None, Some(b)) => Some(b),
(None, None) => None,
}
}
}
32 changes: 30 additions & 2 deletions alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::cmp::Ordering;
use core::error::Error;
use core::fmt::{self, Debug};
use core::hash::{Hash, Hasher};
use core::iter::FusedIterator;
use core::iter::{FusedIterator, TrustedLen};
use core::marker::PhantomData;
use core::mem::{self, ManuallyDrop};
use core::ops::{Bound, Index, RangeBounds};
Expand Down Expand Up @@ -1181,6 +1181,10 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
///
/// If a key from `other` is already present in `self`, the respective
/// value from `self` will be overwritten with the respective value from `other`.
/// Similar to [`insert`], though, the key is not overwritten,
/// which matters for types that can be `==` without being identical.
///
/// [`insert`]: BTreeMap::insert
///
/// # Examples
///
Expand Down Expand Up @@ -1624,6 +1628,9 @@ impl<K, V> ExactSizeIterator for Iter<'_, K, V> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V> TrustedLen for Iter<'_, K, V> {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<K, V> Clone for Iter<'_, K, V> {
fn clone(&self) -> Self {
Expand Down Expand Up @@ -1696,6 +1703,9 @@ impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V> TrustedLen for IterMut<'_, K, V> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<K, V> FusedIterator for IterMut<'_, K, V> {}

Expand Down Expand Up @@ -1817,6 +1827,9 @@ impl<K, V, A: Allocator + Clone> ExactSizeIterator for IntoIter<K, V, A> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V, A: Allocator + Clone> TrustedLen for IntoIter<K, V, A> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<K, V, A: Allocator + Clone> FusedIterator for IntoIter<K, V, A> {}

Expand Down Expand Up @@ -1865,6 +1878,9 @@ impl<K, V> ExactSizeIterator for Keys<'_, K, V> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V> TrustedLen for Keys<'_, K, V> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<K, V> FusedIterator for Keys<'_, K, V> {}

Expand Down Expand Up @@ -1920,6 +1936,9 @@ impl<K, V> ExactSizeIterator for Values<'_, K, V> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V> TrustedLen for Values<'_, K, V> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<K, V> FusedIterator for Values<'_, K, V> {}

Expand Down Expand Up @@ -2160,6 +2179,9 @@ impl<K, V> ExactSizeIterator for ValuesMut<'_, K, V> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V> TrustedLen for ValuesMut<'_, K, V> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<K, V> FusedIterator for ValuesMut<'_, K, V> {}

Expand Down Expand Up @@ -2222,6 +2244,9 @@ impl<K, V, A: Allocator + Clone> ExactSizeIterator for IntoKeys<K, V, A> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V, A: Allocator + Clone> TrustedLen for IntoKeys<K, V, A> {}

#[stable(feature = "map_into_keys_values", since = "1.54.0")]
impl<K, V, A: Allocator + Clone> FusedIterator for IntoKeys<K, V, A> {}

Expand Down Expand Up @@ -2273,6 +2298,9 @@ impl<K, V, A: Allocator + Clone> ExactSizeIterator for IntoValues<K, V, A> {
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<K, V, A: Allocator + Clone> TrustedLen for IntoValues<K, V, A> {}

#[stable(feature = "map_into_keys_values", since = "1.54.0")]
impl<K, V, A: Allocator + Clone> FusedIterator for IntoValues<K, V, A> {}

Expand Down Expand Up @@ -2416,7 +2444,7 @@ impl<K, V> Default for BTreeMap<K, V> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<K: PartialEq, V: PartialEq, A: Allocator + Clone> PartialEq for BTreeMap<K, V, A> {
fn eq(&self, other: &BTreeMap<K, V, A>) -> bool {
self.iter().eq(other)
self.len() == other.len() && self.iter().zip(other).all(|(a, b)| a == b)
}
}

Expand Down
34 changes: 31 additions & 3 deletions alloc/src/collections/btree/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::fmt::Debug;
use crate::rc::Rc;
use crate::string::{String, ToString};
use crate::testing::crash_test::{CrashTestDummy, Panic};
use crate::testing::ord_chaos::{Cyclic3, Governed, Governor};
use crate::testing::ord_chaos::{Cyclic3, Governed, Governor, IdBased};
use crate::testing::rng::DeterministicRng;

// Minimum number of elements to insert, to guarantee a tree with 2 levels,
Expand Down Expand Up @@ -2137,9 +2137,9 @@ fn test_append_drop_leak() {
let mut left = BTreeMap::new();
let mut right = BTreeMap::new();
left.insert(a.spawn(Panic::Never), ());
left.insert(b.spawn(Panic::InDrop), ()); // first duplicate key, dropped during append
left.insert(b.spawn(Panic::Never), ());
left.insert(c.spawn(Panic::Never), ());
right.insert(b.spawn(Panic::Never), ());
right.insert(b.spawn(Panic::InDrop), ()); // first duplicate key, dropped during append
right.insert(c.spawn(Panic::Never), ());

catch_unwind(move || left.append(&mut right)).unwrap_err();
Expand Down Expand Up @@ -2587,3 +2587,31 @@ fn cursor_peek_prev_agrees_with_cursor_mut() {
let prev = cursor.peek_prev();
assert_matches!(prev, Some((&3, _)));
}

#[test]
fn test_id_based_insert() {
let mut lhs = BTreeMap::new();
let mut rhs = BTreeMap::new();

lhs.insert(IdBased { id: 0, name: "lhs_k".to_string() }, "lhs_v".to_string());
rhs.insert(IdBased { id: 0, name: "rhs_k".to_string() }, "rhs_v".to_string());

for (k, v) in rhs.into_iter() {
lhs.insert(k, v);
}

assert_eq!(lhs.pop_first().unwrap().0.name, "lhs_k".to_string());
}

#[test]
fn test_id_based_append() {
let mut lhs = BTreeMap::new();
let mut rhs = BTreeMap::new();

lhs.insert(IdBased { id: 0, name: "lhs_k".to_string() }, "lhs_v".to_string());
rhs.insert(IdBased { id: 0, name: "rhs_k".to_string() }, "rhs_v".to_string());

lhs.append(&mut rhs);

assert_eq!(lhs.pop_first().unwrap().0.name, "lhs_k".to_string());
}
12 changes: 11 additions & 1 deletion alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::cmp::Ordering::{self, Equal, Greater, Less};
use core::cmp::{max, min};
use core::fmt::{self, Debug};
use core::hash::{Hash, Hasher};
use core::iter::{FusedIterator, Peekable};
use core::iter::{FusedIterator, Peekable, TrustedLen};
use core::mem::ManuallyDrop;
use core::ops::{BitAnd, BitOr, BitXor, Bound, RangeBounds, Sub};

Expand Down Expand Up @@ -1753,6 +1753,7 @@ impl<T> Clone for Iter<'_, T> {
Iter { iter: self.iter.clone() }
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Iterator for Iter<'a, T> {
type Item = &'a T;
Expand Down Expand Up @@ -1783,19 +1784,24 @@ impl<'a, T> Iterator for Iter<'a, T> {
self.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
fn next_back(&mut self) -> Option<&'a T> {
self.iter.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> ExactSizeIterator for Iter<'_, T> {
fn len(&self) -> usize {
self.iter.len()
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<T> TrustedLen for Iter<'_, T> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<T> FusedIterator for Iter<'_, T> {}

Expand Down Expand Up @@ -1832,13 +1838,17 @@ impl<T, A: Allocator + Clone> DoubleEndedIterator for IntoIter<T, A> {
self.iter.next_back().map(|(k, _)| k)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T, A: Allocator + Clone> ExactSizeIterator for IntoIter<T, A> {
fn len(&self) -> usize {
self.iter.len()
}
}

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<T, A: Allocator + Clone> TrustedLen for IntoIter<T, A> {}

#[stable(feature = "fused", since = "1.26.0")]
impl<T, A: Allocator + Clone> FusedIterator for IntoIter<T, A> {}

Expand Down
1 change: 0 additions & 1 deletion alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
#![feature(layout_for_ptr)]
#![feature(legacy_receiver_trait)]
#![feature(local_waker)]
#![feature(maybe_uninit_slice)]
#![feature(maybe_uninit_uninit_array_transpose)]
#![feature(panic_internals)]
#![feature(pattern)]
Expand Down
1 change: 0 additions & 1 deletion alloctests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#![feature(inplace_iteration)]
#![feature(iter_advance_by)]
#![feature(iter_next_chunk)]
#![feature(maybe_uninit_slice)]
#![feature(maybe_uninit_uninit_array_transpose)]
#![feature(ptr_alignment_type)]
#![feature(ptr_internals)]
Expand Down
30 changes: 30 additions & 0 deletions alloctests/testing/ord_chaos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use std::cell::Cell;
use std::cmp::Ordering::{self, *};
use std::ptr;

use crate::string::String;

// Minimal type with an `Ord` implementation violating transitivity.
#[derive(Debug)]
pub(crate) enum Cyclic3 {
Expand Down Expand Up @@ -79,3 +81,31 @@ impl<T: PartialEq> PartialEq for Governed<'_, T> {
}

impl<T: Eq> Eq for Governed<'_, T> {}

// Comparison based only on the ID, the name is ignored.
#[derive(Debug)]
pub(crate) struct IdBased {
pub id: u32,
#[allow(dead_code)]
pub name: String,
}

impl PartialEq for IdBased {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}

impl Eq for IdBased {}

impl PartialOrd for IdBased {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

impl Ord for IdBased {
fn cmp(&self, other: &Self) -> Ordering {
self.id.cmp(&other.id)
}
}
Loading
Loading