Skip to content

Commit 7aaa844

Browse files
github-actions[bot]folkertdevwgwoodsmatthiaskrgrslanterns
authored
Merge subtree update for toolchain nightly-2025-03-18 (model-checking#309)
This is an automated PR to merge library subtree updates from 2025-03-17 (rust-lang/rust@227690a) to 2025-03-18 (rust-lang/rust@43a2e9d), inclusive. This is a clean merge, no conflicts were detected. **Do not remove or edit the following annotations:** git-subtree-dir: library git-subtree-split: 8902bd3 --------- Signed-off-by: Ayush Singh <[email protected]> Signed-off-by: fuyangpengqi <[email protected]> Signed-off-by: Ookiineko <[email protected]> Signed-off-by: xizheyin <[email protected]> Signed-off-by: Sean Cross <[email protected]> Signed-off-by: Jiahao XU <[email protected]> Co-authored-by: Folkert de Vries <[email protected]> Co-authored-by: Will Woods <[email protected]> Co-authored-by: Matthias Krüger <[email protected]> Co-authored-by: Slanterns <[email protected]> Co-authored-by: Ayush Singh <[email protected]> Co-authored-by: Trevor Gross <[email protected]> Co-authored-by: Peter Jaszkowiak <[email protected]> Co-authored-by: Karol Zwolak <[email protected]> Co-authored-by: binarycat <[email protected]> Co-authored-by: Marijn Schouten <[email protected]> Co-authored-by: Matthias Krüger <[email protected]> Co-authored-by: Speedy_Lex <[email protected]> Co-authored-by: bors <[email protected]> Co-authored-by: fuyangpengqi <[email protected]> Co-authored-by: Ralf Jung <[email protected]> Co-authored-by: Henry Jiang <[email protected]> Co-authored-by: pcorwin <[email protected]> Co-authored-by: Michael Goulet <[email protected]> Co-authored-by: Jubilee <[email protected]> Co-authored-by: 许杰友 Jieyou Xu (Joe) <[email protected]> Co-authored-by: Scott McMurray <[email protected]> Co-authored-by: Oli Scherer <[email protected]> Co-authored-by: okaneco <[email protected]> Co-authored-by: Redddy <[email protected]> Co-authored-by: Eric Huss <[email protected]> Co-authored-by: Santiago Pastorino <[email protected]> Co-authored-by: Thalia Archibald <[email protected]> Co-authored-by: Chris Denton <[email protected]> Co-authored-by: bjorn3 <[email protected]> Co-authored-by: Guillaume Gomez <[email protected]> Co-authored-by: Jacob Pratt <[email protected]> Co-authored-by: Kevin Reid <[email protected]> Co-authored-by: ltdk <[email protected]> Co-authored-by: Tobias Decking <[email protected]> Co-authored-by: Steven Malis <[email protected]> Co-authored-by: Martin Habovstiak <[email protected]> Co-authored-by: bdbai <[email protected]> Co-authored-by: joboet <[email protected]> Co-authored-by: Jethro Beekman <[email protected]> Co-authored-by: LemonJ <[email protected]> Co-authored-by: Bastian Kersting <[email protected]> Co-authored-by: Mara Bos <[email protected]> Co-authored-by: 王宇逸 <[email protected]> Co-authored-by: Ookiineko <[email protected]> Co-authored-by: Nicole LeGare <[email protected]> Co-authored-by: Nicole LeGare <[email protected]> Co-authored-by: Nicole L <[email protected]> Co-authored-by: Arjun Ramesh <[email protected]> Co-authored-by: xizheyin <[email protected]> Co-authored-by: Pavel Grigorenko <[email protected]> Co-authored-by: Oli Scherer <[email protected]> Co-authored-by: Jakub Beránek <[email protected]> Co-authored-by: Sean Cross <[email protected]> Co-authored-by: Aurelia Molzer <[email protected]> Co-authored-by: beetrees <[email protected]> Co-authored-by: Josh Stone <[email protected]> Co-authored-by: Manish Goregaokar <[email protected]> Co-authored-by: ClearLove <[email protected]> Co-authored-by: Thom Chiovoloni <[email protected]> Co-authored-by: Jiahao XU <[email protected]> Co-authored-by: León Orell Valerian Liehr <[email protected]> Co-authored-by: Yotam Ofek <[email protected]> Co-authored-by: Noratrieb <[email protected]> Co-authored-by: gitbot <git@bot>
1 parent 2d9d9fc commit 7aaa844

Some content is hidden

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

58 files changed

+1498
-272
lines changed

library/Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

library/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
]
99

