-
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
Unboxed closures #14539
Unboxed closures #14539
Conversation
let force_host_ptr = &mut force_host; | ||
let check_stdout_ptr = &mut check_stdout; | ||
let no_prefer_dynamic_ptr = &mut no_prefer_dynamic; | ||
let no_pretty_expanded_ptr = &mut no_pretty_expanded; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we still considering the syntax sugar from @thestinger's RFC to potentially make this less horrifying?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or perhaps I'm misunderstanding, is this only a temporary affair until |&mut: foo|
is implemented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not temporary, it's just how you need to capture by-reference and by-mutable-reference when there's not already a reference. This is the case the sugar would improve, but it doesn't appear to be very common.
This is getting pretty close. Needs a rebase and some tests. |
OK, this is ready for initial review. There are several known problems, but I figured as this patch is over 1KLOC already it's best to fix them in followups. Known issues:
This patch includes simple unit tests for direct calls, calls through a generic type parameter, and boxed calls. r? @nikomatsakis (or whoever) |
(drive by comment) Would it be easy to put this all behind a feature gate until the feature is ready for prime-time? |
This is now behind a gate. Also fixed the formatting issues. |
@@ -1 +1 @@ | |||
Subproject commit 0a894645cf120539876e9eb4eb0d7b572dfa9d14 | |||
Subproject commit 4b4d0533b4f76cc3fbba31bd9e7ac02e0c738b1d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Started reading this today. Looks pretty nice! Not finished yet. |
pub fn main() { | ||
let f = |&mut: x: int, y: int| -> int { x + y }; | ||
let z = call_it(3, f); | ||
println!("{}", z); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this to assert that z has the correct value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment seems like it was not addressed.
OK, left a few comments on things that need addressing. |
the leading quote part of the identifier for the purposes of hygiene. This adopts @jbclements' solution to rust-lang#14539. I'm not sure if this is a breaking change or not. Closes rust-lang#12512. [breaking-change]
the leading quote part of the identifier for the purposes of hygiene. This adopts @jbclements' solution to rust-lang#14539. I'm not sure if this is a breaking change or not. Closes rust-lang#12512. [breaking-change]
ping @pcwalton, what's the status of this? |
It's in my queue of P-backcompat-lang things to do. |
Current status: I have rebased the patch and addressed about half of @nikomatsakis' comments. However, this collided badly with the other unboxed closures work, necessitating some extra functionality. Specifically, I need to add tupling and untupling machinery in several places in trans in order to keep the tests passing, as they call the traits by name and implement them manually. I think that, semantically, @eddyb had the right idea all along: exposing the tupling/untupling is pretty messy, as is the @eddyb, you are perfectly within your rights to say "I told you so". :) |
Hmm. It's possible @eddyb's solution of having variadic generics seems preferable to a family of unnamable traits. That is, it'd be a generic and reusable mechanism. Certainly worth talking through in more detail. |
Getting closer here. One test failing. I had to rework most of the way unboxed closures work in the previous PRs. Still need to address one major issue in method resolution. |
Tests oughta' be passing now. |
This should be ready now; all of @nikomatsakis' comments addressed. r? @pnkfelix |
Tidy failures: https://travis-ci.org/rust-lang/rust/jobs/30130629 |
fixed tidy failures. |
#[rust_call_abi_hack] | ||
fn call_once(self, args: Args) -> Result; | ||
} | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you add these bits of code in comments? e.g. was it to make it easier to convert the test into something that uses #[no_std]
(so that you could feed it into a stage1 rustc
) ? I would still be inclined to remove them...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that, I forgot to remove it.
@pcwalton LGTM, though my knowledge of trans is still pretty weak. I will try to at least give it a whirl locally, but I suspect that if you address the minor comments above, then it will be good to go. |
re-r? @pnkfelix |
Comments addressed. |
Rebased. |
@nikomatsakis r?