diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 62203e132b70c..1c23218552aa1 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -198,7 +198,8 @@ impl Error for TryFromSliceError { } #[stable(feature = "try_from_slice_error", since = "1.36.0")] -impl From for TryFromSliceError { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for TryFromSliceError { fn from(x: Infallible) -> TryFromSliceError { match x {} } diff --git a/library/core/src/ascii/ascii_char.rs b/library/core/src/ascii/ascii_char.rs index 0b72b4780f163..054ddf844700e 100644 --- a/library/core/src/ascii/ascii_char.rs +++ b/library/core/src/ascii/ascii_char.rs @@ -546,7 +546,8 @@ macro_rules! into_int_impl { ($($ty:ty)*) => { $( #[unstable(feature = "ascii_char", issue = "110998")] - impl From for $ty { + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + impl const From for $ty { #[inline] fn from(chr: AsciiChar) -> $ty { chr as u8 as $ty diff --git a/library/core/src/char/convert.rs b/library/core/src/char/convert.rs index 78cd89fefae71..23061cb663bc6 100644 --- a/library/core/src/char/convert.rs +++ b/library/core/src/char/convert.rs @@ -36,7 +36,8 @@ pub(super) const unsafe fn from_u32_unchecked(i: u32) -> char { } #[stable(feature = "char_convert", since = "1.13.0")] -impl From for u32 { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for u32 { /// Converts a [`char`] into a [`u32`]. /// /// # Examples @@ -53,7 +54,8 @@ impl From for u32 { } #[stable(feature = "more_char_conversions", since = "1.51.0")] -impl From for u64 { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for u64 { /// Converts a [`char`] into a [`u64`]. /// /// # Examples @@ -72,7 +74,8 @@ impl From for u64 { } #[stable(feature = "more_char_conversions", since = "1.51.0")] -impl From for u128 { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for u128 { /// Converts a [`char`] into a [`u128`]. /// /// # Examples @@ -157,7 +160,8 @@ impl TryFrom for u16 { /// for a superset of Windows-1252 that fills the remaining blanks with corresponding /// C0 and C1 control codes. #[stable(feature = "char_convert", since = "1.13.0")] -impl From for char { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for char { /// Converts a [`u8`] into a [`char`]. /// /// # Examples @@ -247,7 +251,8 @@ const fn char_try_from_u32(i: u32) -> Result { } #[stable(feature = "try_from", since = "1.34.0")] -impl TryFrom for char { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const TryFrom for char { type Error = CharTryFromError; #[inline] diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 38381dbdf2303..220a24caf09ee 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -216,6 +216,8 @@ pub const fn identity(x: T) -> T { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "AsRef"] +#[const_trait] +#[rustc_const_unstable(feature = "const_try", issue = "74935")] pub trait AsRef: PointeeSized { /// Converts this type into a shared reference of the (usually inferred) input type. #[stable(feature = "rust1", since = "1.0.0")] @@ -367,6 +369,8 @@ pub trait AsRef: PointeeSized { /// `&mut Vec`, for example, is the better choice (callers need to pass the correct type then). #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "AsMut"] +#[const_trait] +#[rustc_const_unstable(feature = "const_try", issue = "74935")] pub trait AsMut: PointeeSized { /// Converts this type into a mutable reference of the (usually inferred) input type. #[stable(feature = "rust1", since = "1.0.0")] @@ -710,9 +714,10 @@ pub trait TryFrom: Sized { // As lifts over & #[stable(feature = "rust1", since = "1.0.0")] -impl AsRef for &T +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const AsRef for &T where - T: AsRef, + T: ~const AsRef, { #[inline] fn as_ref(&self) -> &U { @@ -722,9 +727,10 @@ where // As lifts over &mut #[stable(feature = "rust1", since = "1.0.0")] -impl AsRef for &mut T +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const AsRef for &mut T where - T: AsRef, + T: ~const AsRef, { #[inline] fn as_ref(&self) -> &U { @@ -742,9 +748,10 @@ where // AsMut lifts over &mut #[stable(feature = "rust1", since = "1.0.0")] -impl AsMut for &mut T +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const AsMut for &mut T where - T: AsMut, + T: ~const AsMut, { #[inline] fn as_mut(&mut self) -> &mut U { @@ -840,7 +847,8 @@ where //////////////////////////////////////////////////////////////////////////////// #[stable(feature = "rust1", since = "1.0.0")] -impl AsRef<[T]> for [T] { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const AsRef<[T]> for [T] { #[inline(always)] fn as_ref(&self) -> &[T] { self @@ -848,7 +856,8 @@ impl AsRef<[T]> for [T] { } #[stable(feature = "rust1", since = "1.0.0")] -impl AsMut<[T]> for [T] { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const AsMut<[T]> for [T] { #[inline(always)] fn as_mut(&mut self) -> &mut [T] { self @@ -856,7 +865,8 @@ impl AsMut<[T]> for [T] { } #[stable(feature = "rust1", since = "1.0.0")] -impl AsRef for str { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const AsRef for str { #[inline(always)] fn as_ref(&self) -> &str { self @@ -864,7 +874,8 @@ impl AsRef for str { } #[stable(feature = "as_mut_str_for_str", since = "1.51.0")] -impl AsMut for str { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const AsMut for str { #[inline(always)] fn as_mut(&mut self) -> &mut str { self @@ -925,7 +936,8 @@ impl AsMut for str { pub enum Infallible {} #[stable(feature = "convert_infallible", since = "1.34.0")] -impl Clone for Infallible { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const Clone for Infallible { fn clone(&self) -> Infallible { match *self {} } @@ -953,7 +965,8 @@ impl Error for Infallible { } #[stable(feature = "convert_infallible", since = "1.34.0")] -impl PartialEq for Infallible { +#[rustc_const_unstable(feature = "const_cmp", issue = "143800")] +impl const PartialEq for Infallible { fn eq(&self, _: &Infallible) -> bool { match *self {} } @@ -977,7 +990,8 @@ impl Ord for Infallible { } #[stable(feature = "convert_infallible", since = "1.34.0")] -impl From for Infallible { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const 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 50616732b7776..affb4eb64d39d 100644 --- a/library/core/src/convert/num.rs +++ b/library/core/src/convert/num.rs @@ -69,7 +69,8 @@ macro_rules! impl_from { }; ($Small:ty => $Large:ty, #[$attr:meta], $doc:expr $(,)?) => { #[$attr] - impl From<$Small> for $Large { + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + impl const From<$Small> for $Large { // Rustdocs on the impl block show a "[+] show undocumented items" toggle. // Rustdocs on functions do not. #[doc = $doc] @@ -200,7 +201,8 @@ macro_rules! impl_float_from_bool { )? ) => { #[stable(feature = "float_from_bool", since = "1.68.0")] - impl From for $float { + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + impl const From 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. /// @@ -250,7 +252,8 @@ impl_float_from_bool!( macro_rules! impl_try_from_unbounded { ($source:ty => $($target:ty),+) => {$( #[stable(feature = "try_from", since = "1.34.0")] - impl TryFrom<$source> for $target { + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + impl const TryFrom<$source> for $target { type Error = TryFromIntError; /// Tries to create the target number type from a source @@ -268,7 +271,8 @@ macro_rules! impl_try_from_unbounded { macro_rules! impl_try_from_lower_bounded { ($source:ty => $($target:ty),+) => {$( #[stable(feature = "try_from", since = "1.34.0")] - impl TryFrom<$source> for $target { + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + impl const TryFrom<$source> for $target { type Error = TryFromIntError; /// Tries to create the target number type from a source @@ -290,7 +294,8 @@ macro_rules! impl_try_from_lower_bounded { macro_rules! impl_try_from_upper_bounded { ($source:ty => $($target:ty),+) => {$( #[stable(feature = "try_from", since = "1.34.0")] - impl TryFrom<$source> for $target { + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + impl const TryFrom<$source> for $target { type Error = TryFromIntError; /// Tries to create the target number type from a source @@ -312,7 +317,8 @@ macro_rules! impl_try_from_upper_bounded { macro_rules! impl_try_from_both_bounded { ($source:ty => $($target:ty),+) => {$( #[stable(feature = "try_from", since = "1.34.0")] - impl TryFrom<$source> for $target { + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + impl const TryFrom<$source> for $target { type Error = TryFromIntError; /// Tries to create the target number type from a source @@ -450,7 +456,8 @@ use crate::num::NonZero; macro_rules! impl_nonzero_int_from_nonzero_int { ($Small:ty => $Large:ty) => { #[stable(feature = "nz_int_conv", since = "1.41.0")] - impl From> for NonZero<$Large> { + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + impl const From> for NonZero<$Large> { // Rustdocs on the impl block show a "[+] show undocumented items" toggle. // Rustdocs on functions do not. #[doc = concat!("Converts [NonZero]\\<[", stringify!($Small), "]> ")] @@ -540,7 +547,8 @@ impl_nonzero_int_try_from_int!(isize); macro_rules! impl_nonzero_int_try_from_nonzero_int { ($source:ty => $($target:ty),+) => {$( #[stable(feature = "nzint_try_from_nzint_conv", since = "1.49.0")] - impl TryFrom> for NonZero<$target> { + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + impl const TryFrom> for NonZero<$target> { type Error = TryFromIntError; // Rustdocs on the impl block show a "[+] show undocumented items" toggle. diff --git a/library/core/src/net/ip_addr.rs b/library/core/src/net/ip_addr.rs index aaa68e8d7d1ad..fef987153cb50 100644 --- a/library/core/src/net/ip_addr.rs +++ b/library/core/src/net/ip_addr.rs @@ -1089,7 +1089,8 @@ impl fmt::Debug for IpAddr { } #[stable(feature = "ip_from_ip", since = "1.16.0")] -impl From for IpAddr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for IpAddr { /// Copies this address to a new `IpAddr::V4`. /// /// # Examples @@ -1111,7 +1112,8 @@ impl From for IpAddr { } #[stable(feature = "ip_from_ip", since = "1.16.0")] -impl From for IpAddr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for IpAddr { /// Copies this address to a new `IpAddr::V6`. /// /// # Examples @@ -1221,7 +1223,8 @@ impl Ord for Ipv4Addr { } #[stable(feature = "ip_u32", since = "1.1.0")] -impl From for u32 { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for u32 { /// Uses [`Ipv4Addr::to_bits`] to convert an IPv4 address to a host byte order `u32`. #[inline] fn from(ip: Ipv4Addr) -> u32 { @@ -1230,7 +1233,8 @@ impl From for u32 { } #[stable(feature = "ip_u32", since = "1.1.0")] -impl From for Ipv4Addr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for Ipv4Addr { /// Uses [`Ipv4Addr::from_bits`] to convert a host byte order `u32` into an IPv4 address. #[inline] fn from(ip: u32) -> Ipv4Addr { @@ -1239,7 +1243,8 @@ impl From for Ipv4Addr { } #[stable(feature = "from_slice_v4", since = "1.9.0")] -impl From<[u8; 4]> for Ipv4Addr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From<[u8; 4]> for Ipv4Addr { /// Creates an `Ipv4Addr` from a four element byte array. /// /// # Examples @@ -1257,7 +1262,8 @@ impl From<[u8; 4]> for Ipv4Addr { } #[stable(feature = "ip_from_slice", since = "1.17.0")] -impl From<[u8; 4]> for IpAddr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From<[u8; 4]> for IpAddr { /// Creates an `IpAddr::V4` from a four element byte array. /// /// # Examples @@ -2211,7 +2217,8 @@ impl Ord for Ipv6Addr { } #[stable(feature = "i128", since = "1.26.0")] -impl From for u128 { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for u128 { /// Uses [`Ipv6Addr::to_bits`] to convert an IPv6 address to a host byte order `u128`. #[inline] fn from(ip: Ipv6Addr) -> u128 { @@ -2219,7 +2226,8 @@ impl From for u128 { } } #[stable(feature = "i128", since = "1.26.0")] -impl From for Ipv6Addr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for Ipv6Addr { /// Uses [`Ipv6Addr::from_bits`] to convert a host byte order `u128` to an IPv6 address. #[inline] fn from(ip: u128) -> Ipv6Addr { @@ -2228,7 +2236,8 @@ impl From for Ipv6Addr { } #[stable(feature = "ipv6_from_octets", since = "1.9.0")] -impl From<[u8; 16]> for Ipv6Addr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From<[u8; 16]> for Ipv6Addr { /// Creates an `Ipv6Addr` from a sixteen element byte array. /// /// # Examples @@ -2255,7 +2264,8 @@ impl From<[u8; 16]> for Ipv6Addr { } #[stable(feature = "ipv6_from_segments", since = "1.16.0")] -impl From<[u16; 8]> for Ipv6Addr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From<[u16; 8]> for Ipv6Addr { /// Creates an `Ipv6Addr` from an eight element 16-bit array. /// /// # Examples @@ -2283,7 +2293,8 @@ impl From<[u16; 8]> for Ipv6Addr { } #[stable(feature = "ip_from_slice", since = "1.17.0")] -impl From<[u8; 16]> for IpAddr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From<[u8; 16]> for IpAddr { /// Creates an `IpAddr::V6` from a sixteen element byte array. /// /// # Examples @@ -2310,7 +2321,8 @@ impl From<[u8; 16]> for IpAddr { } #[stable(feature = "ip_from_slice", since = "1.17.0")] -impl From<[u16; 8]> for IpAddr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From<[u16; 8]> for IpAddr { /// Creates an `IpAddr::V6` from an eight element 16-bit array. /// /// # Examples diff --git a/library/core/src/net/socket_addr.rs b/library/core/src/net/socket_addr.rs index 936f9f64930d5..69924199f99f1 100644 --- a/library/core/src/net/socket_addr.rs +++ b/library/core/src/net/socket_addr.rs @@ -592,7 +592,8 @@ impl SocketAddrV6 { } #[stable(feature = "ip_from_ip", since = "1.16.0")] -impl From for SocketAddr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for SocketAddr { /// Converts a [`SocketAddrV4`] into a [`SocketAddr::V4`]. #[inline] fn from(sock4: SocketAddrV4) -> SocketAddr { @@ -601,7 +602,8 @@ impl From for SocketAddr { } #[stable(feature = "ip_from_ip", since = "1.16.0")] -impl From for SocketAddr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for SocketAddr { /// Converts a [`SocketAddrV6`] into a [`SocketAddr::V6`]. #[inline] fn from(sock6: SocketAddrV6) -> SocketAddr { @@ -610,7 +612,8 @@ impl From for SocketAddr { } #[stable(feature = "addr_from_into_ip", since = "1.17.0")] -impl> From<(I, u16)> for SocketAddr { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl> const From<(I, u16)> for SocketAddr { /// Converts a tuple struct (Into<[`IpAddr`]>, `u16`) into a [`SocketAddr`]. /// /// This conversion creates a [`SocketAddr::V4`] for an [`IpAddr::V4`] diff --git a/library/core/src/num/error.rs b/library/core/src/num/error.rs index f9c4cdd0ebe63..cfedd465cab0b 100644 --- a/library/core/src/num/error.rs +++ b/library/core/src/num/error.rs @@ -26,14 +26,16 @@ impl Error for TryFromIntError { } #[stable(feature = "try_from", since = "1.34.0")] -impl From for TryFromIntError { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for TryFromIntError { fn from(x: Infallible) -> TryFromIntError { match x {} } } #[unstable(feature = "never_type", issue = "35121")] -impl From for TryFromIntError { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for TryFromIntError { #[inline] fn from(never: !) -> TryFromIntError { // Match rather than coerce to make sure that code like diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index faa41ddf13ca8..acfe38b7a37b5 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -1378,7 +1378,8 @@ const fn from_ascii_radix_panic(radix: u32) -> ! { macro_rules! from_str_int_impl { ($signedness:ident $($int_ty:ty)+) => {$( #[stable(feature = "rust1", since = "1.0.0")] - impl FromStr for $int_ty { + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + impl const FromStr for $int_ty { type Err = ParseIntError; /// Parses an integer from a string slice with decimal digits. diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index b8900c4113ad3..f793602de5087 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -297,7 +297,8 @@ where } #[stable(feature = "from_nonzero", since = "1.31.0")] -impl From> for T +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From> for T where T: ZeroablePrimitive, { diff --git a/library/core/src/ops/try_trait.rs b/library/core/src/ops/try_trait.rs index aebbddb4f1c07..a889c824be53d 100644 --- a/library/core/src/ops/try_trait.rs +++ b/library/core/src/ops/try_trait.rs @@ -128,7 +128,9 @@ use crate::ops::ControlFlow; )] #[doc(alias = "?")] #[lang = "Try"] -pub trait Try: FromResidual { +#[const_trait] +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +pub trait Try: ~const FromResidual { /// The type of the value produced by `?` when *not* short-circuiting. #[unstable(feature = "try_trait_v2", issue = "84277", old_name = "try_trait")] type Output; @@ -304,6 +306,8 @@ pub trait Try: FromResidual { )] #[rustc_diagnostic_item = "FromResidual"] #[unstable(feature = "try_trait_v2", issue = "84277", old_name = "try_trait")] +#[const_trait] +#[rustc_const_unstable(feature = "const_try", issue = "74935")] pub trait FromResidual::Residual> { /// Constructs the type from a compatible `Residual` type. /// @@ -357,6 +361,8 @@ where /// and in the other direction, /// ` as Residual>::TryType = Result`. #[unstable(feature = "try_trait_v2_residual", issue = "91285")] +#[const_trait] +#[rustc_const_unstable(feature = "const_try", issue = "74935")] pub trait Residual { /// The "return" type of this meta-function. #[unstable(feature = "try_trait_v2_residual", issue = "91285")] diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 8036c59e893a3..7f8c30b95b20f 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -2144,9 +2144,12 @@ const fn expect_failed(msg: &str) -> ! { ///////////////////////////////////////////////////////////////////////////// #[stable(feature = "rust1", since = "1.0.0")] -impl Clone for Option +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const Clone for Option where - T: Clone, + // FIXME(const_hack): the T: ~const Destruct should be inferred from the Self: ~const Destruct in clone_from. + // See https://github.com/rust-lang/rust/issues/144207 + T: ~const Clone + ~const Destruct, { #[inline] fn clone(&self) -> Self { @@ -2230,7 +2233,8 @@ impl<'a, T> IntoIterator for &'a mut Option { } #[stable(since = "1.12.0", feature = "option_from")] -impl From for Option { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for Option { /// Moves `val` into a new [`Some`]. /// /// # Examples @@ -2246,7 +2250,8 @@ impl From for Option { } #[stable(feature = "option_ref_from_ref_option", since = "1.30.0")] -impl<'a, T> From<&'a Option> for Option<&'a T> { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl<'a, T> const From<&'a Option> for Option<&'a T> { /// Converts from `&Option` to `Option<&T>`. /// /// # Examples @@ -2273,7 +2278,8 @@ impl<'a, T> From<&'a Option> for Option<&'a T> { } #[stable(feature = "option_ref_from_ref_option", since = "1.30.0")] -impl<'a, T> From<&'a mut Option> for Option<&'a mut T> { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl<'a, T> const From<&'a mut Option> for Option<&'a mut T> { /// Converts from `&mut Option` to `Option<&mut T>` /// /// # Examples @@ -2593,7 +2599,8 @@ impl> FromIterator> for Option { } #[unstable(feature = "try_trait_v2", issue = "84277", old_name = "try_trait")] -impl ops::Try for Option { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const ops::Try for Option { type Output = T; type Residual = Option; @@ -2612,9 +2619,10 @@ impl ops::Try for Option { } #[unstable(feature = "try_trait_v2", issue = "84277", old_name = "try_trait")] +#[rustc_const_unstable(feature = "const_try", issue = "74935")] // Note: manually specifying the residual type instead of using the default to work around // https://github.com/rust-lang/rust/issues/99940 -impl ops::FromResidual> for Option { +impl const ops::FromResidual> for Option { #[inline] fn from_residual(residual: Option) -> Self { match residual { @@ -2625,7 +2633,8 @@ impl ops::FromResidual> for Option { #[diagnostic::do_not_recommend] #[unstable(feature = "try_trait_v2_yeet", issue = "96374")] -impl ops::FromResidual> for Option { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const ops::FromResidual> for Option { #[inline] fn from_residual(ops::Yeet(()): ops::Yeet<()>) -> Self { None @@ -2633,7 +2642,8 @@ impl ops::FromResidual> for Option { } #[unstable(feature = "try_trait_v2_residual", issue = "91285")] -impl ops::Residual for Option { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const ops::Residual for Option { type TryType = Option; } diff --git a/library/core/src/ptr/alignment.rs b/library/core/src/ptr/alignment.rs index 6d473a4bd5663..bd5b4e21baa0f 100644 --- a/library/core/src/ptr/alignment.rs +++ b/library/core/src/ptr/alignment.rs @@ -189,7 +189,8 @@ impl TryFrom for Alignment { } #[unstable(feature = "ptr_alignment_type", issue = "102070")] -impl From for NonZero { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for NonZero { #[inline] fn from(align: Alignment) -> NonZero { align.as_nonzero() @@ -197,7 +198,8 @@ impl From for NonZero { } #[unstable(feature = "ptr_alignment_type", issue = "102070")] -impl From for usize { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for usize { #[inline] fn from(align: Alignment) -> usize { align.as_usize() diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 7f3f296498544..f65257ff59b92 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -1288,9 +1288,11 @@ impl Result { /// ``` #[unstable(feature = "unwrap_infallible", reason = "newly added", issue = "61695")] #[inline] - pub fn into_ok(self) -> T + #[rustc_allow_const_fn_unstable(const_precise_live_drops)] + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + pub const fn into_ok(self) -> T where - E: Into, + E: ~const Into, { match self { Ok(x) => x, @@ -1323,9 +1325,11 @@ impl Result { /// ``` #[unstable(feature = "unwrap_infallible", reason = "newly added", issue = "61695")] #[inline] - pub fn into_err(self) -> E + #[rustc_allow_const_fn_unstable(const_precise_live_drops)] + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + pub const fn into_err(self) -> E where - T: Into, + T: ~const Into, { match self { Ok(x) => x.into(), @@ -2052,7 +2056,8 @@ impl> FromIterator> for Result { } #[unstable(feature = "try_trait_v2", issue = "84277", old_name = "try_trait")] -impl ops::Try for Result { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const ops::Try for Result { type Output = T; type Residual = Result; @@ -2071,7 +2076,10 @@ impl ops::Try for Result { } #[unstable(feature = "try_trait_v2", issue = "84277", old_name = "try_trait")] -impl> ops::FromResidual> for Result { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl> const ops::FromResidual> + for Result +{ #[inline] #[track_caller] fn from_residual(residual: Result) -> Self { @@ -2082,7 +2090,8 @@ impl> ops::FromResidual> for Res } #[diagnostic::do_not_recommend] #[unstable(feature = "try_trait_v2_yeet", issue = "96374")] -impl> ops::FromResidual> for Result { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl> const ops::FromResidual> for Result { #[inline] fn from_residual(ops::Yeet(e): ops::Yeet) -> Self { Err(From::from(e)) @@ -2090,6 +2099,7 @@ impl> ops::FromResidual> for Result { } #[unstable(feature = "try_trait_v2_residual", issue = "91285")] -impl ops::Residual for Result { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const ops::Residual for Result { type TryType = Result; } diff --git a/library/core/src/str/traits.rs b/library/core/src/str/traits.rs index d0f2b9226bf6d..1597d1c1fa868 100644 --- a/library/core/src/str/traits.rs +++ b/library/core/src/str/traits.rs @@ -825,6 +825,8 @@ unsafe impl const SliceIndex for ops::RangeToInclusive { /// assert!(Point::from_str("(1 2)").is_err()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[const_trait] +#[rustc_const_unstable(feature = "const_try", issue = "74935")] pub trait FromStr: Sized { /// The associated error which can be returned from parsing. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 04c8d1473b048..546f3d91a8099 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -2518,7 +2518,8 @@ impl AtomicPtr { #[cfg(target_has_atomic_load_store = "8")] #[stable(feature = "atomic_bool_from", since = "1.24.0")] -impl From for AtomicBool { +#[rustc_const_unstable(feature = "const_try", issue = "74935")] +impl const From for AtomicBool { /// Converts a `bool` into an `AtomicBool`. /// /// # Examples @@ -2615,7 +2616,8 @@ macro_rules! atomic_int { } #[$stable_from] - impl From<$int_type> for $atomic_type { + #[rustc_const_unstable(feature = "const_try", issue = "74935")] + impl const From<$int_type> for $atomic_type { #[doc = concat!("Converts an `", stringify!($int_type), "` into an `", stringify!($atomic_type), "`.")] #[inline] fn from(v: $int_type) -> Self { Self::new(v) } diff --git a/tests/ui/consts/const-try-feature-gate.rs b/tests/ui/consts/const-try-feature-gate.rs index 09985079e8e82..4a98185a18a7f 100644 --- a/tests/ui/consts/const-try-feature-gate.rs +++ b/tests/ui/consts/const-try-feature-gate.rs @@ -4,6 +4,8 @@ const fn t() -> Option<()> { Some(())?; //~^ ERROR `?` is not allowed //~| ERROR `?` is not allowed + //~| ERROR `Try` is not yet stable as a const trait + //~| ERROR `FromResidual` is not yet stable as a const trait None } diff --git a/tests/ui/consts/const-try-feature-gate.stderr b/tests/ui/consts/const-try-feature-gate.stderr index 0ad19d05b3828..62a4a5fba4ffb 100644 --- a/tests/ui/consts/const-try-feature-gate.stderr +++ b/tests/ui/consts/const-try-feature-gate.stderr @@ -1,19 +1,47 @@ -error[E0015]: `?` is not allowed on `Option<()>` in constant functions +error[E0658]: `?` is not allowed on `Option<()>` in constant functions --> $DIR/const-try-feature-gate.rs:4:5 | LL | Some(())?; | ^^^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: see issue #143874 for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0015]: `?` is not allowed on `Option<()>` in constant functions +error: `Try` is not yet stable as a const trait + --> $DIR/const-try-feature-gate.rs:4:5 + | +LL | Some(())?; + | ^^^^^^^^^ + | +help: add `#![feature(const_try)]` to the crate attributes to enable + | +LL + #![feature(const_try)] + | + +error[E0658]: `?` is not allowed on `Option<()>` in constant functions --> $DIR/const-try-feature-gate.rs:4:5 | LL | Some(())?; | ^^^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: see issue #143874 for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: `FromResidual` is not yet stable as a const trait + --> $DIR/const-try-feature-gate.rs:4:5 + | +LL | Some(())?; + | ^^^^^^^^^ + | +help: add `#![feature(const_try)]` to the crate attributes to enable + | +LL + #![feature(const_try)] + | -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/const-try.rs b/tests/ui/consts/const-try.rs index e13fad78441d6..152400d702ecd 100644 --- a/tests/ui/consts/const-try.rs +++ b/tests/ui/consts/const-try.rs @@ -1,4 +1,6 @@ -//@ compile-flags: -Znext-solver +//@ check-pass +//@ revisions: current next +//@[next] compile-flags: -Znext-solver // Demonstrates what's needed to make use of `?` in const contexts. @@ -13,14 +15,12 @@ struct TryMe; struct Error; impl const FromResidual for TryMe { - //~^ ERROR const `impl` for trait `FromResidual` which is not `const` fn from_residual(residual: Error) -> Self { TryMe } } impl const Try for TryMe { - //~^ ERROR const `impl` for trait `Try` which is not `const` type Output = (); type Residual = Error; fn from_output(output: Self::Output) -> Self { @@ -33,8 +33,6 @@ impl const Try for TryMe { const fn t() -> TryMe { TryMe?; - //~^ ERROR `?` is not allowed on - //~| ERROR `?` is not allowed on TryMe } diff --git a/tests/ui/consts/const-try.stderr b/tests/ui/consts/const-try.stderr deleted file mode 100644 index 7004ea3e6dbb0..0000000000000 --- a/tests/ui/consts/const-try.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error: const `impl` for trait `FromResidual` which is not `const` - --> $DIR/const-try.rs:15:12 - | -LL | impl const FromResidual for TryMe { - | ^^^^^^^^^^^^^^^^^^^ this trait is not `const` - | - = note: marking a trait with `const` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error: const `impl` for trait `Try` which is not `const` - --> $DIR/const-try.rs:22:12 - | -LL | impl const Try for TryMe { - | ^^^ this trait is not `const` - | - = note: marking a trait with `const` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error[E0015]: `?` is not allowed on `TryMe` in constant functions - --> $DIR/const-try.rs:35:5 - | -LL | TryMe?; - | ^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: `?` is not allowed on `TryMe` in constant functions - --> $DIR/const-try.rs:35:5 - | -LL | TryMe?; - | ^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/control-flow/try.rs b/tests/ui/consts/control-flow/try.rs index 67083e1a39b5d..6d762f9194e63 100644 --- a/tests/ui/consts/control-flow/try.rs +++ b/tests/ui/consts/control-flow/try.rs @@ -1,11 +1,12 @@ -// The `?` operator is still not const-evaluatable because it calls `From::from` on the error -// variant. +//@ check-pass + +#![allow(dead_code)] +#![feature(const_trait_impl)] +#![feature(const_try)] const fn opt() -> Option { let x = Some(2); x?; - //~^ ERROR: `?` is not allowed - //~| ERROR: `?` is not allowed None } diff --git a/tests/ui/consts/control-flow/try.stderr b/tests/ui/consts/control-flow/try.stderr deleted file mode 100644 index 62a3e3ce6bc33..0000000000000 --- a/tests/ui/consts/control-flow/try.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0015]: `?` is not allowed on `Option` in constant functions - --> $DIR/try.rs:6:5 - | -LL | x?; - | ^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: `?` is not allowed on `Option` in constant functions - --> $DIR/try.rs:6:5 - | -LL | x?; - | ^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/try-operator.rs b/tests/ui/consts/try-operator.rs index 352dbeefa8a60..59d9fcb1cbdbf 100644 --- a/tests/ui/consts/try-operator.rs +++ b/tests/ui/consts/try-operator.rs @@ -1,9 +1,8 @@ -//@ known-bug: #110395 +//@ run-pass #![feature(try_trait_v2)] #![feature(const_trait_impl)] #![feature(const_try)] -#![feature(const_convert)] fn main() { const fn result() -> Result { diff --git a/tests/ui/consts/try-operator.stderr b/tests/ui/consts/try-operator.stderr deleted file mode 100644 index fc37039d2606b..0000000000000 --- a/tests/ui/consts/try-operator.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0635]: unknown feature `const_convert` - --> $DIR/try-operator.rs:6:12 - | -LL | #![feature(const_convert)] - | ^^^^^^^^^^^^^ - -error[E0015]: `?` is not allowed on `Result<(), ()>` in constant functions - --> $DIR/try-operator.rs:10:9 - | -LL | Err(())?; - | ^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: `?` is not allowed on `Result` in constant functions - --> $DIR/try-operator.rs:10:9 - | -LL | Err(())?; - | ^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: `?` is not allowed on `Option<()>` in constant functions - --> $DIR/try-operator.rs:18:9 - | -LL | None?; - | ^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: `?` is not allowed on `Option<()>` in constant functions - --> $DIR/try-operator.rs:18:9 - | -LL | None?; - | ^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 5 previous errors - -Some errors have detailed explanations: E0015, E0635. -For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/hir-const-check.rs b/tests/ui/traits/const-traits/hir-const-check.rs index c485fb121841b..1b6fa1afab9fa 100644 --- a/tests/ui/traits/const-traits/hir-const-check.rs +++ b/tests/ui/traits/const-traits/hir-const-check.rs @@ -1,8 +1,10 @@ +//@ check-pass //@ compile-flags: -Znext-solver // Regression test for #69615. #![feature(const_trait_impl)] +#![feature(const_try)] #[const_trait] pub trait MyTrait { @@ -12,8 +14,6 @@ pub trait MyTrait { impl const MyTrait for () { fn method(&self) -> Option<()> { Some(())?; - //~^ ERROR `?` is not allowed on - //~| ERROR `?` is not allowed on None } } diff --git a/tests/ui/traits/const-traits/hir-const-check.stderr b/tests/ui/traits/const-traits/hir-const-check.stderr deleted file mode 100644 index d66a7ea31449b..0000000000000 --- a/tests/ui/traits/const-traits/hir-const-check.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0015]: `?` is not allowed on `Option<()>` in constant functions - --> $DIR/hir-const-check.rs:14:9 - | -LL | Some(())?; - | ^^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: `?` is not allowed on `Option<()>` in constant functions - --> $DIR/hir-const-check.rs:14:9 - | -LL | Some(())?; - | ^^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs index 47c85980aca0a..af552ac0c5e71 100644 --- a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs +++ b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs @@ -1,11 +1,10 @@ #![allow(incomplete_features)] -#![feature(const_trait_impl, try_trait_v2)] +#![feature(const_trait_impl, const_try, try_trait_v2)] use std::ops::FromResidual; impl const FromResidual for T { - //~^ ERROR const `impl` for trait `FromResidual` which is not `const` - //~| ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as the type parameter for some local type fn from_residual(t: T) -> _ { //~^ ERROR the placeholder `_` is not allowed t diff --git a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr index 5c5fba95f0249..08fc73fe77b4d 100644 --- a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr +++ b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr @@ -1,12 +1,3 @@ -error: const `impl` for trait `FromResidual` which is not `const` - --> $DIR/ice-119717-constant-lifetime.rs:6:15 - | -LL | impl const FromResidual for T { - | ^^^^^^^^^^^^ this trait is not `const` - | - = note: marking a trait with `const` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) --> $DIR/ice-119717-constant-lifetime.rs:6:6 | @@ -17,7 +8,7 @@ LL | impl const FromResidual for T { = note: only traits defined in the current crate can be implemented for a type parameter error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions - --> $DIR/ice-119717-constant-lifetime.rs:9:31 + --> $DIR/ice-119717-constant-lifetime.rs:8:31 | LL | fn from_residual(t: T) -> _ { | ^ not allowed in type signatures @@ -28,7 +19,7 @@ LL - fn from_residual(t: T) -> _ { LL + fn from_residual(t: T) -> T { | -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0121, E0210. For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.rs b/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.rs index 5e368b9e6a96c..bfce9dc9c7334 100644 --- a/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.rs +++ b/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.rs @@ -6,20 +6,16 @@ struct TryMe; struct Error; impl const FromResidual for TryMe {} -//~^ ERROR const `impl` for trait `FromResidual` which is not `const` -//~| ERROR not all trait items implemented +//~^ ERROR not all trait items implemented impl const Try for TryMe { - //~^ ERROR const `impl` for trait `Try` which is not `const` - //~| ERROR not all trait items implemented + //~^ ERROR not all trait items implemented type Output = (); type Residual = Error; } const fn t() -> TryMe { TryMe?; - //~^ ERROR `?` is not allowed on - //~| ERROR `?` is not allowed on TryMe } diff --git a/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr b/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr index 849d6522cd6e9..183203aa8ba51 100644 --- a/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr +++ b/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr @@ -1,12 +1,3 @@ -error: const `impl` for trait `FromResidual` which is not `const` - --> $DIR/ice-126148-failed-to-normalize.rs:8:12 - | -LL | impl const FromResidual for TryMe {} - | ^^^^^^^^^^^^^^^^^^^ this trait is not `const` - | - = note: marking a trait with `const` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - error[E0046]: not all trait items implemented, missing: `from_residual` --> $DIR/ice-126148-failed-to-normalize.rs:8:1 | @@ -15,17 +6,8 @@ LL | impl const FromResidual for TryMe {} | = help: implement the missing item: `fn from_residual(_: Error) -> Self { todo!() }` -error: const `impl` for trait `Try` which is not `const` - --> $DIR/ice-126148-failed-to-normalize.rs:12:12 - | -LL | impl const Try for TryMe { - | ^^^ this trait is not `const` - | - = note: marking a trait with `const` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - error[E0046]: not all trait items implemented, missing: `from_output`, `branch` - --> $DIR/ice-126148-failed-to-normalize.rs:12:1 + --> $DIR/ice-126148-failed-to-normalize.rs:11:1 | LL | impl const Try for TryMe { | ^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_output`, `branch` in implementation @@ -33,23 +15,6 @@ LL | impl const Try for TryMe { = help: implement the missing item: `fn from_output(_: ::Output) -> Self { todo!() }` = help: implement the missing item: `fn branch(self) -> ControlFlow<::Residual, ::Output> { todo!() }` -error[E0015]: `?` is not allowed on `TryMe` in constant functions - --> $DIR/ice-126148-failed-to-normalize.rs:20:5 - | -LL | TryMe?; - | ^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: `?` is not allowed on `TryMe` in constant functions - --> $DIR/ice-126148-failed-to-normalize.rs:20:5 - | -LL | TryMe?; - | ^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 6 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0015, E0046. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/traits/const-traits/trait-default-body-stability.rs b/tests/ui/traits/const-traits/trait-default-body-stability.rs index 567f1b3c28424..a8157d37ce3f9 100644 --- a/tests/ui/traits/const-traits/trait-default-body-stability.rs +++ b/tests/ui/traits/const-traits/trait-default-body-stability.rs @@ -1,4 +1,4 @@ -//@ known-bug: #110395 +//@ check-pass //@ compile-flags: -Znext-solver #![allow(incomplete_features)] #![feature(staged_api)] diff --git a/tests/ui/traits/const-traits/trait-default-body-stability.stderr b/tests/ui/traits/const-traits/trait-default-body-stability.stderr deleted file mode 100644 index b995d6f4f3d4a..0000000000000 --- a/tests/ui/traits/const-traits/trait-default-body-stability.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error: const `impl` for trait `Try` which is not `const` - --> $DIR/trait-default-body-stability.rs:19:12 - | -LL | impl const Try for T { - | ^^^ this trait is not `const` - | - = note: marking a trait with `const` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error: const `impl` for trait `FromResidual` which is not `const` - --> $DIR/trait-default-body-stability.rs:34:12 - | -LL | impl const FromResidual for T { - | ^^^^^^^^^^^^ this trait is not `const` - | - = note: marking a trait with `const` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error[E0015]: `?` is not allowed on `T` in constant functions - --> $DIR/trait-default-body-stability.rs:46:9 - | -LL | T? - | ^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: `?` is not allowed on `T` in constant functions - --> $DIR/trait-default-body-stability.rs:46:9 - | -LL | T? - | ^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0015`.