Skip to content

Unbox more closures in the libraries #20363

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

Merged
merged 23 commits into from
Jan 1, 2015
Merged

Unbox more closures in the libraries #20363

merged 23 commits into from
Jan 1, 2015

Conversation

japaric
Copy link
Member

@japaric japaric commented Dec 31, 2014

The the last argument of the ItemDecorator::expand method has changed to Box<FnMut>. Syntax extensions will break.

[breaking-change]


This PR removes pretty much all the remaining uses of boxed closures from the libraries. There are still boxed closures under the test directory, but I think those should be removed or replaced with unboxed closures at the same time we remove boxed closures from the language.

In a few places I had to do some contortions (see the first commit for an example) to work around issue #19596. I have marked those workarounds with FIXMEs. In the future when &mut F where F: FnMut implements the FnMut trait, we should be able to remove those workarounds. I've take care to avoid placing the workaround functions in the public API.

Since let f = || {} always gets type checked as a boxed closure, I have explictly annotated those closures (with e.g. |&:| {}) to force the compiler to type check them as unboxed closures.

Instead of removing the type aliases (like GetCrateDataCb), I could have replaced them with newtypes. But this seemed like overcomplicating things for little to no gain.

I think we should be able to remove the boxed closures from the languge after this PR lands. (I'm being optimistic here)

r? @alexcrichton or @aturon
cc @nikomatsakis

@nikomatsakis
Copy link
Contributor

r+. Giving high priority as this is an urgent language change.

bors added a commit that referenced this pull request Jan 1, 2015
The the last argument of the `ItemDecorator::expand` method has changed to `Box<FnMut>`. Syntax extensions will break.

[breaking-change]

---

This PR removes pretty much all the remaining uses of boxed closures from the libraries. There are still boxed closures under the `test` directory, but I think those should be removed or replaced with unboxed closures at the same time we remove boxed closures from the language.

In a few places I had to do some contortions (see the first commit for an example) to work around issue #19596. I have marked those workarounds with FIXMEs. In the future when `&mut F where F: FnMut` implements the `FnMut` trait, we should be able to remove those workarounds. I've take care to avoid placing the workaround functions in the public API.

Since `let f = || {}` always gets type checked as a boxed closure, I have explictly annotated those closures (with e.g. `|&:| {}`) to force the compiler to type check them as unboxed closures.

Instead of removing the type aliases (like `GetCrateDataCb`), I could have replaced them with newtypes. But this seemed like overcomplicating things for little to no gain.

I think we should be able to remove the boxed closures from the languge after this PR lands. (I'm being optimistic here)

r? @alexcrichton or @aturon 
cc @nikomatsakis
@bors bors merged commit 10bbf69 into rust-lang:master Jan 1, 2015
@japaric japaric deleted the moar-uc branch January 4, 2015 13:06
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants