summaryrefslogtreecommitdiffstats
path: root/library/core/src/convert
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /library/core/src/convert
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/core/src/convert')
-rw-r--r--library/core/src/convert/mod.rs49
-rw-r--r--library/core/src/convert/num.rs24
2 files changed, 25 insertions, 48 deletions
diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs
index 5888e2960..38a6d1ccd 100644
--- a/library/core/src/convert/mod.rs
+++ b/library/core/src/convert/mod.rs
@@ -214,7 +214,6 @@ pub const fn identity<T>(x: T) -> T {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "AsRef")]
-#[const_trait]
pub trait AsRef<T: ?Sized> {
/// Converts this type into a shared reference of the (usually inferred) input type.
#[stable(feature = "rust1", since = "1.0.0")]
@@ -366,7 +365,6 @@ pub trait AsRef<T: ?Sized> {
/// `&mut Vec<u8>`, for example, is the better choice (callers need to pass the correct type then).
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "AsMut")]
-#[const_trait]
pub trait AsMut<T: ?Sized> {
/// Converts this type into a mutable reference of the (usually inferred) input type.
#[stable(feature = "rust1", since = "1.0.0")]
@@ -443,7 +441,6 @@ pub trait AsMut<T: ?Sized> {
/// [`Vec`]: ../../std/vec/struct.Vec.html
#[rustc_diagnostic_item = "Into"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[const_trait]
pub trait Into<T>: Sized {
/// Converts this type into the (usually inferred) input type.
#[must_use]
@@ -539,7 +536,6 @@ pub trait Into<T>: Sized {
all(_Self = "&str", T = "std::string::String"),
note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix",
))]
-#[const_trait]
pub trait From<T>: Sized {
/// Converts to this type from the input type.
#[rustc_diagnostic_item = "from_fn"]
@@ -564,7 +560,6 @@ pub trait From<T>: Sized {
/// [`Into`], see there for details.
#[rustc_diagnostic_item = "TryInto"]
#[stable(feature = "try_from", since = "1.34.0")]
-#[const_trait]
pub trait TryInto<T>: Sized {
/// The type returned in the event of a conversion error.
#[stable(feature = "try_from", since = "1.34.0")]
@@ -641,7 +636,6 @@ pub trait TryInto<T>: Sized {
/// [`try_from`]: TryFrom::try_from
#[rustc_diagnostic_item = "TryFrom"]
#[stable(feature = "try_from", since = "1.34.0")]
-#[const_trait]
pub trait TryFrom<T>: Sized {
/// The type returned in the event of a conversion error.
#[stable(feature = "try_from", since = "1.34.0")]
@@ -658,10 +652,9 @@ pub trait TryFrom<T>: Sized {
// As lifts over &
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
-impl<T: ?Sized, U: ?Sized> const AsRef<U> for &T
+impl<T: ?Sized, U: ?Sized> AsRef<U> for &T
where
- T: ~const AsRef<U>,
+ T: AsRef<U>,
{
#[inline]
fn as_ref(&self) -> &U {
@@ -671,10 +664,9 @@ where
// As lifts over &mut
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
-impl<T: ?Sized, U: ?Sized> const AsRef<U> for &mut T
+impl<T: ?Sized, U: ?Sized> AsRef<U> for &mut T
where
- T: ~const AsRef<U>,
+ T: AsRef<U>,
{
#[inline]
fn as_ref(&self) -> &U {
@@ -692,10 +684,9 @@ where
// AsMut lifts over &mut
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
-impl<T: ?Sized, U: ?Sized> const AsMut<U> for &mut T
+impl<T: ?Sized, U: ?Sized> AsMut<U> for &mut T
where
- T: ~const AsMut<U>,
+ T: AsMut<U>,
{
#[inline]
fn as_mut(&mut self) -> &mut U {
@@ -713,10 +704,9 @@ where
// From implies Into
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
-impl<T, U> const Into<U> for T
+impl<T, U> Into<U> for T
where
- U: ~const From<T>,
+ U: From<T>,
{
/// Calls `U::from(self)`.
///
@@ -730,8 +720,7 @@ where
// From (and thus Into) is reflexive
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
-impl<T> const From<T> for T {
+impl<T> From<T> for T {
/// Returns the argument unchanged.
#[inline(always)]
fn from(t: T) -> T {
@@ -748,8 +737,7 @@ impl<T> const From<T> for T {
#[allow(unused_attributes)] // FIXME(#58633): do a principled fix instead.
#[rustc_reservation_impl = "permitting this impl would forbid us from adding \
`impl<T> From<!> for T` later; see rust-lang/rust#64715 for details"]
-#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
-impl<T> const From<!> for T {
+impl<T> From<!> for T {
fn from(t: !) -> T {
t
}
@@ -757,10 +745,9 @@ impl<T> const From<!> for T {
// TryFrom implies TryInto
#[stable(feature = "try_from", since = "1.34.0")]
-#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
-impl<T, U> const TryInto<U> for T
+impl<T, U> TryInto<U> for T
where
- U: ~const TryFrom<T>,
+ U: TryFrom<T>,
{
type Error = U::Error;
@@ -773,10 +760,9 @@ where
// Infallible conversions are semantically equivalent to fallible conversions
// with an uninhabited error type.
#[stable(feature = "try_from", since = "1.34.0")]
-#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
-impl<T, U> const TryFrom<U> for T
+impl<T, U> TryFrom<U> for T
where
- U: ~const Into<T>,
+ U: Into<T>,
{
type Error = Infallible;
@@ -876,8 +862,7 @@ impl AsMut<str> for str {
pub enum Infallible {}
#[stable(feature = "convert_infallible", since = "1.34.0")]
-#[rustc_const_unstable(feature = "const_clone", issue = "91805")]
-impl const Clone for Infallible {
+impl Clone for Infallible {
fn clone(&self) -> Infallible {
match *self {}
}
@@ -929,8 +914,8 @@ impl Ord for Infallible {
}
#[stable(feature = "convert_infallible", since = "1.34.0")]
-#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
-impl const From<!> for Infallible {
+impl From<!> for Infallible {
+ #[inline]
fn from(x: !) -> Self {
x
}
diff --git a/library/core/src/convert/num.rs b/library/core/src/convert/num.rs
index a74a56bc5..56ab63be2 100644
--- a/library/core/src/convert/num.rs
+++ b/library/core/src/convert/num.rs
@@ -44,8 +44,7 @@ impl_float_to_int!(f64 => u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize);
macro_rules! impl_from {
($Small: ty, $Large: ty, #[$attr:meta], $doc: expr) => {
#[$attr]
- #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")]
- impl const From<$Small> for $Large {
+ impl From<$Small> for $Large {
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
// Rustdocs on functions do not.
#[doc = $doc]
@@ -170,8 +169,7 @@ impl_from! { f32, f64, #[stable(feature = "lossless_float_conv", since = "1.6.0"
// bool -> Float
#[stable(feature = "float_from_bool", since = "1.68.0")]
-#[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")]
-impl const From<bool> for f32 {
+impl From<bool> for f32 {
/// Converts `bool` to `f32` losslessly. The resulting value is positive
/// `0.0` for `false` and `1.0` for `true` values.
///
@@ -190,8 +188,7 @@ impl const From<bool> for f32 {
}
}
#[stable(feature = "float_from_bool", since = "1.68.0")]
-#[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")]
-impl const From<bool> for f64 {
+impl From<bool> for f64 {
/// Converts `bool` to `f64` losslessly. The resulting value is positive
/// `0.0` for `false` and `1.0` for `true` values.
///
@@ -214,8 +211,7 @@ impl const From<bool> for f64 {
macro_rules! try_from_unbounded {
($source:ty, $($target:ty),*) => {$(
#[stable(feature = "try_from", since = "1.34.0")]
- #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")]
- impl const TryFrom<$source> for $target {
+ impl TryFrom<$source> for $target {
type Error = TryFromIntError;
/// Try to create the target number type from a source
@@ -233,8 +229,7 @@ macro_rules! try_from_unbounded {
macro_rules! try_from_lower_bounded {
($source:ty, $($target:ty),*) => {$(
#[stable(feature = "try_from", since = "1.34.0")]
- #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")]
- impl const TryFrom<$source> for $target {
+ impl TryFrom<$source> for $target {
type Error = TryFromIntError;
/// Try to create the target number type from a source
@@ -256,8 +251,7 @@ macro_rules! try_from_lower_bounded {
macro_rules! try_from_upper_bounded {
($source:ty, $($target:ty),*) => {$(
#[stable(feature = "try_from", since = "1.34.0")]
- #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")]
- impl const TryFrom<$source> for $target {
+ impl TryFrom<$source> for $target {
type Error = TryFromIntError;
/// Try to create the target number type from a source
@@ -279,8 +273,7 @@ macro_rules! try_from_upper_bounded {
macro_rules! try_from_both_bounded {
($source:ty, $($target:ty),*) => {$(
#[stable(feature = "try_from", since = "1.34.0")]
- #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")]
- impl const TryFrom<$source> for $target {
+ impl TryFrom<$source> for $target {
type Error = TryFromIntError;
/// Try to create the target number type from a source
@@ -431,8 +424,7 @@ use crate::num::NonZeroUsize;
macro_rules! nzint_impl_from {
($Small: ty, $Large: ty, #[$attr:meta], $doc: expr) => {
#[$attr]
- #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")]
- impl const From<$Small> for $Large {
+ impl From<$Small> for $Large {
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
// Rustdocs on functions do not.
#[doc = $doc]