Conversation
So that each unique filename only occurs once in the JSON output. This reduces the JSON file size by about 9%.
|
rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing |
|
This does make the output very slightly harder to work with, because filenames require a lookup instead of being directly available. But it's kind of a no-brainer in terms of file size, and for that reason is mentioned in the 2023 roadmap (#106697). It also slightly reduces peak memory usage. There is currently a couple of tests failing. They need #142479. I also have an implementation of |
|
Marking as blocked on #142479 |
obi1kenobi
left a comment
There was a problem hiding this comment.
Rustdoc JSON format changes LGTM. Thank you!
| /// Rustdoc makes no guarantees about the inner value of Id's. Applications | ||
| /// should treat them as opaque keys to lookup items, and avoid attempting | ||
| /// to parse them, or otherwise depend on any implementation details. |
There was a problem hiding this comment.
Is it worth keeping this portion of the comment?
On one hand, this comment used to be a lot more useful when the ID was of the form 2:1234 (more or less) where 2 was the crate ID and the rest could be (ab)used as a DefId inside that crate with better than 50-50 odds of working out. On the other hand, the ID values may change representation again in the future, and this is a solid future-proofing warning.
There was a problem hiding this comment.
Thanks for explaining how it used to be different, now I understand how the comment came to be. It used to make sense, but no more. The id is just an index into another part of the JSON. That's not an "opaque key" in any sense. And the idea of parsing an integer is silly.
As for future-proofing: sure, this could change, but so could literally anything else in the representation. So it doesn't need explicit mention.
So that each unique filename only occurs once in the JSON output. This reduces the JSON file size by about 9%.
r? @aDotInTheVoid