summaryrefslogtreecommitdiff
path: root/src/codegen/mod.rs
diff options
context:
space:
mode:
authorIan P. Cooke <icooke@3redpartners.com>2021-07-07 06:37:04 -0500
committerEmilio Cobos Álvarez <emilio@crisal.io>2021-07-16 21:31:29 +0200
commita380678490b821201f10b861144b15bbe08694a2 (patch)
treeade618adab094bfa8e6e248cdc0eef05bb08a5a4 /src/codegen/mod.rs
parentf65f2307f69a85cc7857b88409fe89c2bd2f79b7 (diff)
Let Rust derive everything but Default for large arrays in 1.47 and later
Fixes #1977 as of rust-lang/rust#74060 is available since Rust 1.47 Fixes #2041. Closes #2070.
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r--src/codegen/mod.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index c70c1064..d49d3248 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1503,7 +1503,8 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
// We cannot generate any constructor if the underlying storage can't
// implement AsRef<[u8]> / AsMut<[u8]> / etc.
- let mut generate_ctor = layout.size <= RUST_DERIVE_IN_ARRAY_LIMIT;
+ let mut generate_ctor = layout.size <= RUST_DERIVE_IN_ARRAY_LIMIT ||
+ ctx.options().rust_features().larger_arrays;
let mut access_spec = !fields_should_be_private;
for bf in self.bitfields() {
@@ -1512,7 +1513,9 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
continue;
}
- if layout.size > RUST_DERIVE_IN_ARRAY_LIMIT {
+ if layout.size > RUST_DERIVE_IN_ARRAY_LIMIT &&
+ !ctx.options().rust_features().larger_arrays
+ {
continue;
}