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

Tracking issue for RefCell::{replace, swap} #43570

Closed
2 of 3 tasks
alexcrichton opened this issue Jul 31, 2017 · 19 comments
Closed
2 of 3 tasks

Tracking issue for RefCell::{replace, swap} #43570

alexcrichton opened this issue Jul 31, 2017 · 19 comments
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. B-RFC-implemented Blocker: Approved by a merged RFC and implemented. B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@alexcrichton
Copy link
Member

alexcrichton commented Jul 31, 2017

Tracking issue for rust-lang/rfcs#2057

  • Implement the functionality
  • Add documentation
  • Stabilize!
@alexcrichton alexcrichton added B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jul 31, 2017
@notriddle
Copy link
Contributor

Can I implement this? (I understand you'll want to give it the C-assigned label, to make sure nobody else works on it)

@alexcrichton
Copy link
Member Author

Certainly!

@Mark-Simulacrum Mark-Simulacrum added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Aug 1, 2017
bors added a commit that referenced this issue Aug 14, 2017
Implement `RefCell::replace` and `RefCell::swap`

Tracking issue: #43570
@notriddle
Copy link
Contributor

notriddle commented Aug 15, 2017

  • Implemented the functionality
  • What documentation is needed beyond the API docs?
  • I assume that once 1.20 is released, we'll be able to talk about marking it stable.

@Havvy
Copy link
Contributor

Havvy commented Nov 7, 2017

The only docs needed for this is the API docs.

I've also written PR #45819 to add a replace_with variant.

@gbip
Copy link

gbip commented Dec 5, 2017

Is there any plan to make this stable ? I can't figure the syntax to move a value inside a RefCell to replace the old one.
Thanks !

kennytm added a commit to kennytm/rust that referenced this issue Dec 20, 2017
Stablize RefCell::{replace, swap}

RefCell::replace_with is not stablized in this PR, since it wasn't part of the RFC.

CC rust-lang#43570
@alexcrichton
Copy link
Member Author

Stabilized in #46517

@SimonSapin
Copy link
Contributor

replace_with was not stabilized together with replace and swap in #46517 because it wasn’t part of rust-lang/rfcs#2057.

Let’s stabilize it now, perhaps with the “corresponds to std::mem::replace” bit of doc removed per #45819 (comment)

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Mar 17, 2018

Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@SimonSapin SimonSapin reopened this Mar 17, 2018
@rfcbot rfcbot added the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Mar 17, 2018
@alexcrichton
Copy link
Member Author

@rfcbot concern footgun

I'd personally be somewhat concerned about the replace_with API in terms of the intended use case of RefCell. Used in the case where mutability doesn't cut it usage of RefCell often implies lots of aliasing all over the place which is often difficult to determine statically. As a result correct progress mostly minimize the amount of time a RefCell is borrowed or otherwise used for. I'd be worried that allowing an arbitrary closure in replace_with is hiding the fact that you're borrowing the RefCell for the duration of the entire closure. It may be clearer to force authors to explicitly take a borrow and map it to see where the borrow duration runs?

@alexcrichton
Copy link
Member Author

I'm also under the impression that this isn't a massively used method in the sense that the ergonomic win here isn't necessary critical, but I could be wrong!

@Havvy
Copy link
Contributor

Havvy commented Mar 19, 2018

I sent the PR for it because I wrote the function freely in my own code where I wanted to recurse through a path in a tree without passing a Vec of RefCell borrows but rather keep the borrow information in the stack.

Putting a warning that the RefCell is borrowed for the duration of the closure into the documentation would help.

@alexcrichton
Copy link
Member Author

@SimonSapin do you have thoughts on the concern I listed above?

I'm not personally a huge fan of a warning in the sense that I don't think it absolves us of the footgun of the API, but if there's a strong use case for adding it then the warning is likely enough. I do not currently see, however, the strong use case for adding this

@Centril Centril added the disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. label May 24, 2018
@Phlosioneer
Copy link
Contributor

This has been merged. Tracking issue can be closed.

@Havvy
Copy link
Contributor

Havvy commented Sep 23, 2018

RefCell::replace_with has not been stabilized yet.

@Phlosioneer
Copy link
Contributor

Ah. I thought that would be a different issue, because it's not in the title and not in the RFC. Sorry.

@alexcrichton
Copy link
Member Author

@rfcbot resolve footgun

I don't want to personally be on the hook for blocking this any more

@rfcbot
Copy link

rfcbot commented Feb 20, 2019

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Feb 20, 2019
@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Feb 20, 2019
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Mar 2, 2019
@rfcbot
Copy link

rfcbot commented Mar 2, 2019

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC will be merged soon.

@jonas-schievink jonas-schievink added B-unstable Blocker: Implemented in the nightly compiler and unstable. B-RFC-implemented Blocker: Approved by a merged RFC and implemented. labels Mar 24, 2019
@jonas-schievink
Copy link
Contributor

jonas-schievink commented Mar 24, 2019

Seems like this just needs a stabilization PR now?

@jonas-schievink jonas-schievink added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. labels Mar 24, 2019
Centril added a commit to Centril/rust that referenced this issue Mar 31, 2019
…swap, r=Centril

Stabilize refcell_replace_swap feature

Please be kind, this is my first time contributing. 😄

I noticed rust-lang#43570 only needs stabilizing (and I need it for a side project I'm working on), so I followed the [guide](https://rust-lang.github.io/rustc-guide/stabilization_guide.html#stabilization-pr) to move things forward.

I'm happy to amend things if needed, let me know!
@bors bors closed this as completed in 70fa616 Mar 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. B-RFC-implemented Blocker: Approved by a merged RFC and implemented. B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

10 participants