Skip to content
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: Get repr information through AdtDef for foreign items #110983

Merged
merged 5 commits into from
Apr 30, 2023

Conversation

GuillaumeGomez
Copy link
Member

As suggested by @notriddle, this approach works too. The only downside is that the display of the original attribute isn't kept, but I think it's an acceptable downside.

r? @notriddle

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 29, 2023
@notriddle
Copy link
Contributor

Doesn’t this still leave the attribute missing in the JSON output?

@GuillaumeGomez
Copy link
Member Author

Oh very good point! I'll do it for JSON as well and add a test.

@notriddle
Copy link
Contributor

If I were you, I'd redesign it so that it injects the extra attribute when cleaning, instead of implementing it a second time for JSON output.

@GuillaumeGomez
Copy link
Member Author

GuillaumeGomez commented Apr 29, 2023

I thought about it and I'm a bit reluctant to this approach because we moved things out of memory to instead compute them on demand and storing this one here seemed going on the opposite way. Also, it would force to have a special representation here since attributes are the rustc ones, not rustdoc cleaned elements. Because of all this, I decided to not move it into a struct. Do you prefer to still move it into a type though?

EDIT: I can create a attributes method which would get this information on clean::Item directly though.

@notriddle
Copy link
Contributor

@GuillaumeGomez That solution sounds fine. I just want to make sure computing attributes is done in a shared place used by both HTML and JSON. A method that concatenates stored attributes together with computed ones does that.

@rustbot rustbot added the A-rustdoc-json Area: Rustdoc JSON backend label Apr 29, 2023
@rustbot
Copy link
Collaborator

rustbot commented Apr 29, 2023

Some changes occurred in src/librustdoc/clean/types.rs

cc @camelid

@GuillaumeGomez
Copy link
Member Author

Great! I did exactly that. Only issue: I actually can't test it because foreign items can't be inlined in JSON apparently... But at least they're now calling the same method.

@notriddle
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 29, 2023

📌 Commit b778688 has been approved by notriddle

It is now in the queue for this repository.

@bors 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 Apr 29, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 30, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#110586 (Fix Unreadable non-UTF-8 output on localized MSVC)
 - rust-lang#110652 (Add test for warning-free builds of `core` under `no_global_oom_handling`)
 - rust-lang#110973 (improve error notes for packed struct reference diagnostic)
 - rust-lang#110981 (Move most rustdoc-ui tests into subdirectories)
 - rust-lang#110983 (rustdoc: Get `repr` information through `AdtDef` for foreign items)
 - rust-lang#110984 (Do not resolve anonymous lifetimes in consts to be static.)
 - rust-lang#110997 (Improve internal field comments on `slice::Iter(Mut)`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 549b3a1 into rust-lang:master Apr 30, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 30, 2023
@GuillaumeGomez GuillaumeGomez deleted the foreign-repr branch April 30, 2023 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants