summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-04-09 04:56:23 +0000
committerbors <bors@rust-lang.org>2015-04-09 04:56:23 +0000
commit0e5e669272253fa1dcbe08a23977d1f9fb0a392a (patch)
tree886d0125a7b3e008ae3c9d0e90557247d49be0e4 /src/libcore
parent287a544a309b840fd715fe1d5b651b5116bf08fa (diff)
parentdf95719391b2ee94c09162060052755e75f431dc (diff)
downloadrust-0e5e669272253fa1dcbe08a23977d1f9fb0a392a.tar.gz
rust-0e5e669272253fa1dcbe08a23977d1f9fb0a392a.zip
Auto merge of #24168 - kballard:clone-for-extern-c-unsafe-fns, r=alexcrichton
We only implemented Clone on `extern "Rust" fn`s (for up to 8
parameters). This didn't cover `extern "C"` or `unsafe` (or
`unsafe extern "C"`) `fn`s, but there's no reason why they shouldn't be
cloneable as well.

The new impls are marked unstable because the existing impl for `extern
"Rust" fn`s is.

Fixes #24161.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/clone.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs
index 85e5bde4859..91747d7405f 100644
--- a/src/libcore/clone.rs
+++ b/src/libcore/clone.rs
@@ -97,6 +97,27 @@ macro_rules! extern_fn_clone {
             #[inline]
             fn clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self }
         }
+
+        #[unstable(feature = "core", reason = "brand new")]
+        impl<$($A,)* ReturnType> Clone for extern "C" fn($($A),*) -> ReturnType {
+            /// Return a copy of a function pointer
+            #[inline]
+            fn clone(&self) -> extern "C" fn($($A),*) -> ReturnType { *self }
+        }
+
+        #[unstable(feature = "core", reason = "brand new")]
+        impl<$($A,)* ReturnType> Clone for unsafe extern "Rust" fn($($A),*) -> ReturnType {
+            /// Return a copy of a function pointer
+            #[inline]
+            fn clone(&self) -> unsafe extern "Rust" fn($($A),*) -> ReturnType { *self }
+        }
+
+        #[unstable(feature = "core", reason = "brand new")]
+        impl<$($A,)* ReturnType> Clone for unsafe extern "C" fn($($A),*) -> ReturnType {
+            /// Return a copy of a function pointer
+            #[inline]
+            fn clone(&self) -> unsafe extern "C" fn($($A),*) -> ReturnType { *self }
+        }
     )
 }