-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Clone impls for extern "C" and unsafe fns #24168
Conversation
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 rust-lang#24161.
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
I noodled on this a bit more generically. There are plenty of other supported ABI's in rust, which should all get a Clone impl, right? I'm happy to do the copypasting for the other abi's, I'm just wondering if this is going to end up accidentally combinatorial. |
A way to be generic over all ABIs would be nice: impl<const ABI: &str, ...T, U> extern ABI fn(...T) -> U { ... } |
I just did it with More Macros™ |
Supporting this for other ABIs would be nice as well. I didn't do it because I don't know offhand what other ABIs are available and I didn't really want to produce a huge explosion of Clone impls. I agree that it would be nice to be able to be generic over ABIs, but I don't know how that would really work, as the ABI isn't a value but is in fact a syntactic element (even though it uses quotes). |
tbc, I'm +1 on this change. I'll PR my thing in the next few days, and then we can bikeshed on that PR? |
@kballard Well it would probably involve adding values to the typesystem and redefining the syntax of a function type to take a string value at that position - nothing easily done without a bunch of RFCs post 1.0 though :). |
I would rather not add bindings to all ABIs that we support for now. With specialization we will be able to day |
⌛ Testing commit df95719 with merge 0e5e669... |
…crichton 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.
We only implemented Clone on
extern "Rust" fn
s (for up to 8parameters). This didn't cover
extern "C"
orunsafe
(orunsafe extern "C"
)fn
s, but there's no reason why they shouldn't becloneable as well.
The new impls are marked unstable because the existing impl for
extern "Rust" fn
s is.Fixes #24161.