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

Consider mangling ID's in rustdoc-json #91609

Open
aDotInTheVoid opened this issue Dec 6, 2021 · 5 comments
Open

Consider mangling ID's in rustdoc-json #91609

aDotInTheVoid opened this issue Dec 6, 2021 · 5 comments
Labels
A-rustdoc-json Area: Rustdoc JSON backend C-discussion Category: Discussion or questions that doesn't represent real issues. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@aDotInTheVoid
Copy link
Member

Currently JSON ID's are (approximatly) the underling DefId's which means they are not realy opaque, despite what we've said in the RFC.

They happen to be the compiler internal DefId for that item, but in the JSON blob they should be treated as opaque as they aren't guaranteed to be stable across compiler invocations

The problem with this is that their is no obligation to treet the ID's as opaque (for a concreet example see scrabsha/scrabsha.github.io#2). If we want to garentee our ability to change the ID format, we should make it so that no one relies on the specific values of ID's by making them not cary information. Eg 0:0 lets the user know things, wheras a3aefbcbf31fa0bc12b9a73bc9d67976 (md5 hash) doesnt.

Potential Drawbacks

  • Non determinism
  • Harder to debug
  • Slower to build
  • Larger output

Which of these are actualy a problem, or just unfounded concerns I'm not sure:

If you want to change this: heres the places to look:

root: types::Id(String::from("0:0")),

ItemId::DefId(did) => Id(format!("{}", DisplayDefId(did))),

I'm not sure if this is a good idea, and would love feedback

@rustbot modify labels: +C-discussion +A-rustdoc-json

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend C-discussion Category: Discussion or questions that doesn't represent real issues. labels Dec 6, 2021
@camelid camelid added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Dec 13, 2021
@camelid
Copy link
Member

camelid commented Dec 13, 2021

MD5 hashes should be deterministic, so non-determinism would only be introduced if we used a random number generator.

@CraftSpider
Copy link
Contributor

I think MD5 hashes would be okay, though I would also support simply encoding the output in a less 'human readable' way. I'm okay with information being conveyed, if it's more obvious that the user isn't meant to access/rely on that information (think base64 or such)

@camelid camelid changed the title Consider mangaling ID's in rustdoc-json Consider mangling ID's in rustdoc-json Jan 12, 2022
@aDotInTheVoid
Copy link
Member Author

@aDotInTheVoid
Copy link
Member Author

CC @zjp-CN. If there's information that's only availible by parsing the (supposed-to-be) opaque identifiers, I'd love to hear that. Otherwise just be aware that you're relying on an implementation detail, and it's liable to break without notice.

@zjp-CN
Copy link

zjp-CN commented May 15, 2024

Hi, I did try to parse an id to learn about what it means in the testing, but haven't depended on it much in the app.

There is missing information on parsing type: rustdoc_types::Impl doesn't tell if it's an auto impl, whereas an id starting with a can just tell it is.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 16, 2024
…Gomez

rustdoc-json-types: Document `Id`

Inspired by finding [someone looking into the internals of an id](rust-lang#91609 (comment)), I realized we only document the fact that these are opaque on [the rfc](https://rust-lang.github.io/rfcs/2963-rustdoc-json.html#id).

r? `@GuillaumeGomez`
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 16, 2024
Rollup merge of rust-lang#125130 - aDotInTheVoid:id-docs, r=GuillaumeGomez

rustdoc-json-types: Document `Id`

Inspired by finding [someone looking into the internals of an id](rust-lang#91609 (comment)), I realized we only document the fact that these are opaque on [the rfc](https://rust-lang.github.io/rfcs/2963-rustdoc-json.html#id).

r? `@GuillaumeGomez`
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 C-discussion Category: Discussion or questions that doesn't represent real issues. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants