Skip to content

fn pointers taking references are not Clone #38382

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
sgrif opened this issue Dec 15, 2016 · 4 comments
Closed

fn pointers taking references are not Clone #38382

sgrif opened this issue Dec 15, 2016 · 4 comments
Labels
A-type-system Area: Type system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sgrif
Copy link
Contributor

sgrif commented Dec 15, 2016

The type fn(&'a T) implements Clone, while fn(&T) does not. This presumably applies to more traits than just Clone.

@ghost
Copy link

ghost commented Dec 15, 2016

This is probably related to #28229

@petrochenkov
Copy link
Contributor

More like #24000

The problem can probably be mitigated in practice to some extent by manually implementing fn pointer traits for a few most common cases involving references.
The place to add impls is here.

@sgrif
Copy link
Contributor Author

sgrif commented Dec 19, 2016

Yes, I agree. I did check that adding

fnptr_impls_safety_abi! { extern "Rust" fn($(&$Arg),*) -> Ret, $($Arg),* }

compiles successfully. It does (e.g. no coherence issues). I didn't confirm whether it solved the problem I was encountering though.

@Mark-Simulacrum Mark-Simulacrum added A-type-system Area: Type system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 23, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 26, 2017
@cjgillot
Copy link
Contributor

cjgillot commented Mar 4, 2022

This was fixed a long time ago.

@cjgillot cjgillot closed this as completed Mar 4, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-type-system Area: Type system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants