Skip to content

Commit 0d860d0

Browse files
github-actions[bot]RalfJungmatthiaskrgrBerrysoftm-ou-se
authored
Merge subtree update for toolchain nightly-2025-04-06 (#320)
This is an automated PR to merge library subtree updates from 2025-04-04 (rust-lang/rust@00095b3) to 2025-04-06 (rust-lang/rust@5e17a2a) (inclusive) into main. `git merge` resulted in conflicts, which require manual resolution. Files were commited with merge conflict markers. **Do not remove or edit the following annotations:** git-subtree-dir: library git-subtree-split: a5c6692 --------- Signed-off-by: Jiahao XU <[email protected]> Signed-off-by: Ayush Singh <[email protected]> Signed-off-by: xizheyin <[email protected]> Co-authored-by: Ralf Jung <[email protected]> Co-authored-by: Matthias Krüger <[email protected]> Co-authored-by: Berrysoft <[email protected]> Co-authored-by: Mara Bos <[email protected]> Co-authored-by: Manish Goregaokar <[email protected]> Co-authored-by: Josh Stone <[email protected]> Co-authored-by: bors <[email protected]> Co-authored-by: ClearLove <[email protected]> Co-authored-by: Thom Chiovoloni <[email protected]> Co-authored-by: Scott McMurray <[email protected]> Co-authored-by: Jiahao XU <[email protected]> Co-authored-by: bjorn3 <[email protected]> Co-authored-by: Michael Goulet <[email protected]> Co-authored-by: The Miri Cronjob Bot <[email protected]> Co-authored-by: Jacob Pratt <[email protected]> Co-authored-by: Tobias Bucher <[email protected]> Co-authored-by: León Orell Valerian Liehr <[email protected]> Co-authored-by: Yotam Ofek <[email protected]> Co-authored-by: okaneco <[email protected]> Co-authored-by: 许杰友 Jieyou Xu (Joe) <[email protected]> Co-authored-by: Guillaume Gomez <[email protected]> Co-authored-by: Ayush Singh <[email protected]> Co-authored-by: Noratrieb <[email protected]> Co-authored-by: Thalia Archibald <[email protected]> Co-authored-by: Marijn Schouten <[email protected]> Co-authored-by: Ibraheem Ahmed <[email protected]> Co-authored-by: Chris Denton <[email protected]> Co-authored-by: Taiki Endo <[email protected]> Co-authored-by: Andrei Damian <[email protected]> Co-authored-by: bendn <[email protected]> Co-authored-by: Caleb Zulawski <[email protected]> Co-authored-by: Jana Dönszelmann <[email protected]> Co-authored-by: syvb <[email protected]> Co-authored-by: Sebastian Urban <[email protected]> Co-authored-by: Bardi Harborow <[email protected]> Co-authored-by: lcnr <[email protected]> Co-authored-by: Trevor Gross <[email protected]> Co-authored-by: moxian <[email protected]> Co-authored-by: Frank King <[email protected]> Co-authored-by: joboet <[email protected]> Co-authored-by: Takayuki Maeda <[email protected]> Co-authored-by: DaniPopes <[email protected]> Co-authored-by: Mads Marquart <[email protected]> Co-authored-by: Christopher Durham <[email protected]> Co-authored-by: Rafael Bachmann <[email protected]> Co-authored-by: xizheyin <[email protected]> Co-authored-by: Benoît du Garreau <[email protected]> Co-authored-by: Daniel Henry-Mantilla <[email protected]> Co-authored-by: mejrs <[email protected]> Co-authored-by: clubby789 <[email protected]> Co-authored-by: Daniel Bloom <[email protected]> Co-authored-by: Jake Wharton <[email protected]> Co-authored-by: Calder Coalson <[email protected]> Co-authored-by: Stuart Cook <[email protected]> Co-authored-by: gitbot <git@bot> Co-authored-by: Michael Tautschnig <[email protected]>
1 parent 659982c commit 0d860d0

File tree

48 files changed

+1020
-407
lines changed

Some content is hidden

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

48 files changed

+1020
-407
lines changed

library/alloc/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,4 @@ check-cfg = [
3737
'cfg(no_global_oom_handling)',
3838
'cfg(no_rc)',
3939
'cfg(no_sync)',
40-
'cfg(randomized_layouts)',
4140
]

library/alloctests/tests/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ mod fmt;
6363
mod heap;
6464
mod linked_list;
6565
mod misc_tests;
66+
mod num;
6667
mod rc;
6768
mod slice;
6869
mod sort;

library/alloctests/tests/num.rs

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
use std::fmt::{Debug, Display};
2+
use std::str::FromStr;
3+
4+
fn assert_nb<Int: ToString + FromStr + Debug + Display + Eq>(value: Int) {
5+
let s = value.to_string();
6+
let s2 = format!("s: {}.", value);
7+
8+
assert_eq!(format!("s: {s}."), s2);
9+
let Ok(ret) = Int::from_str(&s) else {
10+
panic!("failed to convert into to string");
11+
};
12+
assert_eq!(ret, value);
13+
}
14+
15+
macro_rules! uint_to_s {
16+
($($fn_name:ident, $int:ident,)+) => {
17+
$(
18+
#[test]
19+
fn $fn_name() {
20+
assert_nb::<$int>($int::MIN);
21+
assert_nb::<$int>($int::MAX);
22+
assert_nb::<$int>(1);
23+
assert_nb::<$int>($int::MIN / 2);
24+
assert_nb::<$int>($int::MAX / 2);
25+
}
26+
)+
27+
}
28+
}
29+
macro_rules! int_to_s {
30+
($($fn_name:ident, $int:ident,)+) => {
31+
$(
32+
#[test]
33+
fn $fn_name() {
34+
assert_nb::<$int>($int::MIN);
35+
assert_nb::<$int>($int::MAX);
36+
assert_nb::<$int>(1);
37+
assert_nb::<$int>(0);
38+
assert_nb::<$int>(-1);
39+
assert_nb::<$int>($int::MIN / 2);
40+
assert_nb::<$int>($int::MAX / 2);
41+
}
42+
)+
43+
}
44+
}
45+
46+
int_to_s!(
47+
test_i8_to_string,
48+
i8,
49+
test_i16_to_string,
50+
i16,
51+
test_i32_to_string,
52+
i32,
53+
test_i64_to_string,
54+
i64,
55+
test_i128_to_string,
56+
i128,
57+
);
58+
uint_to_s!(
59+
test_u8_to_string,
60+
u8,
61+
test_u16_to_string,
62+
u16,
63+
test_u32_to_string,
64+
u32,
65+
test_u64_to_string,
66+
u64,
67+
test_u128_to_string,
68+
u128,
69+
);

library/core/src/bstr.rs renamed to library/core/src/bstr/mod.rs

+14-273
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
//! The `ByteStr` type and trait implementations.
22
3+
mod traits;
4+
5+
#[unstable(feature = "bstr_internals", issue = "none")]
6+
pub use traits::{impl_partial_eq, impl_partial_eq_n, impl_partial_eq_ord};
7+
38
use crate::borrow::{Borrow, BorrowMut};
4-
use crate::cmp::Ordering;
5-
use crate::ops::{
6-
Deref, DerefMut, DerefPure, Index, IndexMut, Range, RangeFrom, RangeFull, RangeInclusive,
7-
RangeTo, RangeToInclusive,
8-
};
9-
use crate::{fmt, hash};
9+
use crate::fmt;
10+
use crate::ops::{Deref, DerefMut, DerefPure};
1011

1112
/// A wrapper for `&[u8]` representing a human-readable string that's conventionally, but not
1213
/// always, UTF-8.
@@ -91,6 +92,13 @@ impl ByteStr {
9192
pub fn as_bytes(&self) -> &[u8] {
9293
&self.0
9394
}
95+
96+
#[doc(hidden)]
97+
#[unstable(feature = "bstr_internals", issue = "none")]
98+
#[inline]
99+
pub fn as_bytes_mut(&mut self) -> &mut [u8] {
100+
&mut self.0
101+
}
94102
}
95103

96104
#[unstable(feature = "bstr", issue = "134915")]
@@ -295,273 +303,6 @@ impl<'a> Default for &'a mut ByteStr {
295303
// }
296304
// }
297305

298-
#[unstable(feature = "bstr", issue = "134915")]
299-
impl hash::Hash for ByteStr {
300-
#[inline]
301-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
302-
self.0.hash(state);
303-
}
304-
}
305-
306-
#[unstable(feature = "bstr", issue = "134915")]
307-
impl Index<usize> for ByteStr {
308-
type Output = u8;
309-
310-
#[inline]
311-
fn index(&self, idx: usize) -> &u8 {
312-
&self.0[idx]
313-
}
314-
}
315-
316-
#[unstable(feature = "bstr", issue = "134915")]
317-
impl Index<RangeFull> for ByteStr {
318-
type Output = ByteStr;
319-
320-
#[inline]
321-
fn index(&self, _: RangeFull) -> &ByteStr {
322-
self
323-
}
324-
}
325-
326-
#[unstable(feature = "bstr", issue = "134915")]
327-
impl Index<Range<usize>> for ByteStr {
328-
type Output = ByteStr;
329-
330-
#[inline]
331-
fn index(&self, r: Range<usize>) -> &ByteStr {
332-
ByteStr::from_bytes(&self.0[r])
333-
}
334-
}
335-
336-
#[unstable(feature = "bstr", issue = "134915")]
337-
impl Index<RangeInclusive<usize>> for ByteStr {
338-
type Output = ByteStr;
339-
340-
#[inline]
341-
fn index(&self, r: RangeInclusive<usize>) -> &ByteStr {
342-
ByteStr::from_bytes(&self.0[r])
343-
}
344-
}
345-
346-
#[unstable(feature = "bstr", issue = "134915")]
347-
impl Index<RangeFrom<usize>> for ByteStr {
348-
type Output = ByteStr;
349-
350-
#[inline]
351-
fn index(&self, r: RangeFrom<usize>) -> &ByteStr {
352-
ByteStr::from_bytes(&self.0[r])
353-
}
354-
}
355-
356-
#[unstable(feature = "bstr", issue = "134915")]
357-
impl Index<RangeTo<usize>> for ByteStr {
358-
type Output = ByteStr;
359-
360-
#[inline]
361-
fn index(&self, r: RangeTo<usize>) -> &ByteStr {
362-
ByteStr::from_bytes(&self.0[r])
363-
}
364-
}
365-
366-
#[unstable(feature = "bstr", issue = "134915")]
367-
impl Index<RangeToInclusive<usize>> for ByteStr {
368-
type Output = ByteStr;
369-
370-
#[inline]
371-
fn index(&self, r: RangeToInclusive<usize>) -> &ByteStr {
372-
ByteStr::from_bytes(&self.0[r])
373-
}
374-
}
375-
376-
#[unstable(feature = "bstr", issue = "134915")]
377-
impl IndexMut<usize> for ByteStr {
378-
#[inline]
379-
fn index_mut(&mut self, idx: usize) -> &mut u8 {
380-
&mut self.0[idx]
381-
}
382-
}
383-
384-
#[unstable(feature = "bstr", issue = "134915")]
385-
impl IndexMut<RangeFull> for ByteStr {
386-
#[inline]
387-
fn index_mut(&mut self, _: RangeFull) -> &mut ByteStr {
388-
self
389-
}
390-
}
391-
392-
#[unstable(feature = "bstr", issue = "134915")]
393-
impl IndexMut<Range<usize>> for ByteStr {
394-
#[inline]
395-
fn index_mut(&mut self, r: Range<usize>) -> &mut ByteStr {
396-
ByteStr::from_bytes_mut(&mut self.0[r])
397-
}
398-
}
399-
400-
#[unstable(feature = "bstr", issue = "134915")]
401-
impl IndexMut<RangeInclusive<usize>> for ByteStr {
402-
#[inline]
403-
fn index_mut(&mut self, r: RangeInclusive<usize>) -> &mut ByteStr {
404-
ByteStr::from_bytes_mut(&mut self.0[r])
405-
}
406-
}
407-
408-
#[unstable(feature = "bstr", issue = "134915")]
409-
impl IndexMut<RangeFrom<usize>> for ByteStr {
410-
#[inline]
411-
fn index_mut(&mut self, r: RangeFrom<usize>) -> &mut ByteStr {
412-
ByteStr::from_bytes_mut(&mut self.0[r])
413-
}
414-
}
415-
416-
#[unstable(feature = "bstr", issue = "134915")]
417-
impl IndexMut<RangeTo<usize>> for ByteStr {
418-
#[inline]
419-
fn index_mut(&mut self, r: RangeTo<usize>) -> &mut ByteStr {
420-
ByteStr::from_bytes_mut(&mut self.0[r])
421-
}
422-
}
423-
424-
#[unstable(feature = "bstr", issue = "134915")]
425-
impl IndexMut<RangeToInclusive<usize>> for ByteStr {
426-
#[inline]
427-
fn index_mut(&mut self, r: RangeToInclusive<usize>) -> &mut ByteStr {
428-
ByteStr::from_bytes_mut(&mut self.0[r])
429-
}
430-
}
431-
432-
#[unstable(feature = "bstr", issue = "134915")]
433-
impl Eq for ByteStr {}
434-
435-
#[unstable(feature = "bstr", issue = "134915")]
436-
impl PartialEq<ByteStr> for ByteStr {
437-
#[inline]
438-
fn eq(&self, other: &ByteStr) -> bool {
439-
&self.0 == &other.0
440-
}
441-
}
442-
443-
#[doc(hidden)]
444-
#[macro_export]
445-
#[unstable(feature = "bstr_internals", issue = "none")]
446-
macro_rules! impl_partial_eq {
447-
($lhs:ty, $rhs:ty) => {
448-
#[allow(unused_lifetimes)]
449-
impl<'a> PartialEq<$rhs> for $lhs {
450-
#[inline]
451-
fn eq(&self, other: &$rhs) -> bool {
452-
let other: &[u8] = other.as_ref();
453-
PartialEq::eq(self.as_bytes(), other)
454-
}
455-
}
456-
457-
#[allow(unused_lifetimes)]
458-
impl<'a> PartialEq<$lhs> for $rhs {
459-
#[inline]
460-
fn eq(&self, other: &$lhs) -> bool {
461-
let this: &[u8] = self.as_ref();
462-
PartialEq::eq(this, other.as_bytes())
463-
}
464-
}
465-
};
466-
}
467-
468-
#[doc(hidden)]
469-
#[unstable(feature = "bstr_internals", issue = "none")]
470-
pub use impl_partial_eq;
471-
472-
#[doc(hidden)]
473-
#[macro_export]
474-
#[unstable(feature = "bstr_internals", issue = "none")]
475-
macro_rules! impl_partial_eq_ord {
476-
($lhs:ty, $rhs:ty) => {
477-
$crate::bstr::impl_partial_eq!($lhs, $rhs);
478-
479-
#[allow(unused_lifetimes)]
480-
#[unstable(feature = "bstr", issue = "134915")]
481-
impl<'a> PartialOrd<$rhs> for $lhs {
482-
#[inline]
483-
fn partial_cmp(&self, other: &$rhs) -> Option<Ordering> {
484-
let other: &[u8] = other.as_ref();
485-
PartialOrd::partial_cmp(self.as_bytes(), other)
486-
}
487-
}
488-
489-
#[allow(unused_lifetimes)]
490-
#[unstable(feature = "bstr", issue = "134915")]
491-
impl<'a> PartialOrd<$lhs> for $rhs {
492-
#[inline]
493-
fn partial_cmp(&self, other: &$lhs) -> Option<Ordering> {
494-
let this: &[u8] = self.as_ref();
495-
PartialOrd::partial_cmp(this, other.as_bytes())
496-
}
497-
}
498-
};
499-
}
500-
501-
#[doc(hidden)]
502-
#[unstable(feature = "bstr_internals", issue = "none")]
503-
pub use impl_partial_eq_ord;
504-
505-
#[doc(hidden)]
506-
#[macro_export]
507-
#[unstable(feature = "bstr_internals", issue = "none")]
508-
macro_rules! impl_partial_eq_n {
509-
($lhs:ty, $rhs:ty) => {
510-
#[allow(unused_lifetimes)]
511-
#[unstable(feature = "bstr", issue = "134915")]
512-
impl<const N: usize> PartialEq<$rhs> for $lhs {
513-
#[inline]
514-
fn eq(&self, other: &$rhs) -> bool {
515-
let other: &[u8] = other.as_ref();
516-
PartialEq::eq(self.as_bytes(), other)
517-
}
518-
}
519-
520-
#[allow(unused_lifetimes)]
521-
#[unstable(feature = "bstr", issue = "134915")]
522-
impl<const N: usize> PartialEq<$lhs> for $rhs {
523-
#[inline]
524-
fn eq(&self, other: &$lhs) -> bool {
525-
let this: &[u8] = self.as_ref();
526-
PartialEq::eq(this, other.as_bytes())
527-
}
528-
}
529-
};
530-
}
531-
532-
#[doc(hidden)]
533-
#[unstable(feature = "bstr_internals", issue = "none")]
534-
pub use impl_partial_eq_n;
535-
536-
// PartialOrd with `[u8]` omitted to avoid inference failures
537-
impl_partial_eq!(ByteStr, [u8]);
538-
// PartialOrd with `&[u8]` omitted to avoid inference failures
539-
impl_partial_eq!(ByteStr, &[u8]);
540-
// PartialOrd with `str` omitted to avoid inference failures
541-
impl_partial_eq!(ByteStr, str);
542-
// PartialOrd with `&str` omitted to avoid inference failures
543-
impl_partial_eq!(ByteStr, &str);
544-
// PartialOrd with `[u8; N]` omitted to avoid inference failures
545-
impl_partial_eq_n!(ByteStr, [u8; N]);
546-
// PartialOrd with `[u8; N]` omitted to avoid inference failures
547-
impl_partial_eq_n!(ByteStr, &[u8; N]);
548-
549-
#[unstable(feature = "bstr", issue = "134915")]
550-
impl Ord for ByteStr {
551-
#[inline]
552-
fn cmp(&self, other: &ByteStr) -> Ordering {
553-
Ord::cmp(&self.0, &other.0)
554-
}
555-
}
556-
557-
#[unstable(feature = "bstr", issue = "134915")]
558-
impl PartialOrd for ByteStr {
559-
#[inline]
560-
fn partial_cmp(&self, other: &ByteStr) -> Option<Ordering> {
561-
PartialOrd::partial_cmp(&self.0, &other.0)
562-
}
563-
}
564-
565306
#[unstable(feature = "bstr", issue = "134915")]
566307
impl<'a> TryFrom<&'a ByteStr> for &'a str {
567308
type Error = crate::str::Utf8Error;

0 commit comments

Comments
 (0)