Skip to content

Update subtree/library to 2025-03-18 #303

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

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
09d073a
doc all differences of ptr:copy(_nonoverlapping) with memcpy and memmove
hkBst Jan 31, 2025
39a0e63
Extract `unescape` from `rustc_lexer` into its own crate
GuillaumeGomez Jan 31, 2025
0537b1a
Add `_value` methods to proc_macro lib
GuillaumeGomez Jan 31, 2025
f69e62a
document capacity for ZST as example and prose
hkBst Jan 30, 2025
018d380
Initial STD support for Cygwin
Berrysoft Dec 26, 2024
90ee901
Fix `std::sys::unix::set_linger` for Cygwin
Mar 4, 2024
0ac7bb7
Fix building for cygwin
Berrysoft Dec 29, 2024
0604b97
Revert changes for rtstartup
Berrysoft Feb 25, 2025
ac2de6e
Fix code style
Berrysoft Feb 25, 2025
416f3ca
Remove std::os::cygwin::raw
Berrysoft Mar 7, 2025
d0083f5
Impl cygwin rand with getrandom
Berrysoft Mar 7, 2025
cc79e6d
Unify cygwin & horizon random impl
Berrysoft Mar 7, 2025
be00400
Readd os::cygwin::raw as pub(crate)
Berrysoft Mar 7, 2025
e7b4635
Use __xpg_strerror_r on cygwin
Berrysoft Mar 7, 2025
f6a7d44
Remove stack overflow handler for cygwin
Berrysoft Mar 7, 2025
a7400e8
std: Mention clone-on-write mutation in Arc<T>
xizheyin Mar 11, 2025
3a88b13
Add `From<{integer}>` for `f16`/`f128` impls
beetrees Mar 11, 2025
bd67b00
Fix panic handler for cygwin
Berrysoft Mar 12, 2025
a1da920
Stablize feature `anonymous_pipe`
NobodyXu Mar 1, 2025
7180a30
Mv os-specific trait impl of `Pipe*` into `std::os::*`
NobodyXu Mar 7, 2025
63ce115
Add test for new proc_macro literal methods
GuillaumeGomez Mar 16, 2025
2b74fa0
Make ControlFlow must_use
compiler-errors Feb 22, 2025
7edc9a4
make `_Unwind_Action` a type alias, not enum
Noratrieb Mar 16, 2025
ab08b6d
Exclude `literal-escaper` from `library` workspace
GuillaumeGomez Mar 16, 2025
e2c1110
Auto merge of #138363 - beetrees:f16-f128-integer-convert, r=Amanieu
bors Mar 17, 2025
961d0dd
Rollup merge of #136293 - hkBst:patch-32, r=Amanieu
jhpratt Mar 17, 2025
8aa941d
Rollup merge of #136359 - hkBst:ptr_copy_docs, r=Amanieu
jhpratt Mar 17, 2025
4ac135d
Rollup merge of #138573 - Noratrieb:no-unsound-bad-bonk-bonk, r=worki…
jhpratt Mar 17, 2025
35e5e82
Auto merge of #138583 - jhpratt:rollup-h699hty, r=jhpratt
bors Mar 17, 2025
c5b628f
Rollup merge of #136355 - GuillaumeGomez:proc-macro_add_value_retriev…
jhpratt Mar 17, 2025
edd0a06
Rollup merge of #137621 - Berrysoft:cygwin-std, r=joboet
jhpratt Mar 17, 2025
93124fe
Rollup merge of #137793 - NobodyXu:stablise-annoymous-pipe, r=joshtri…
jhpratt Mar 17, 2025
bc5baf1
Rollup merge of #138341 - xizheyin:issue-138322, r=joboet
jhpratt Mar 17, 2025
8902bd3
Rollup merge of #137449 - compiler-errors:control-flow, r=Amanieu,lni…
matthiaskrgr Mar 17, 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
8 changes: 8 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
]

