-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Fix display of const generics in rustdoc #60760
Conversation
Instead of |
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.
Heads-up: It's the first time I'm reviewing anything here, I'm not familiar with the rustdoc codebase.
See my inline comment regarding the fixme.
I do agree with varkor for the display.
src/librustdoc/clean/mod.rs
Outdated
expr: format!("{:?}", self.val), // FIXME(const_generics) | ||
expr: match self.val { | ||
ConstValue::Param(ty::ParamConst { name, .. }) => format!("const {}", name), | ||
e => format!("{:?}", e), // FIXME generic consts |
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 don't think it's entirely clear what's still to fix.
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.
In general, the constant could be an arbitrary expression, in which case we want to pretty-print it rather than debug format it. (This could be made more clear in the comment.)
Unsorted, | ||
} | ||
|
||
// @has foo/struct.VSet.html '//pre[@class="rust struct"]' 'pub struct VSet<T, const ORDER: Order>' |
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.
TIL: rustdoc tests
I'll update with @varkor's comments! |
c38c224
to
2caeaf5
Compare
Updated! |
Looks good, thanks! r=me unless @badboy has any additional comments. |
Thanks for both of your reviews! :) @bors: r=varkor,badboy |
📌 Commit 2caeaf5 has been approved by |
@varkor Why is the @GuillaumeGomez Also, I think it would be nice to do away with the unnecessary braces around the const arguments. |
Hmm, I'm not sure. But it doesn't seem related to this change.
Writing it without curly brackets doesn't currently work. |
@varkor Yeah but you could normalize in the rustdoc display itself. |
That would not represent the actual syntax. When the issue with parameter names is fixed, then this will no longer be a problem. |
Fix display of const generics in rustdoc <img width="745" alt="Screenshot 2019-05-18 at 15 45 22" src="https://user-images.githubusercontent.com/3050060/57970638-04854e80-7984-11e9-9f04-da6b51ec8bc7.png"> Part of #60737. cc @varkor r? @badboy
☀️ Test successful - checks-travis, status-appveyor |
Part of #60737.
cc @varkor
r? @badboy