Skip to content
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

extern "C" functions don't implement Clone #24161

Closed
bfops opened this issue Apr 7, 2015 · 3 comments · Fixed by #24168
Closed

extern "C" functions don't implement Clone #24161

bfops opened this issue Apr 7, 2015 · 3 comments · Fixed by #24168
Labels
A-type-system Area: Type system

Comments

@bfops
Copy link
Contributor

bfops commented Apr 7, 2015

This should compile. It used to compile without deriving Clone, and it currently compiles if extern "C" is removed.

#[derive(Copy, Clone)]
struct Functions {
  pub foo: extern "C" fn(u32) -> u32,
}

fn main() {
}
@steveklabnik steveklabnik added the A-type-system Area: Type system label Apr 7, 2015
@lilyball
Copy link
Contributor

lilyball commented Apr 7, 2015

Clone also needs to be implemented for unsafe fn. Right now it's only implemented for fns of 0–8 arguments.

@lilyball
Copy link
Contributor

lilyball commented Apr 7, 2015

Looking at the source it's actually explicitly implemented on extern "Rust" fn.

lilyball added a commit to lilyball/rust that referenced this issue Apr 7, 2015
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.
bors added a commit that referenced this issue Apr 9, 2015
…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.
@bfops
Copy link
Contributor Author

bfops commented Apr 9, 2015

That was quick, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants