Implement <Rc>::downcast by bluss · Pull Request #44273 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation15 Commits2 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

bluss

@rust-highfive

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@bluss

I'll probably revise this -- the pointer math in from_raw does not optimize out as it should

@kennytm

Arc is skipped because Any itself has no downcast for the case that makes most sense: Any + Send + Sync

Why we don't implement downcast for Any + Send + Sync? Other than it isn't terribly necessary.

@bluss

Implement downcast the like it exists for Box.

The implementation avoids using into_raw/from_raw, because the pointer arithmetic which should cancel does not seem to optimize out at the moment.

Since Rc is never Send, only Rc and not Rc<Any + Send> implements downcast.

@bluss bluss changed the titleImplement <Rc>::downcast and generalize Rc::into_raw Implement <Rc>::downcast

Sep 3, 2017

@bluss

I pushed a new version with a more direct implementation, because the pointer arithmetic of using into_raw/from_raw did not optimize out. (playground demo for that)

@bluss

@kennytm I'm not sure, there are only four combinations of Any and Send, Sync, so it's simple to cover them all, but a bit confusing in the API doc.

@sfackler sfackler added the T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

label

Sep 3, 2017

@sfackler

This seems reasonable to me.

@rfcbot fcp merge

@rfcbot

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

No concerns currently listed.

Once these reviewers reach consensus, 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

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

@alexcrichton

@bors

📌 Commit 758a0ce has been approved by alexcrichton

@alexcrichton alexcrichton 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-team

Status: Awaiting decision from the relevant subteam (see the T- label).

labels

Sep 14, 2017

@alexcrichton

@alexcrichton

@bors: r-

oh actually, @bluss mind filing a tracking issue for this and updating the PR with that number?

@bluss bluss mentioned this pull request

Sep 15, 2017

@bluss

@bluss

Sure, updated with tracking issue #44608

@alexcrichton

@bors

📌 Commit 3a39d95 has been approved by alexcrichton

alexcrichton added a commit to alexcrichton/rust that referenced this pull request

Sep 16, 2017

@alexcrichton

Implement <Rc>::downcast

frewsxcv added a commit to frewsxcv/rust that referenced this pull request

Sep 16, 2017

@frewsxcv

Implement <Rc>::downcast

alexcrichton added a commit to alexcrichton/rust that referenced this pull request

Sep 17, 2017

@alexcrichton

Implement <Rc>::downcast

bors added a commit that referenced this pull request

Sep 17, 2017

@bors

Rollup of 19 pull requests

@bluss bluss deleted the rc-downcast branch

March 17, 2018 16:04

Labels

final-comment-period

In the final comment period and will be merged soon unless new substantive objections are raised.

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.