577
577
#![ stable( feature = "rust1" , since = "1.0.0" ) ]
578
578
579
579
use crate :: iter:: { self , FusedIterator , TrustedLen } ;
580
+ use crate :: marker:: Destruct ;
580
581
use crate :: ops:: { self , ControlFlow , Deref , DerefMut } ;
581
582
use crate :: panicking:: { panic, panic_display} ;
582
583
use crate :: pin:: Pin ;
@@ -2087,9 +2088,10 @@ const fn expect_failed(msg: &str) -> ! {
2087
2088
/////////////////////////////////////////////////////////////////////////////
2088
2089
2089
2090
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2090
- impl < T > Clone for Option < T >
2091
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
2092
+ impl < T > const Clone for Option < T >
2091
2093
where
2092
- T : Clone ,
2094
+ T : ~ const Clone + ~ const Destruct ,
2093
2095
{
2094
2096
#[ inline]
2095
2097
fn clone ( & self ) -> Self {
@@ -2173,7 +2175,8 @@ impl<'a, T> IntoIterator for &'a mut Option<T> {
2173
2175
}
2174
2176
2175
2177
#[ stable( since = "1.12.0" , feature = "option_from" ) ]
2176
- impl < T > From < T > for Option < T > {
2178
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
2179
+ impl < T > const From < T > for Option < T > {
2177
2180
/// Moves `val` into a new [`Some`].
2178
2181
///
2179
2182
/// # Examples
@@ -2189,7 +2192,8 @@ impl<T> From<T> for Option<T> {
2189
2192
}
2190
2193
2191
2194
#[ stable( feature = "option_ref_from_ref_option" , since = "1.30.0" ) ]
2192
- impl < ' a , T > From < & ' a Option < T > > for Option < & ' a T > {
2195
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
2196
+ impl < ' a , T > const From < & ' a Option < T > > for Option < & ' a T > {
2193
2197
/// Converts from `&Option<T>` to `Option<&T>`.
2194
2198
///
2195
2199
/// # Examples
@@ -2216,7 +2220,8 @@ impl<'a, T> From<&'a Option<T>> for Option<&'a T> {
2216
2220
}
2217
2221
2218
2222
#[ stable( feature = "option_ref_from_ref_option" , since = "1.30.0" ) ]
2219
- impl < ' a , T > From < & ' a mut Option < T > > for Option < & ' a mut T > {
2223
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
2224
+ impl < ' a , T > const From < & ' a mut Option < T > > for Option < & ' a mut T > {
2220
2225
/// Converts from `&mut Option<T>` to `Option<&mut T>`
2221
2226
///
2222
2227
/// # Examples
@@ -2535,7 +2540,8 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
2535
2540
}
2536
2541
2537
2542
#[ unstable( feature = "try_trait_v2" , issue = "84277" , old_name = "try_trait" ) ]
2538
- impl < T > ops:: Try for Option < T > {
2543
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
2544
+ impl < T > const ops:: Try for Option < T > {
2539
2545
type Output = T ;
2540
2546
type Residual = Option < convert:: Infallible > ;
2541
2547
@@ -2554,9 +2560,10 @@ impl<T> ops::Try for Option<T> {
2554
2560
}
2555
2561
2556
2562
#[ unstable( feature = "try_trait_v2" , issue = "84277" , old_name = "try_trait" ) ]
2563
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
2557
2564
// Note: manually specifying the residual type instead of using the default to work around
2558
2565
// https://github.com/rust-lang/rust/issues/99940
2559
- impl < T > ops:: FromResidual < Option < convert:: Infallible > > for Option < T > {
2566
+ impl < T > const ops:: FromResidual < Option < convert:: Infallible > > for Option < T > {
2560
2567
#[ inline]
2561
2568
fn from_residual ( residual : Option < convert:: Infallible > ) -> Self {
2562
2569
match residual {
@@ -2567,15 +2574,17 @@ impl<T> ops::FromResidual<Option<convert::Infallible>> for Option<T> {
2567
2574
2568
2575
#[ diagnostic:: do_not_recommend]
2569
2576
#[ unstable( feature = "try_trait_v2_yeet" , issue = "96374" ) ]
2570
- impl < T > ops:: FromResidual < ops:: Yeet < ( ) > > for Option < T > {
2577
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
2578
+ impl < T > const ops:: FromResidual < ops:: Yeet < ( ) > > for Option < T > {
2571
2579
#[ inline]
2572
2580
fn from_residual ( ops:: Yeet ( ( ) ) : ops:: Yeet < ( ) > ) -> Self {
2573
2581
None
2574
2582
}
2575
2583
}
2576
2584
2577
2585
#[ unstable( feature = "try_trait_v2_residual" , issue = "91285" ) ]
2578
- impl < T > ops:: Residual < T > for Option < convert:: Infallible > {
2586
+ #[ rustc_const_unstable( feature = "const_trait_impl" , issue = "67792" ) ]
2587
+ impl < T > const ops:: Residual < T > for Option < convert:: Infallible > {
2579
2588
type TryType = Option < T > ;
2580
2589
}
2581
2590
0 commit comments