Skip to content

Commit 1886fe2

Browse files
committed
Derive Clone along with Copy on latest stable.
1 parent 8582a90 commit 1886fe2

File tree

202 files changed

+7154
-5103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+7154
-5103
lines changed

src/codegen/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,10 @@ impl CodeGenerator for CompInfo {
16421642
ctx.options().derive_copy
16431643
{
16441644
derives.push("Copy");
1645-
if used_template_params.is_some() {
1645+
1646+
if ctx.options().rust_features().builtin_clone_impls() ||
1647+
used_template_params.is_some()
1648+
{
16461649
// FIXME: This requires extra logic if you have a big array in a
16471650
// templated struct. The reason for this is that the magic:
16481651
// fn clone(&self) -> Self { *self }

src/features.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ macro_rules! rust_target_base {
9090
=> Stable_1_0 => 1.0;
9191
/// Rust stable 1.19
9292
=> Stable_1_19 => 1.19;
93+
/// Rust stable 1.21
94+
=> Stable_1_21 => 1.21;
9395
/// Nightly rust
9496
=> Nightly => nightly;
9597
);
@@ -100,7 +102,7 @@ rust_target_base!(rust_target_def);
100102
rust_target_base!(rust_target_values_def);
101103

102104
/// Latest stable release of Rust
103-
pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_19;
105+
pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_21;
104106

105107
/// Create RustFeatures struct definition, new(), and a getter for each field
106108
macro_rules! rust_feature_def {
@@ -142,6 +144,8 @@ rust_feature_def!(
142144
=> const_fn;
143145
/// `thiscall` calling convention ([Tracking issue](https://github.com/rust-lang/rust/issues/42202))
144146
=> thiscall_abi;
147+
/// builtin impls for `Clone` ([PR](https://github.com/rust-lang/rust/pull/43690))
148+
=> builtin_clone_impls;
145149
);
146150

147151
impl From<RustTarget> for RustFeatures {
@@ -152,6 +156,10 @@ impl From<RustTarget> for RustFeatures {
152156
features.untagged_union = true;
153157
}
154158

159+
if rust_target >= RustTarget::Stable_1_21 {
160+
features.builtin_clone_impls = true;
161+
}
162+
155163
if rust_target >= RustTarget::Nightly {
156164
features.const_fn = true;
157165
features.thiscall_abi = true;
@@ -183,6 +191,7 @@ mod test {
183191
fn str_to_target() {
184192
test_target("1.0", RustTarget::Stable_1_0);
185193
test_target("1.19", RustTarget::Stable_1_19);
194+
test_target("1.21", RustTarget::Stable_1_21);
186195
test_target("nightly", RustTarget::Nightly);
187196
}
188197
}

0 commit comments

Comments
 (0)