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

Stabilize the copy_closures and clone_closures features #49299

Merged
merged 3 commits into from
Mar 24, 2018

Conversation

SimonSapin
Copy link
Contributor

@SimonSapin SimonSapin commented Mar 23, 2018

In addition to the Fn* family of traits, closures now implement Copy (and similarly Clone) if all of the captures do.

Tracking issue: #44490

In addition to the `Fn*` family of traits, closures now implement `Copy` (and similarly `Clone`) if all of the captures do.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @withoutboats (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 23, 2018
Some(trait_id) == self.tcx().lang_items().clone_trait() &&
self.tcx().has_clone_closures(def_id.krate);
let copy_closures = Some(trait_id) == self.tcx().lang_items().copy_trait();
let clone_closures = Some(trait_id) == self.tcx().lang_items().clone_trait();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not confident about this particular chunk, but tests appear to be happy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems ok. The name of the variable is weird; I would prefer is_copy_trait and is_clone_trait or something.

@SimonSapin SimonSapin added T-lang Relevant to the language team, which will review and decide on the PR/issue. relnotes Marks issues that should be documented in the release notes of the next release. labels Mar 23, 2018
@@ -166,6 +166,11 @@ pub trait Unsize<T: ?Sized> {
/// are allowed to access `x` after the assignment. Under the hood, both a copy and a move
/// can result in bits being copied in memory, although this is sometimes optimized away.
///
/// ## Closures
///
/// Closure types automatically implement `Clone` if they capture no value from the environment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clone

is that a typo for Copy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, hasty copy-paste. Good catch, thanks. I just squashed a fix.

@nikomatsakis
Copy link
Contributor

r? @nikomatsakis

@SimonSapin SimonSapin mentioned this pull request Mar 23, 2018
2 tasks
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mind changing the names of those variables? otherwise r=me :)

@SimonSapin
Copy link
Contributor Author

Yes, this code is much less confusing with those variable names. Done, thanks.

@cramertj
Copy link
Member

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Mar 24, 2018

📌 Commit 1efe0b3 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 24, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Mar 24, 2018
Stabilize the copy_closures and clone_closures features

In addition to the `Fn*` family of traits, closures now implement `Copy` (and similarly `Clone`) if all of the captures do.

Tracking issue: rust-lang#44490
kennytm added a commit to kennytm/rust that referenced this pull request Mar 24, 2018
Stabilize the copy_closures and clone_closures features

In addition to the `Fn*` family of traits, closures now implement `Copy` (and similarly `Clone`) if all of the captures do.

Tracking issue: rust-lang#44490
bors added a commit that referenced this pull request Mar 24, 2018
@bors bors merged commit 1efe0b3 into rust-lang:master Mar 24, 2018
@SimonSapin SimonSapin deleted the ubiquity branch March 24, 2018 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants