-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Minor librustdoc cleanup and refactoring. #36903
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
I need a sanity check for 19f6130 Here's the new print function it will use: rust/src/librustc/hir/print.rs Lines 273 to 275 in df9fa1a
rust/src/librustc/hir/print.rs Lines 1615 to 1636 in df9fa1a
|
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.
r=me modulo comments.
CLikeVariant | ||
} else { | ||
TupleVariant(struct_def.fields().iter().map(|x| x.ty.clean(cx)).collect()) | ||
impl VariantKind { |
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.
Could you make this an implementation of Clean<VariantKind>
for hir::VariantData
?
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.
d6fb0c8d6a01beab132f1df7832794401ac92a46
@@ -2682,11 +2668,12 @@ fn name_from_pat(p: &hir::Pat) -> String { | |||
match p.node { | |||
PatKind::Wild => "_".to_string(), | |||
PatKind::Binding(_, ref p, _) => p.node.to_string(), | |||
PatKind::TupleStruct(ref p, ..) | PatKind::Path(None, ref p) => path_to_string(p), | |||
PatKind::TupleStruct(ref p, ..) | PatKind::Path(None, ref p) => p.to_string(), |
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.
hir::print::State::print_path
begins with self.maybe_print_comment(path.span.lo)
, which might actually print a comment in this case:
fn f(arg1: (), // Some comment
path::to::TupleStruct(x): path::to::TupleStruct) {
//^ The `name_from_pat` of this tuple struct pattern might include "// Some comment"
}
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.
Do you think I should add an parameter to that function to control whether the comment gets printed or just ditch that commit?
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'd probably ditch the commit to be on the safe side since I don't understand the pretty printer, especially in edge cases (e.g. it might emit newlines and indents in long patterns).
VariantKind::CLike | ||
} else { | ||
VariantKind::Tuple( | ||
self.fields().iter().map(|x| x.ty.clean(cx)).collect()) |
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.
nit: this can fit on one line
(ret, ImportList(resolve_use_source(cx, p.clean(cx), self.id), | ||
remaining)) | ||
(ret, Import::List(resolve_use_source(cx, p.clean(cx), self.id), | ||
remaining)) |
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.
nit: this can fit on one line
use clean::{Variant, VariantKind}; | ||
if let clean::VariantItem( | ||
Variant { kind: VariantKind::Struct(ref s) } ) = variant.inner | ||
{ |
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.
nit: this would be easier for me to read:
if let clean::VariantItem(Variant { kind: VariantKind::Struct(ref s) }) =
variant.inner
{
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.
or
if let clean::VariantItem(Variant {
kind: VariantKind::Struct(ref s)
}) = variant.inner {
Latest force push removes 19f6130 and makes the suggested style changes. |
Thanks! @bors r+ |
📌 Commit 35d214a has been approved by |
Minor librustdoc cleanup and refactoring.
No description provided.