Uh oh!
There was an error while loading. Please reload this page.
Implement Copy/Clone for closures - #44551
Conversation
rust-highfive
commented
Sep 13, 2017
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
aidanhs
commented
Sep 13, 2017
There was a problem hiding this comment.
Don't you need to check the feature-gate status of the crate that defined the closure, to avoid ICEs?
Crate A:
#![feature(clone_closures)]pubtraitGeneric{fnfoo<T:Clone>(self,t:T);}pubfnexample<G:Generic>(g:G){
g.foo(|| {});}Crate B:
// no feature flags!externcrate a;structS;implGenericforS{fnfoo<T:Clone>(self,t:T){let _ = t.clone();}}fnmain(){// trans will monomorphize this, and will try to evaluate `[closure]: Clone`, which// will fail and cause an ICE.
foo::example(S);}Another option would be to make all closures Copy & Clone in trans, but that would be visible through specialization etc. so I'm not sure it's the better idea.
There was a problem hiding this comment.
@arielb1 Yes you're right. I'm working on it.
There was a problem hiding this comment.
Is there a reason for this assertion? This method works just as well for structs and univariant enums.
There was a problem hiding this comment.
Indeed, but it won't work for arrays. I guess the match can be extended in the future if needed.
bors
commented
Sep 17, 2017
☔ The latest upstream changes (presumably #44634) made this pull request unmergeable. Please resolve the merge conflicts. |
52f677c to
75c4487Compared5c2a99 to
3fa3fe0Comparearielb1
commented
Sep 20, 2017
@bors r+ |
bors
commented
Sep 20, 2017
📌 Commit 3fa3fe0 has been approved by |
Implement `Copy`/`Clone` for closures Implement RFC [#2132](rust-lang/rfcs#2132) (tracking issue: #44490). NB: I'm not totally sure about the whole feature gates thing, that's my first PR of this kind...
bors
commented
Sep 21, 2017
bors
commented
Sep 21, 2017
☀️ Test successful - status-appveyor, status-travis |
Implement RFC #2132 (tracking issue: #44490).
NB: I'm not totally sure about the whole feature gates thing, that's my first PR of this kind...