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 RFC 1789: Conversions from &mut T to &Cell<T> #43038

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

Tracking issue for RFC 1789: Conversions from &mut T to &Cell<T> #43038

aturon opened this issue Jul 3, 2017 · 19 comments
Labels
B-RFC-implemented Blocker: Approved by a merged RFC and implemented. 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. 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

@aturon
Copy link
Member

aturon commented Jul 3, 2017

This is a tracking issue for the RFC "Conversions from &mut T to &Cell<T>" (rust-lang/rfcs#1789).

Steps:

@aturon aturon 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 3, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Jul 27, 2017
bors added a commit that referenced this issue Jul 23, 2018
Implement rfc 1789: Conversions from `&mut T` to `&Cell<T>`

I'm surprised that RFC 1789 has not been implemented for several months. Tracking issue: #43038

Please note: when I was writing tests for `&Cell<[i32]>`, I found it is not easy to get the length of the contained slice. So I designed a `get_with` method which might be useful for similar cases. This method is not designed in the RFC, and it certainly needs to be reviewed by core team. I think it has some connections with `Cell::update` #50186 , which is also in design phase.
@Mark-Simulacrum Mark-Simulacrum added B-RFC-implemented Blocker: Approved by a merged RFC and implemented. and removed B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. labels Jul 25, 2018
@bstrie
Copy link
Contributor

bstrie commented Nov 13, 2018

This appears to have been implemented and is sitting behind the as_ref feature flag. Would anyone like to make any motions toward stabilization, or did the long discussion in the implementation PR cast doubts on the design?

@SimonSapin
Copy link
Contributor

Let’s.

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Apr 7, 2019

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

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), 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.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Apr 7, 2019
@dtolnay
Copy link
Member

dtolnay commented Apr 7, 2019

As I understand it, the new API here currently consists of:

impl<T: ?Sized> Cell<T> {
    pub fn from_mut(t: &mut T) -> &Cell<T>;
}

impl<T> Cell<[T]> {
    pub fn as_slice_of_cells(&self) -> &[Cell<T>];
}

@czipperz
Copy link
Contributor

Ping @BurntSushi @aturon @withoutboats do any of you have any concerns with merging this?

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels May 28, 2019
@rfcbot
Copy link

rfcbot commented May 28, 2019

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

@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 Jun 7, 2019
@rfcbot
Copy link

rfcbot commented Jun 7, 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.

@SimonSapin
Copy link
Contributor

Stabilization PR: #61620

bors added a commit that referenced this issue Jun 8, 2019
Stabilize Cell::from_mut and as_slice_of_cells

FCP: #43038 (comment)
@SimonSapin
Copy link
Contributor

Stabilized in #61620.

@czipperz
Copy link
Contributor

Does someone want to edit the description to check the stabilization checkbox?

@SimonSapin
Copy link
Contributor

SimonSapin commented Jul 18, 2019

Sure, though IMO the issue being closed already reflects that everything in it is either done or obsolete.

@jethrogb
Copy link
Contributor

Why doesn't this return &mut Cell<T>?

@SimonSapin
Copy link
Contributor

Is there a case where this would be useful? I feel that having multiple references to the thing is the point of this API.

@jethrogb
Copy link
Contributor

You can trivially convert a &mut Cell<T> to a &Cell<T> and then hand out multiple references. Also, it's too late now because 1.37 has been released.

@czipperz
Copy link
Contributor

Is there a way to go from &mut Cell<T> to &mut T?

@jethrogb
Copy link
Contributor

@czipperz
Copy link
Contributor

So that's the reason why this should return &mut Cell<T> imo.

@SimonSapin
Copy link
Contributor

This discussion is somewhat academic since Cell::from_mut is now stable on the stable channel, but:

  • If you’re gonna convert to &Cell<T> anyway, why would it be useful (rather than merely not an obstacle) for Cell::from_mut to return &mut Cell<T>?
  • If you’re gonna call Cell::get_mut on the result, why is it useful to go through Cell::from_mut in the first place? &mut T is what you started from.

@czipperz
Copy link
Contributor

I see what you mean. This is a tool for allowing temporary usage through a &Cell<T> for single thread scoped shared state. But the long term storage solution should be &mut T. I guess this api limits people to not store &mut Cell<T> that points to &mut T. But I don't know how useful that is in reality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-RFC-implemented Blocker: Approved by a merged RFC and implemented. 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. 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

8 participants