Skip to content

Make Arc::make_unique check weak refs; add make_unique to Rc #14522

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

Closed
wants to merge 1 commit into from

Conversation

aturon
Copy link
Member

@aturon aturon commented May 29, 2014

This patch makes Arc::make_unique examine the number of weak
references as well as strong references, which is required for safety.

It also adds a make_unique method to the Rc type for consistency.

Closes #14521.

@alexcrichton
Copy link
Member

Could you also add tests for make_unique for Rc and the weak case on Arc?

This patch makes `Arc::make_unique` examine the number of weak
references as well as strong references, which is required for safety.

It also adds a `make_unique` method to the `Rc` type for consistency.

Closes rust-lang#14521.
@aturon
Copy link
Member Author

aturon commented May 29, 2014

@alexcrichton Added.

@aturon
Copy link
Member Author

aturon commented May 29, 2014

@alexcrichton The upgrade can only succeed if there is another strong reference, which would then fail to trigger the original bug.

@aturon
Copy link
Member Author

aturon commented May 29, 2014

@alexcrichton Note that, on the other hand, the old Arc would have allowed the current upgrade to go through.

@alexcrichton
Copy link
Member

Aha, indeed. Oh well.

bors added a commit that referenced this pull request May 30, 2014
…ichton,me

This patch makes `Arc::make_unique` examine the number of weak
references as well as strong references, which is required for safety.

It also adds a `make_unique` method to the `Rc` type for consistency.

Closes #14521.
@bors bors closed this May 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arc::make_unique ignores weak references
3 participants