-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
RWLock: Add deadlock example #82624
RWLock: Add deadlock example #82624
Conversation
r? @sfackler (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
78d28ca
to
c1526ab
Compare
This comment has been minimized.
This comment has been minimized.
c1526ab
to
3a72c32
Compare
This comment has been minimized.
This comment has been minimized.
3a72c32
to
0648a88
Compare
/// `read`. | ||
/// `read`, e.g.: | ||
/// | ||
/// ```text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced we spend a bunch of vertical space on a fairly obscure edge case, but I'd defer to @rust-lang/docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's up to you and libs; we don't have any real precedent here in either direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can get the best of both worlds: is there a way to collapse a subset of the docs by default? It would be useful for detailed examples, e.g. like we do in GitHub:
Time-threads diagram
// Thread 1 | // Thread 2
let _rg = lock.read(); |
| // will block
| let _wg = lock.write();
// may deadlock |
let _rg = lock.read(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is with the <details>
tag, which, given that markdown is a superset of HTML, should be usable. I don't think we currently use it at all, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it, and it works nicely, although it needs a small tweak: see #82805.
From what I can tell, at least we use <details>
in the unstable/yellow orange boxes.
Currently we use `<details>` and `<summary>` for the unstable info box, under class `.stab`. However, they can also be useful to add detailed documentation like lengthy detailed examples that would be too much to show by default, e.g.: /// <details><summary>Time-threads diagram</summary> /// /// ```text /// // Thread 1 | // Thread 2 /// let _rg = lock.read(); | /// | // will block /// | let _wg = lock.write(); /// // may deadlock | /// let _rg = lock.read(); | /// ``` /// </details> See rust-lang#82624 for an example where we could use this functionality. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Suggested in rust-lang#82596 but it was a bit too late. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
0648a88
to
98096a9
Compare
@sfackler this is ready for review |
I need to finish #82805 first, then we can merge this, sorry. |
@ojeda sure no worries. nevermind they are unrelated prs |
This PR requires #82805 to display properly the details HTML tag in the docs. |
ah thanks for confirming. marking it as blocked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@bors r+ |
📌 Commit 98096a9 has been approved by |
☀️ Test successful - checks-actions |
Suggested in #82596 but it was a bit too late.
@matklad @azdavis @sfackler