Merge from rustc

This commit is contained in:
The Miri Cronjob Bot 2025-04-26 04:59:48 +00:00
commit 6c2fa0bce7
221 changed files with 3217 additions and 2142 deletions

View file

@ -1138,6 +1138,10 @@ pub(crate) mod builtin {
issue = "29599",
reason = "`concat_idents` is not stable enough for use and is subject to change"
)]
#[deprecated(
since = "1.88.0",
note = "use `${concat(...)}` with the `macro_metavar_expr_concat` feature instead"
)]
#[rustc_builtin_macro]
#[macro_export]
macro_rules! concat_idents {

View file

@ -162,8 +162,14 @@
//! The [`is_some`] and [`is_none`] methods return [`true`] if the [`Option`]
//! is [`Some`] or [`None`], respectively.
//!
//! The [`is_some_and`] and [`is_none_or`] methods apply the provided function
//! to the contents of the [`Option`] to produce a boolean value.
//! If this is [`None`] then a default result is returned instead without executing the function.
//!
//! [`is_none`]: Option::is_none
//! [`is_some`]: Option::is_some
//! [`is_some_and`]: Option::is_some_and
//! [`is_none_or`]: Option::is_none_or
//!
//! ## Adapters for working with references
//!
@ -177,6 +183,10 @@
//! <code>[Option]<[Pin]<[&]T>></code>
//! * [`as_pin_mut`] converts from <code>[Pin]<[&mut] [Option]\<T>></code> to
//! <code>[Option]<[Pin]<[&mut] T>></code>
//! * [`as_slice`] returns a one-element slice of the contained value, if any.
//! If this is [`None`], an empty slice is returned.
//! * [`as_mut_slice`] returns a mutable one-element slice of the contained value, if any.
//! If this is [`None`], an empty slice is returned.
//!
//! [&]: reference "shared reference"
//! [&mut]: reference "mutable reference"
@ -187,6 +197,8 @@
//! [`as_pin_mut`]: Option::as_pin_mut
//! [`as_pin_ref`]: Option::as_pin_ref
//! [`as_ref`]: Option::as_ref
//! [`as_slice`]: Option::as_slice
//! [`as_mut_slice`]: Option::as_mut_slice
//!
//! ## Extracting the contained value
//!
@ -200,12 +212,15 @@
//! (which must implement the [`Default`] trait)
//! * [`unwrap_or_else`] returns the result of evaluating the provided
//! function
//! * [`unwrap_unchecked`] produces *[undefined behavior]*
//!
//! [`expect`]: Option::expect
//! [`unwrap`]: Option::unwrap
//! [`unwrap_or`]: Option::unwrap_or
//! [`unwrap_or_default`]: Option::unwrap_or_default
//! [`unwrap_or_else`]: Option::unwrap_or_else
//! [`unwrap_unchecked`]: Option::unwrap_unchecked
//! [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
//!
//! ## Transforming contained values
//!
@ -230,8 +245,9 @@
//! * [`filter`] calls the provided predicate function on the contained
//! value `t` if the [`Option`] is [`Some(t)`], and returns [`Some(t)`]
//! if the function returns `true`; otherwise, returns [`None`]
//! * [`flatten`] removes one level of nesting from an
//! [`Option<Option<T>>`]
//! * [`flatten`] removes one level of nesting from an [`Option<Option<T>>`]
//! * [`inspect`] method takes ownership of the [`Option`] and applies
//! the provided function to the contained value by reference if [`Some`]
//! * [`map`] transforms [`Option<T>`] to [`Option<U>`] by applying the
//! provided function to the contained value of [`Some`] and leaving
//! [`None`] values unchanged
@ -239,6 +255,7 @@
//! [`Some(t)`]: Some
//! [`filter`]: Option::filter
//! [`flatten`]: Option::flatten
//! [`inspect`]: Option::inspect
//! [`map`]: Option::map
//!
//! These methods transform [`Option<T>`] to a value of a possibly
@ -621,6 +638,10 @@ impl<T> Option<T> {
///
/// let x: Option<u32> = None;
/// assert_eq!(x.is_some_and(|x| x > 1), false);
///
/// let x: Option<String> = Some("ownership".to_string());
/// assert_eq!(x.as_ref().is_some_and(|x| x.len() > 1), true);
/// println!("still alive {:?}", x);
/// ```
#[must_use]
#[inline]
@ -665,6 +686,10 @@ impl<T> Option<T> {
///
/// let x: Option<u32> = None;
/// assert_eq!(x.is_none_or(|x| x > 1), true);
///
/// let x: Option<String> = Some("ownership".to_string());
/// assert_eq!(x.as_ref().is_none_or(|x| x.len() > 1), true);
/// println!("still alive {:?}", x);
/// ```
#[must_use]
#[inline]

View file

@ -59,6 +59,7 @@ pub use crate::hash::macros::Hash;
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[allow(deprecated)]
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
#[doc(no_inline)]
pub use crate::{
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,

View file

@ -259,8 +259,14 @@
//! The [`is_ok`] and [`is_err`] methods return [`true`] if the [`Result`]
//! is [`Ok`] or [`Err`], respectively.
//!
//! The [`is_ok_and`] and [`is_err_and`] methods apply the provided function
//! to the contents of the [`Result`] to produce a boolean value. If the [`Result`] does not have the expected variant
//! then [`false`] is returned instead without executing the function.
//!
//! [`is_err`]: Result::is_err
//! [`is_ok`]: Result::is_ok
//! [`is_ok_and`]: Result::is_ok_and
//! [`is_err_and`]: Result::is_err_and
//!
//! ## Adapters for working with references
//!
@ -287,6 +293,7 @@
//! (which must implement the [`Default`] trait)
//! * [`unwrap_or_else`] returns the result of evaluating the provided
//! function
//! * [`unwrap_unchecked`] produces *[undefined behavior]*
//!
//! The panicking methods [`expect`] and [`unwrap`] require `E` to
//! implement the [`Debug`] trait.
@ -297,6 +304,8 @@
//! [`unwrap_or`]: Result::unwrap_or
//! [`unwrap_or_default`]: Result::unwrap_or_default
//! [`unwrap_or_else`]: Result::unwrap_or_else
//! [`unwrap_unchecked`]: Result::unwrap_unchecked
//! [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
//!
//! These methods extract the contained value in a [`Result<T, E>`] when it
//! is the [`Err`] variant. They require `T` to implement the [`Debug`]
@ -304,10 +313,13 @@
//!
//! * [`expect_err`] panics with a provided custom message
//! * [`unwrap_err`] panics with a generic message
//! * [`unwrap_err_unchecked`] produces *[undefined behavior]*
//!
//! [`Debug`]: crate::fmt::Debug
//! [`expect_err`]: Result::expect_err
//! [`unwrap_err`]: Result::unwrap_err
//! [`unwrap_err_unchecked`]: Result::unwrap_err_unchecked
//! [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
//!
//! ## Transforming contained values
//!
@ -330,21 +342,29 @@
//! [`Some(v)`]: Option::Some
//! [`transpose`]: Result::transpose
//!
//! This method transforms the contained value of the [`Ok`] variant:
//! These methods transform the contained value of the [`Ok`] variant:
//!
//! * [`map`] transforms [`Result<T, E>`] into [`Result<U, E>`] by applying
//! the provided function to the contained value of [`Ok`] and leaving
//! [`Err`] values unchanged
//! * [`inspect`] takes ownership of the [`Result`], applies the
//! provided function to the contained value by reference,
//! and then returns the [`Result`]
//!
//! [`map`]: Result::map
//! [`inspect`]: Result::inspect
//!
//! This method transforms the contained value of the [`Err`] variant:
//! These methods transform the contained value of the [`Err`] variant:
//!
//! * [`map_err`] transforms [`Result<T, E>`] into [`Result<T, F>`] by
//! applying the provided function to the contained value of [`Err`] and
//! leaving [`Ok`] values unchanged
//! * [`inspect_err`] takes ownership of the [`Result`], applies the
//! provided function to the contained value of [`Err`] by reference,
//! and then returns the [`Result`]
//!
//! [`map_err`]: Result::map_err
//! [`inspect_err`]: Result::inspect_err
//!
//! These methods transform a [`Result<T, E>`] into a value of a possibly
//! different type `U`:
@ -578,6 +598,10 @@ impl<T, E> Result<T, E> {
///
/// let x: Result<u32, &str> = Err("hey");
/// assert_eq!(x.is_ok_and(|x| x > 1), false);
///
/// let x: Result<String, &str> = Ok("ownership".to_string());
/// assert_eq!(x.as_ref().is_ok_and(|x| x.len() > 1), true);
/// println!("still alive {:?}", x);
/// ```
#[must_use]
#[inline]
@ -623,6 +647,10 @@ impl<T, E> Result<T, E> {
///
/// let x: Result<u32, Error> = Ok(123);
/// assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false);
///
/// let x: Result<u32, String> = Err("ownership".to_string());
/// assert_eq!(x.as_ref().is_err_and(|x| x.len() > 1), true);
/// println!("still alive {:?}", x);
/// ```
#[must_use]
#[inline]