Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c386ffb

Browse files
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 44d50f9 + 9185143 commit c386ffb

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)

AltStyle によって変換されたページ (->オリジナル) /