exclude = [
"literal-escaper",
# stdarch has its own Cargo workspace
"stdarch",
"windows_targets"
Expand Down
26 changes: 23 additions & 3 deletions alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,29 @@ macro_rules! acquire {
///
/// Shared references in Rust disallow mutation by default, and `Arc` is no
/// exception: you cannot generally obtain a mutable reference to something
/// inside an `Arc`. If you need to mutate through an `Arc`, use
/// [`Mutex`][mutex], [`RwLock`][rwlock], or one of the [`Atomic`][atomic]
/// types.
/// inside an `Arc`. If you do need to mutate through an `Arc`, you have several options:
///
/// 1. Use interior mutability with synchronization primitives like [`Mutex`][mutex],
/// [`RwLock`][rwlock], or one of the [`Atomic`][atomic] types.
///
/// 2. Use clone-on-write semantics with [`Arc::make_mut`] which provides efficient mutation
/// without requiring interior mutability. This approach clones the data only when
/// needed (when there are multiple references) and can be more efficient when mutations
/// are infrequent.
///
/// 3. Use [`Arc::get_mut`] when you know your `Arc` is not shared (has a reference count of 1),
/// which provides direct mutable access to the inner value without any cloning.
///
/// ```
/// use std::sync::Arc;
///
/// let mut data = Arc::new(vec![1, 2, 3]);
///
/// // This will clone the vector only if there are other references to it
/// Arc::make_mut(&mut data).push(4);
///
/// assert_eq!(*data, vec![1, 2, 3, 4]);
/// ```
///
/// **Note**: This type is only available on platforms that support atomic
/// loads and stores of pointers, which includes all platforms that support
Expand Down
13 changes: 13 additions & 0 deletions alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,19 @@ impl<T, A: Allocator> Vec<T, A> {
/// vec.push(42);
/// assert!(vec.capacity() >= 10);
/// ```
///
/// A vector with zero-sized elements will always have a capacity of usize::MAX:
///
/// ```
/// #[derive(Clone)]
/// struct ZeroSized;
///
/// fn main() {
/// assert_eq!(std::mem::size_of::<ZeroSized>(), 0);
/// let v = vec![ZeroSized; 0];
/// assert_eq!(v.capacity(), usize::MAX);
/// }
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]
Expand Down
50 changes: 48 additions & 2 deletions core/src/convert/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,42 @@ impl_from!(i16 => isize, #[stable(feature = "lossless_iusize_conv", since = "1.2
// https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-951.pdf

// Note: integers can only be represented with full precision in a float if
// they fit in the significand, which is 24 bits in f32 and 53 bits in f64.
// they fit in the significand, which is:
// * 11 bits in f16
// * 24 bits in f32
// * 53 bits in f64
// * 113 bits in f128
// Lossy float conversions are not implemented at this time.
// FIXME(f16_f128): The `f16`/`f128` impls `#[stable]` attributes should be changed to reference
// `f16`/`f128` when they are stabilised (trait impls have to have a `#[stable]` attribute, but none
// of the `f16`/`f128` impls can be used on stable as the `f16` and `f128` types are unstable).

// signed integer -> float
impl_from!(i8 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(i8 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(i8 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(i8 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(i16 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(i16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(i16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(i32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(i32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
// FIXME(f16_f128): This impl would allow using `f128` on stable before it is stabilised.
// impl_from!(i64 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);

// unsigned integer -> float
impl_from!(u8 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u8 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u8 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u8 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u16 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u16 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
// FIXME(f16_f128): This impl would allow using `f128` on stable before it is stabilised.
// impl_from!(u64 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);

// float -> float
// FIXME(f16_f128): adding additional `From<{float}>` impls to `f32` breaks inference. See
Expand All @@ -174,20 +194,27 @@ impl_from!(f32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0
impl_from!(f64 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);

macro_rules! impl_float_from_bool {
($float:ty) => {
(
$float:ty $(;
doctest_prefix: $(#[doc = $doctest_prefix:literal])*
doctest_suffix: $(#[doc = $doctest_suffix:literal])*
)?
) => {
#[stable(feature = "float_from_bool", since = "1.68.0")]
impl From<bool> for $float {
#[doc = concat!("Converts a [`bool`] to [`", stringify!($float),"`] losslessly.")]
/// The resulting value is positive `0.0` for `false` and `1.0` for `true` values.
///
/// # Examples
/// ```
$($(#[doc = $doctest_prefix])*)?
#[doc = concat!("let x: ", stringify!($float)," = false.into();")]
/// assert_eq!(x, 0.0);
/// assert!(x.is_sign_positive());
///
#[doc = concat!("let y: ", stringify!($float)," = true.into();")]
/// assert_eq!(y, 1.0);
$($(#[doc = $doctest_suffix])*)?
/// ```
#[inline]
fn from(small: bool) -> Self {
Expand All @@ -198,8 +225,27 @@ macro_rules! impl_float_from_bool {
}

// boolean -> float
impl_float_from_bool!(
f16;
doctest_prefix:
// rustdoc doesn't remove the conventional space after the `///`
///#![feature(f16)]
///# #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
///
doctest_suffix:
///# }
);
impl_float_from_bool!(f32);
impl_float_from_bool!(f64);
impl_float_from_bool!(
f128;
doctest_prefix:
///#![feature(f128)]
///# #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
///
doctest_suffix:
///# }
);

// no possible bounds violation
macro_rules! impl_try_from_unbounded {
Expand Down
9 changes: 6 additions & 3 deletions core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3641,7 +3641,8 @@ pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(ptr: *const
/// For regions of memory which might overlap, use [`copy`] instead.
///
/// `copy_nonoverlapping` is semantically equivalent to C's [`memcpy`], but
/// with the argument order swapped.
/// with the source and destination arguments swapped,
/// and `count` counting the number of `T`s instead of bytes.
///
/// The copy is "untyped" in the sense that data may be uninitialized or otherwise violate the
/// requirements of `T`. The initialization state is preserved exactly.
Expand Down Expand Up @@ -3761,8 +3762,10 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
/// If the source and destination will *never* overlap,
/// [`copy_nonoverlapping`] can be used instead.
///
/// `copy` is semantically equivalent to C's [`memmove`], but with the argument
/// order swapped. Copying takes place as if the bytes were copied from `src`
/// `copy` is semantically equivalent to C's [`memmove`], but
/// with the source and destination arguments swapped,
/// and `count` counting the number of `T`s instead of bytes.
/// Copying takes place as if the bytes were copied from `src`
/// to a temporary array and then copied from the array to `dst`.
///
/// The copy is "untyped" in the sense that data may be uninitialized or otherwise violate the
Expand Down
1 change: 1 addition & 0 deletions core/src/ops/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ use crate::{convert, ops};
/// [`Continue`]: ControlFlow::Continue
#[stable(feature = "control_flow_enum_type", since = "1.55.0")]
#[rustc_diagnostic_item = "ControlFlow"]
#[must_use]
// ControlFlow should not implement PartialOrd or Ord, per RFC 3058:
// https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#traits-for-controlflow
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down
10 changes: 10 additions & 0 deletions literal-escaper/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "literal-escaper"
version = "0.0.0"
edition = "2021"

[dependencies]
std = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-std' }

[features]
rustc-dep-of-std = ["dep:std"]
4 changes: 4 additions & 0 deletions literal-escaper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# literal-escaper

This crate provides code to unescape string literals. It is used by `rustc_lexer`
and `proc_macro`.
Loading