-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustdoc: allow list syntax for #[doc(alias)] attributes #82846
Conversation
Nice! I didn't really think about syntax when creating #81205, I agree that this syntax looks better :) |
68c43c7
to
4673bdd
Compare
Updated! |
@rfcbot fcp merge This allows writing #[doc(alias = "y")]
#[doc(alias = "z")] This makes the code more convenient to write, and does not conflict with any other possible features. |
Team member @jyn514 has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
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.
The goal of this change seems good to me. However, I'm wondering how this new syntax would interact with what's proposed in #82000. That issue proposes this syntax:
#[doc(alias = "sprintf", lang = "C, C++, POSIX")]
but I wonder if a less ambiguous form might end up being:
#[doc(alias("sprintf", lang = "C, C++, POSIX"))]
Would something like that still be possible after this change? I think so, but I wanted to check.
Also, I noticed that @GuillaumeGomez proposed in #81205 that
Meaning accept both |
☔ The latest upstream changes (presumably #82911) made this pull request unmergeable. Please resolve the merge conflicts. |
Yes
I would prefer to accept only one. I'm okay with |
I was referring to |
It's not instead of. Both syntaxes are working. :) |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
9b5d5cf
to
6aa5007
Compare
This comment has been minimized.
This comment has been minimized.
6aa5007
to
acd7a20
Compare
This comment has been minimized.
This comment has been minimized.
acd7a20
to
133d035
Compare
Updated! Anything else to be done here? |
@GuillaumeGomez this is still waiting on FCP: #82846 (comment) |
I find this not so intuitive since it is using Can we have a suggestion when someone is trying At least they don't have to search the rust reference or online to find out how it works. Maybe we can have a clippy lint later on this to recommend using the multiple items style. Also, why not just soft deprecate the old one since we just have this lately? |
#[doc(alias = "\"")] //~ ERROR | ||
#[doc(alias = "\n")] //~ ERROR | ||
#[doc(alias = " | ||
")] //~^ ERROR | ||
#[doc(alias = "\t")] //~ ERROR | ||
#[doc(alias = " hello")] //~ ERROR | ||
#[doc(alias = "hello ")] //~ ERROR | ||
#[doc(alias = "")] //~ ERROR |
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.
#[doc(alias = "")] //~ ERROR | |
#[doc(alias = "")] //~ ERROR | |
#[doc(alias = ["foo", "bar"])] //~ SUGGESTION |
We should show users the correct way to have multiple aliases.
There is no attribute in the rust compiler using this syntax, so why would anyone use it? It'll return a compiler error because it's invalid syntax.
Again, it's assuming that people would use a syntax which doesn't exist anywhere else in the compiler.
Both syntaxes are correct and working, so why deprecating one of them? |
It exists but not in attributes, it exists as Is this the first compiler attribute does supports both single value and multiple values?
Because it seemed redundant, the |
It's completely out of scope here. |
Compiling playground v0.0.1 (/playground)
error: expected unsuffixed literal or identifier, found `[`
--> src/lib.rs:1:15
|
1 | #[doc(alias = ["foo"])]
| ^
error: aborting due to previous error
error: could not compile `playground` The current compilation error does not seemed to be useful to let them know |
And once again: why would an attribute take an array whereas no other attributes is doing so? |
I don't mean to need it to take an array. What I am suggesting is that we show a better error just in case someone did that. Just error handling, still not valid code. |
I think the compiler error is clear enough: this is a syntax error, not an attribute one. |
Right - this would need to be changed in the parser, not here, rustdoc has no control over it. @pickfire feel free to open an issue for that but it doesn't belong in this pr. |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
@bors r+ |
📌 Commit 1d26e6b has been approved by |
…n514 rustdoc: allow list syntax for #[doc(alias)] attributes Fixes rust-lang#81205. It now allows to have: ```rust #[doc(alias = "x")] // and: #[doc(alias("y", "z"))] ``` cc `@jplatte` r? `@jyn514`
Rollup of 11 pull requests Successful merges: - rust-lang#82500 (Reuse `std::sys::unsupported::pipe` on `hermit`) - rust-lang#82759 (Remove unwrap_none/expect_none from compiler/.) - rust-lang#82846 (rustdoc: allow list syntax for #[doc(alias)] attributes) - rust-lang#82892 (Clarify docs for Read::read's return value) - rust-lang#83179 (Extend `proc_macro_back_compat` lint to `actix-web`) - rust-lang#83197 (Move some test-only code to test files) - rust-lang#83208 (Fix gitattibutes for old git versions) - rust-lang#83215 (Deprecate std::os::haiku::raw, which accidentally wasn't deprecated) - rust-lang#83230 (Remove unnecessary `forward_inner_docs` hack) - rust-lang#83236 (Upgrade memmap to memmap2) - rust-lang#83270 (Fix typo/inaccuracy in the documentation of Iterator::skip_while) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #81205.
It now allows to have:
cc @jplatte
r? @jyn514