Skip to content

Commit

Permalink
Derive Clone along with Copy on latest stable.
Browse files Browse the repository at this point in the history
  • Loading branch information
pepyakin committed Oct 23, 2017
1 parent 8582a90 commit 1886fe2
Show file tree
Hide file tree
Showing 202 changed files with 7,154 additions and 5,103 deletions.
5 changes: 4 additions & 1 deletion src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,10 @@ impl CodeGenerator for CompInfo {
ctx.options().derive_copy
{
derives.push("Copy");
if used_template_params.is_some() {

if ctx.options().rust_features().builtin_clone_impls() ||
used_template_params.is_some()
{
// FIXME: This requires extra logic if you have a big array in a
// templated struct. The reason for this is that the magic:
// fn clone(&self) -> Self { *self }
Expand Down
11 changes: 10 additions & 1 deletion src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ macro_rules! rust_target_base {
=> Stable_1_0 => 1.0;
/// Rust stable 1.19
=> Stable_1_19 => 1.19;
/// Rust stable 1.21
=> Stable_1_21 => 1.21;
/// Nightly rust
=> Nightly => nightly;
);
Expand All @@ -100,7 +102,7 @@ rust_target_base!(rust_target_def);
rust_target_base!(rust_target_values_def);

/// Latest stable release of Rust
pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_19;
pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_21;

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

impl From<RustTarget> for RustFeatures {
Expand All @@ -152,6 +156,10 @@ impl From<RustTarget> for RustFeatures {
features.untagged_union = true;
}

if rust_target >= RustTarget::Stable_1_21 {
features.builtin_clone_impls = true;
}

if rust_target >= RustTarget::Nightly {
features.const_fn = true;
features.thiscall_abi = true;
Expand Down Expand Up @@ -183,6 +191,7 @@ mod test {
fn str_to_target() {
test_target("1.0", RustTarget::Stable_1_0);
test_target("1.19", RustTarget::Stable_1_19);
test_target("1.21", RustTarget::Stable_1_21);
test_target("nightly", RustTarget::Nightly);
}
}
Loading

0 comments on commit 1886fe2

Please sign in to comment.