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

RefCell: document panics in Clone, PartialEq, PartialOrd, Ord. #48365

Merged
merged 2 commits into from
Feb 28, 2018

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Feb 20, 2018

This fixes #47400 by adding:

    /// # Panics
    ///
    /// Panics if the value is currently mutably borrowed.

to said impls. They may panic since they call .borrow().

@Centril Centril added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 20, 2018
@rust-highfive
Copy link
Collaborator

r? @alexcrichton

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 20, 2018
@Centril
Copy link
Contributor Author

Centril commented Feb 22, 2018

r? @steveklabnik

Re-assigning to a T-doc member =)

@pietroalbini
Copy link
Member

@steveklabnik ping from the release team!

@@ -880,6 +883,9 @@ impl<T:Default> Default for RefCell<T> {

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized + PartialEq> PartialEq for RefCell<T> {
/// # Panics
///
/// Panics if the value is currently mutably borrowed.
Copy link
Member

Choose a reason for hiding this comment

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

For the functions that take an other like this one, what do you think about using this wording:

Panics if the value in either RefCell is currently borrowed.

This wording is taken from RefCell::swap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds like a great improvement 👍

Copy link
Member

@steveklabnik steveklabnik left a comment

Choose a reason for hiding this comment

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

r=me after changing to @frewsxcv 's wording; consistency is important and i think it's slightly clearer. Thanks so much for this PR!

@Centril
Copy link
Contributor Author

Centril commented Feb 27, 2018

@steveklabnik: Will do in a jiffy =)

@Centril
Copy link
Contributor Author

Centril commented Feb 27, 2018

And fixed.

r=@steveklabnik

@frewsxcv
Copy link
Member

@bors r+ rollup

thanks!

@bors
Copy link
Contributor

bors commented Feb 27, 2018

📌 Commit f8ebb3f has been approved by frewsxcv

@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 Feb 27, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Feb 28, 2018
…s, r=frewsxcv

RefCell: document panics in Clone, PartialEq, PartialOrd, Ord.

This fixes rust-lang#47400 by adding:

```rust
    /// # Panics
    ///
    /// Panics if the value is currently mutably borrowed.
```
to said impls. They may panic since they call `.borrow()`.
bors added a commit that referenced this pull request Feb 28, 2018
Rollup of 15 pull requests

- Successful merges: #48266, #48321, #48365, #48381, #48450, #48473, #48479, #48484, #48488, #48497, #48541, #48548, #48558, #48560, #48565
- Failed merges:
@bors bors merged commit f8ebb3f into rust-lang:master Feb 28, 2018
@Centril Centril deleted the docs/document-refcell-panics branch February 28, 2018 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

libstd/rustdoc: Document potential panics in RefCell where .borrow() is used implicitly in impls
7 participants