1010
exclude = [
11+
"literal-escaper",
1112
# stdarch has its own Cargo workspace
1213
"stdarch",
1314
"windows_targets"

library/alloc/src/sync.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,29 @@ macro_rules! acquire {
8484
///
8585
/// Shared references in Rust disallow mutation by default, and `Arc` is no
8686
/// exception: you cannot generally obtain a mutable reference to something
87-
/// inside an `Arc`. If you need to mutate through an `Arc`, use
88-
/// [`Mutex`][mutex], [`RwLock`][rwlock], or one of the [`Atomic`][atomic]
89-
/// types.
87+
/// inside an `Arc`. If you do need to mutate through an `Arc`, you have several options:
88+
///
89+
/// 1. Use interior mutability with synchronization primitives like [`Mutex`][mutex],
90+
/// [`RwLock`][rwlock], or one of the [`Atomic`][atomic] types.
91+
///
92+
/// 2. Use clone-on-write semantics with [`Arc::make_mut`] which provides efficient mutation
93+
/// without requiring interior mutability. This approach clones the data only when
94+
/// needed (when there are multiple references) and can be more efficient when mutations
95+
/// are infrequent.
96+
///
97+
/// 3. Use [`Arc::get_mut`] when you know your `Arc` is not shared (has a reference count of 1),
98+
/// which provides direct mutable access to the inner value without any cloning.
99+
///
100+
/// ```
101+
/// use std::sync::Arc;
102+
///
103+
/// let mut data = Arc::new(vec![1, 2, 3]);
104+
///
105+
/// // This will clone the vector only if there are other references to it
106+
/// Arc::make_mut(&mut data).push(4);
107+
///
108+
/// assert_eq!(*data, vec![1, 2, 3, 4]);
109+
/// ```
90110
///
91111
/// **Note**: This type is only available on platforms that support atomic
92112
/// loads and stores of pointers, which includes all platforms that support

library/alloc/src/vec/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,19 @@ impl<T, A: Allocator> Vec<T, A> {
12521252
/// vec.push(42);
12531253
/// assert!(vec.capacity() >= 10);
12541254
/// ```
1255+
///
1256+
/// A vector with zero-sized elements will always have a capacity of usize::MAX:
1257+
///
1258+
/// ```
1259+
/// #[derive(Clone)]
1260+
/// struct ZeroSized;
1261+
///
1262+
/// fn main() {
1263+
/// assert_eq!(std::mem::size_of::<ZeroSized>(), 0);
1264+
/// let v = vec![ZeroSized; 0];
1265+
/// assert_eq!(v.capacity(), usize::MAX);
1266+
/// }
1267+
/// ```
12551268
#[inline]
12561269
#[stable(feature = "rust1", since = "1.0.0")]
12571270
#[rustc_const_stable(feature = "const_vec_string_slice", since = "CURRENT_RUSTC_VERSION")]

library/core/src/convert/num.rs

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,22 +156,42 @@ impl_from!(i16 => isize, #[stable(feature = "lossless_iusize_conv", since = "1.2
156156
// https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-951.pdf
157157

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

162169
// signed integer -> float
170+
impl_from!(i8 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
163171
impl_from!(i8 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
164172
impl_from!(i8 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
173+
impl_from!(i8 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
165174
impl_from!(i16 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
166175
impl_from!(i16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
176+
impl_from!(i16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
167177
impl_from!(i32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
178+
impl_from!(i32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
179+
// FIXME(f16_f128): This impl would allow using `f128` on stable before it is stabilised.
180+
// impl_from!(i64 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
168181

169182
// unsigned integer -> float
183+
impl_from!(u8 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
170184
impl_from!(u8 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
171185
impl_from!(u8 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
186+
impl_from!(u8 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
187+
impl_from!(u16 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
172188
impl_from!(u16 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
173189
impl_from!(u16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
190+
impl_from!(u16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
174191
impl_from!(u32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
192+
impl_from!(u32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
193+
// FIXME(f16_f128): This impl would allow using `f128` on stable before it is stabilised.
194+
// impl_from!(u64 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
175195

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

185205
macro_rules! impl_float_from_bool {
186-
($float:ty) => {
206+
(
207+
$float:ty $(;
208+
doctest_prefix: $(#[doc = $doctest_prefix:literal])*
209+
doctest_suffix: $(#[doc = $doctest_suffix:literal])*
210+
)?
211+
) => {
187212
#[stable(feature = "float_from_bool", since = "1.68.0")]
188213
impl From<bool> for $float {
189214
#[doc = concat!("Converts a [`bool`] to [`", stringify!($float),"`] losslessly.")]
190215
/// The resulting value is positive `0.0` for `false` and `1.0` for `true` values.
191216
///
192217
/// # Examples
193218
/// ```
219+
$($(#[doc = $doctest_prefix])*)?
194220
#[doc = concat!("let x: ", stringify!($float)," = false.into();")]
195221
/// assert_eq!(x, 0.0);
196222
/// assert!(x.is_sign_positive());
197223
///
198224
#[doc = concat!("let y: ", stringify!($float)," = true.into();")]
199225
/// assert_eq!(y, 1.0);
226+
$($(#[doc = $doctest_suffix])*)?
200227
/// ```
201228
#[inline]
202229
fn from(small: bool) -> Self {
@@ -207,8 +234,27 @@ macro_rules! impl_float_from_bool {
207234
}
208235

209236
// boolean -> float
237+
impl_float_from_bool!(
238+
f16;
239+
doctest_prefix:
240+
// rustdoc doesn't remove the conventional space after the `///`
241+
///#![feature(f16)]
242+
///# #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
243+
///
244+
doctest_suffix:
245+
///# }
246+
);
210247
impl_float_from_bool!(f32);
211248
impl_float_from_bool!(f64);
249+
impl_float_from_bool!(
250+
f128;
251+
doctest_prefix:
252+
///#![feature(f128)]
253+
///# #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
254+
///
255+
doctest_suffix:
256+
///# }
257+
);
212258

213259
// no possible bounds violation
214260
macro_rules! impl_try_from_unbounded {

library/core/src/intrinsics/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3664,7 +3664,8 @@ pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(ptr: *const
36643664
/// For regions of memory which might overlap, use [`copy`] instead.
36653665
///
36663666
/// `copy_nonoverlapping` is semantically equivalent to C's [`memcpy`], but
3667-
/// with the argument order swapped.
3667+
/// with the source and destination arguments swapped,
3668+
/// and `count` counting the number of `T`s instead of bytes.
36683669
///
36693670
/// The copy is "untyped" in the sense that data may be uninitialized or otherwise violate the
36703671
/// requirements of `T`. The initialization state is preserved exactly.
@@ -3791,8 +3792,10 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
37913792
/// If the source and destination will *never* overlap,
37923793
/// [`copy_nonoverlapping`] can be used instead.
37933794
///
3794-
/// `copy` is semantically equivalent to C's [`memmove`], but with the argument
3795-
/// order swapped. Copying takes place as if the bytes were copied from `src`
3795+
/// `copy` is semantically equivalent to C's [`memmove`], but
3796+
/// with the source and destination arguments swapped,
3797+
/// and `count` counting the number of `T`s instead of bytes.
3798+
/// Copying takes place as if the bytes were copied from `src`
37963799
/// to a temporary array and then copied from the array to `dst`.
37973800
///
37983801
/// The copy is "untyped" in the sense that data may be uninitialized or otherwise violate the

library/core/src/ops/control_flow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ use crate::{convert, ops};
8080
/// [`Continue`]: ControlFlow::Continue
8181
#[stable(feature = "control_flow_enum_type", since = "1.55.0")]
8282
#[rustc_diagnostic_item = "ControlFlow"]
83+
#[must_use]
8384
// ControlFlow should not implement PartialOrd or Ord, per RFC 3058:
8485
// https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#traits-for-controlflow
8586
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

library/literal-escaper/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "literal-escaper"
3+
version = "0.0.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
std = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-std' }
8+
9+
[features]
10+
rustc-dep-of-std = ["dep:std"]

library/literal-escaper/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# literal-escaper
2+
3+
This crate provides code to unescape string literals. It is used by `rustc_lexer`
4+
and `proc_macro`.

0 commit comments

Comments
 (0)