@@ -127,7 +127,11 @@ pub trait Clone: Sized {
127
127
/// allocations.
128
128
#[ inline]
129
129
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
130
- fn clone_from ( & mut self , source : & Self ) {
130
+ #[ default_method_body_is_const]
131
+ fn clone_from ( & mut self , source : & Self )
132
+ where
133
+ Self : ~const Drop ,
134
+ {
131
135
* self = source. clone ( )
132
136
}
133
137
}
@@ -178,7 +182,8 @@ mod impls {
178
182
( $( $t: ty) * ) => {
179
183
$(
180
184
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
181
- impl Clone for $t {
185
+ #[ rustc_const_unstable( feature = "const_clone" , issue = "91805" ) ]
186
+ impl const Clone for $t {
182
187
#[ inline]
183
188
fn clone( & self ) -> Self {
184
189
* self
@@ -196,23 +201,26 @@ mod impls {
196
201
}
197
202
198
203
#[ unstable( feature = "never_type" , issue = "35121" ) ]
199
- impl Clone for ! {
204
+ #[ rustc_const_unstable( feature = "const_clone" , issue = "91805" ) ]
205
+ impl const Clone for ! {
200
206
#[ inline]
201
207
fn clone ( & self ) -> Self {
202
208
* self
203
209
}
204
210
}
205
211
206
212
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
207
- impl < T : ?Sized > Clone for * const T {
213
+ #[ rustc_const_unstable( feature = "const_clone" , issue = "91805" ) ]
214
+ impl < T : ?Sized > const Clone for * const T {
208
215
#[ inline]
209
216
fn clone ( & self ) -> Self {
210
217
* self
211
218
}
212
219
}
213
220
214
221
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
215
- impl < T : ?Sized > Clone for * mut T {
222
+ #[ rustc_const_unstable( feature = "const_clone" , issue = "91805" ) ]
223
+ impl < T : ?Sized > const Clone for * mut T {
216
224
#[ inline]
217
225
fn clone ( & self ) -> Self {
218
226
* self
@@ -221,7 +229,8 @@ mod impls {
221
229
222
230
/// Shared references can be cloned, but mutable references *cannot*!
223
231
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
224
- impl < T : ?Sized > Clone for & T {
232
+ #[ rustc_const_unstable( feature = "const_clone" , issue = "91805" ) ]
233
+ impl < T : ?Sized > const Clone for & T {
225
234
#[ inline]
226
235
#[ rustc_diagnostic_item = "noop_method_clone" ]
227
236
fn clone ( & self ) -> Self {
0 commit comments