-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 legacy_const_generic doc arguments display #89954
Fix legacy_const_generic doc arguments display #89954
Conversation
r? @ollie27 (rust-highfive has picked a reviewer for you, use r? to override) |
r? @jyn514 |
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 really have time to review this properly ... @Amanieu @Mark-Simulacrum does this look like about the transformation you expect?
3817192
to
059596c
Compare
Updated. |
This comment has been minimized.
This comment has been minimized.
059596c
to
629ec2a
Compare
I think some indication that the arguments must be const should be given -- there's no canonical Rust syntax for this yet, though. |
@Mark-Simulacrum So what should be changed here exactly? If the syntax isn't present yet, I'm not sure what I can do but if you have suggestions, please go ahead. :) |
There's some discussion starting at #83167 (comment) of options for rendering. Can you provide a screenshot of what one of these functions looks like before/after this PR? That might help with discussion since currently reading the code seems necessary. |
629ec2a
to
08acb98
Compare
Yeah, ok, that matches what I thought. I would suggest adding I think that would move us in the right direction, but I'm not sure it's enough, particularly for call-sites which are using the regular const-generic syntax (i.e., with turbofish), which will look like they're omitting valid options. One benefit to us might be that I think all such "weird" functions are currently only leaf functions (i.e., not trait methods, etc) so we may be able to just duplicate the signature twice with an "or" in between or something like that, though it's probably painful to do in rustdoc's current design from what I recall. Overall, I think it's important to show users both styles if neither style issues deprecation warnings (which I believe is currently the case), and important to signal the need for the argument to be const. It may be worth nominating for libs-api to discuss whether there is a preferred syntax for calling these functions, and whether we wish to deprecate one of the forms; that would alleviate the concern over users encountering both syntaxes in the wild -- at least over time. |
Let's ping them then. cc @rust-lang/libs-api |
I personally think that just having: pub fn foo(x: usize, const Y: usize, z: usize); is enough since that is the form used by the vendor APIs. I don't think we need to expose the desugared generic form of the function in the documentation. |
I largely agree, with a possible caveat of a single paragraph at the root (core::arch module docs) explaining this, if it doesn't exist yet. I think it would definitely be an improvement on the status quo. |
08acb98
to
5c75a48
Compare
LGTM |
@bors: r=Amanieu |
📌 Commit 5c75a48 has been approved by |
…-doc, r=Amanieu Fix legacy_const_generic doc arguments display Fixes rust-lang#83167. cc `@Amanieu`
…askrgr Rollup of 12 pull requests Successful merges: - rust-lang#89954 (Fix legacy_const_generic doc arguments display) - rust-lang#91321 (Handle placeholder regions in NLL type outlive constraints) - rust-lang#91329 (Fix incorrect usage of `EvaluatedToOk` when evaluating `TypeOutlives`) - rust-lang#91364 (Improve error message for incorrect field accesses through raw pointers) - rust-lang#91387 (Clarify and tidy up explanation of E0038) - rust-lang#91410 (Move `#![feature(const_precise_live_drops)]` checks earlier in the pipeline) - rust-lang#91435 (Improve diagnostic for missing half of binary operator in `if` condition) - rust-lang#91444 (disable tests in Miri that take too long) - rust-lang#91457 (Add additional test from rust issue number 91068) - rust-lang#91460 (Document how `last_os_error` should be used) - rust-lang#91464 (Document file path case sensitivity) - rust-lang#91466 (Improve the comments in `Symbol::interner`.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #83167.
cc @Amanieu