rustdoc-json: Add test for #[optimize(..)] by aDotInTheVoid · Pull Request #142916 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation14 Commits1 Checks10 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
These commits modify tests/rustdoc-json.
rustdoc-json is a public (but unstable) interface.
Please ensure that if you've changed the output:
- It's intentional.
- The
FORMAT_VERSIONinsrc/librustdoc-json-typesis bumped if necessary.
cc @aDotInTheVoid, @obi1kenobi
This comment has been minimized.
What makes the test for this attr specifically useful? Since a bunch of them are changing which don't necessarily have tests either?
Don't get me wrong, not against more tests, was just wondering about specifically this one
| @@ -0,0 +1,13 @@ |
|---|
| #![feature(optimize_attribute)] |
| //@ is "$.index[?(@.name=='speed')].attrs" '["#[attr = Optimize(Speed)]"]' |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the display of the inner value supposed to be like that? Shouldn't it be speed?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also
| //@ is "$.index[?(@.name=='just_inline')].attrs" '["#[attr = Inline(Hint)]"]' |
|---|
| #[inline] |
| pub fn just_inline() {} |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. How attributes are displayed is incoherent though, which isn't great. For example:
attrs/repr_align.rs:3://@ is "$.index[?(@.name=='Aligned')].attrs" '["#[repr(align(4))]"]'
attrs/export_name_2024.rs:7://@ is "$.index[?(@.name=='example')].attrs" '["#[export_name = \"altered\"]"]'
attrs/repr_c.rs:13://@ is "$.index[?(@.name=='ReprCUnion')].attrs" '["#[repr(C)]"]'
attrs/repr_packed.rs:6://@ is "$.index[?(@.name=='Packed')].attrs" '["#[repr(packed(1))]"]'
keyword_private.rs:8://@ is "$.index[?(@.name=='foo')].attrs" '["#[doc(keyword = \"match\")]"]'
Some of them are "code-like" and other represent the internal type representation in rustc, which is subject to change. Do we plan to uniform it at some point?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The code-like ones are either unstructured attributes, or have special handling in rustdoc.
#142936 moves to rustdoc-json not representing attributes as strings, but with a enum.
As part of #131229, all attributes are moving to being structured, but this is a gradual process.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went through #142936. Feel very relieved. Attributes are declared in rustdoc-json-types so they can't change unexpectedly. Very good idea!
| #[optimize(size)] |
|---|
| pub fn size() {} |
| //@ is "$.index[?(@.name=='none')].attrs" '["#[attr = Optimize(DoNotOptimize)]"]' |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Especially in this case.
📌 Commit bec2679 has been approved by GuillaumeGomez
It is now in the queue for this repository.
bors added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
bors added a commit that referenced this pull request
Rollup of 7 pull requests
Successful merges:
- #137268 (Allow comparisons between
CStr,CString, andCow<CStr>.) - #142704 (Remove the deprecated unstable
concat_idents!macro) - #142742 ([win][aarch64] Fix linking statics on Arm64EC, take 2)
- #142843 (Enable reproducible-build-2 for Windows MSVC)
- #142916 (rustdoc-json: Add test for
#[optimize(..)]) - #142919 (rustdoc-json: Add test for
#[cold]) - #142944 (Stats output tweaks)
Failed merges:
- #142825 (Port
#[track_caller]to the new attribute system)
r? @ghost
@rustbot modify labels: rollup
rust-timer added a commit that referenced this pull request
Rollup merge of #142916 - aDotInTheVoid:you-can-trip-on-my-optimizer, r=GuillaumeGomez
rustdoc-json: Add test for #[optimize(..)]
Follow up to #138291
CC @jdonszelmann
r? @GuillaumeGomez