Repository: rust-lang/rust-bindgen
Pull request #2583 (2023-07-14 20:31:08)

Fix `Clone` implementation for `__BindgenUnionField`
Fixes https://github.com/rust-lang/rust-bindgen/issues/2582

cc @emilio 


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e8477daa..1317f8fe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -172,6 +172,8 @@
 
 ## Added
 ## Changed
+- The `Clone` implementation for `_BindgenUnionField` has been changed to pass
+  the `incorrect_clone_impl_on_copy_type` Clippy lint.
 ## Removed
 ## Fixed
 ## Security
diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs
index 9280b7b9..31a4b23a 100644
--- a/bindgen/codegen/mod.rs
+++ b/bindgen/codegen/mod.rs
@@ -4990,7 +4990,7 @@ pub(crate) mod utils {
             impl<T> ::#prefix::clone::Clone for __BindgenUnionField<T> {
                 #[inline]
                 fn clone(&self) -> Self {
-                    Self::new()
+                    *self
                 }
             }
         };


Test patch:
diff --git a/bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs b/bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs
index 758675da..a7d7518a 100644
--- a/bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/16-byte-alignment_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs b/bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs
index 5de1669a..c3b11f63 100644
--- a/bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/anon_struct_in_union_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/anon_union_1_0.rs b/bindgen-tests/tests/expectations/tests/anon_union_1_0.rs
index 90a2e00d..c7e24da1 100644
--- a/bindgen-tests/tests/expectations/tests/anon_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/anon_union_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs b/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs
index 93e2b8e7..2a73a439 100644
--- a/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs
+++ b/bindgen-tests/tests/expectations/tests/bindgen-union-inside-namespace.rs
@@ -26,7 +26,7 @@ pub mod root {
     impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
         #[inline]
         fn clone(&self) -> Self {
-            Self::new()
+            *self
         }
     }
     impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/class_1_0.rs b/bindgen-tests/tests/expectations/tests/class_1_0.rs
index 5d66e212..17cf1182 100644
--- a/bindgen-tests/tests/expectations/tests/class_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/class_1_0.rs
@@ -54,7 +54,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs b/bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs
index 1f0ea9ab..b36faa6c 100644
--- a/bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/class_with_inner_struct_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs b/bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs
index 3429b72b..308b6a65 100644
--- a/bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/derive-partialeq-union_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/disable-untagged-union.rs b/bindgen-tests/tests/expectations/tests/disable-untagged-union.rs
index 7322552a..d507c70a 100644
--- a/bindgen-tests/tests/expectations/tests/disable-untagged-union.rs
+++ b/bindgen-tests/tests/expectations/tests/disable-untagged-union.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/issue-493.rs b/bindgen-tests/tests/expectations/tests/issue-493.rs
index 16c5cc7e..d2e4ea53 100644
--- a/bindgen-tests/tests/expectations/tests/issue-493.rs
+++ b/bindgen-tests/tests/expectations/tests/issue-493.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/issue-493_1_0.rs b/bindgen-tests/tests/expectations/tests/issue-493_1_0.rs
index 0716802f..ff0c9342 100644
--- a/bindgen-tests/tests/expectations/tests/issue-493_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/issue-493_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs
index 7c691a97..2e64796b 100644
--- a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs
@@ -108,7 +108,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs b/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs
index b9ad6437..e2ae2b0c 100644
--- a/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs
@@ -108,7 +108,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs b/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs
index eb8d4b5d..12930079 100644
--- a/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs
@@ -108,7 +108,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/class_1_0.rs b/bindgen-tests/tests/expectations/tests/libclang-9/class_1_0.rs
index 9796b592..b6544212 100644
--- a/bindgen-tests/tests/expectations/tests/libclang-9/class_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/libclang-9/class_1_0.rs
@@ -54,7 +54,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs b/bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs
index 9831363d..8bab61e3 100644
--- a/bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/struct_with_anon_union_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs b/bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs
index 291526fd..ae2ff333 100644
--- a/bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs b/bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs
index f44a3194..6d8a5b97 100644
--- a/bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/struct_with_nesting_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/transform-op.rs b/bindgen-tests/tests/expectations/tests/transform-op.rs
index 57b22ca2..85c34985 100644
--- a/bindgen-tests/tests/expectations/tests/transform-op.rs
+++ b/bindgen-tests/tests/expectations/tests/transform-op.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/typeref_1_0.rs b/bindgen-tests/tests/expectations/tests/typeref_1_0.rs
index e6c60c7f..16bb52c1 100644
--- a/bindgen-tests/tests/expectations/tests/typeref_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/typeref_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs b/bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs
index c1982df1..f80cff75 100644
--- a/bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union-in-ns_1_0.rs
@@ -26,7 +26,7 @@ pub mod root {
     impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
         #[inline]
         fn clone(&self) -> Self {
-            Self::new()
+            *self
         }
     }
     impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs b/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs
index fa7a0d8f..e3b65e50 100644
--- a/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs
@@ -108,7 +108,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs b/bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs
index 9c60ca47..a37109ab 100644
--- a/bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_dtor_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_fields_1_0.rs b/bindgen-tests/tests/expectations/tests/union_fields_1_0.rs
index f59295c0..8fbade8c 100644
--- a/bindgen-tests/tests/expectations/tests/union_fields_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_fields_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_template_1_0.rs b/bindgen-tests/tests/expectations/tests/union_template_1_0.rs
index 3d8d90b8..4ebad2a2 100644
--- a/bindgen-tests/tests/expectations/tests/union_template_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_template_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs
index 269a10aa..4bc131bd 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
index 90bb2743..dec7fc29 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
@@ -108,7 +108,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs
index 176c9ec0..d0158ce1 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_anon_union_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs
index 446044d8..23b1887b 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs
index 57916a89..179a87c9 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs
index adda6a0d..2b50d4e7 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_big_member_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs
index 94fab651..4305d58f 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_nesting_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/union_with_non_copy_member.rs b/bindgen-tests/tests/expectations/tests/union_with_non_copy_member.rs
index 580826f4..d9eaeacd 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_non_copy_member.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_non_copy_member.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/use-core_1_0.rs b/bindgen-tests/tests/expectations/tests/use-core_1_0.rs
index a11ea286..6c56e43e 100644
--- a/bindgen-tests/tests/expectations/tests/use-core_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/use-core_1_0.rs
@@ -25,7 +25,7 @@ impl<T> ::core::default::Default for __BindgenUnionField<T> {
 impl<T> ::core::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::core::marker::Copy for __BindgenUnionField<T> {}
diff --git a/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union_1_0.rs b/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union_1_0.rs
index fdee0709..dfe2213e 100644
--- a/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_anon_union_1_0.rs
@@ -24,7 +24,7 @@ impl<T> ::std::default::Default for __BindgenUnionField<T> {
 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
     #[inline]
     fn clone(&self) -> Self {
-        Self::new()
+        *self
     }
 }
 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}