Skip to content

Commit b8f5a37

Browse files
authored
Unrolled build for #142756
Rollup merge of #142756 - Daniel-Aaron-Bloom:const-clone, r=oli-obk Make `Clone` a `const_trait` See [tracking issue](#142757) for justification.
2 parents 15c701f + 9185143 commit b8f5a37

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

library/core/src/clone.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
3737
#![stable(feature = "rust1", since = "1.0.0")]
3838

39-
use crate::marker::PointeeSized;
39+
use crate::marker::{Destruct, PointeeSized};
4040

4141
mod uninit;
4242

@@ -157,6 +157,8 @@ mod uninit;
157157
#[lang = "clone"]
158158
#[rustc_diagnostic_item = "Clone"]
159159
#[rustc_trivial_field_reads]
160+
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
161+
#[const_trait]
160162
pub trait Clone: Sized {
161163
/// Returns a duplicate of the value.
162164
///
@@ -208,7 +210,10 @@ pub trait Clone: Sized {
208210
/// allocations.
209211
#[inline]
210212
#[stable(feature = "rust1", since = "1.0.0")]
211-
fn clone_from(&mut self, source: &Self) {
213+
fn clone_from(&mut self, source: &Self)
214+
where
215+
Self: ~const Destruct,
216+
{
212217
*self = source.clone()
213218
}
214219
}

library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
#![feature(cfg_select)]
104104
#![feature(cfg_target_has_reliable_f16_f128)]
105105
#![feature(const_carrying_mul_add)]
106+
#![feature(const_destruct)]
106107
#![feature(const_eval_select)]
107108
#![feature(core_intrinsics)]
108109
#![feature(coverage_attribute)]

0 commit comments

Comments
 (0)