-
Notifications
You must be signed in to change notification settings - Fork 13k
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-json: Dangling ID when private struct used in bound for pub-on-pub impl #113674
Comments
@HeroicKatora @obi1kenobi @LukeMathWalker what do you think is the right thing to do here? i expect removing the bound altogether will cause issues, and i do like that it's consistent with the HTML output, but in the other hand i don't think the HTML side was ever thought through too well and this makes it very hard to test for correctness. @aDotInTheVoid can you remind me the reason the "no broken links" rule was added to jsondoclint? the idea was that we were missing public items in the output? maybe we can add the equivalent of -Z ui-testing that adds a list of items that are private and therefore expected to have broken links? |
It's an interesting one. Another potential solution would be to include tombstone items—the link resolves to an "Omitted"-style item, which allows the code using the JSON to understand that it was not included due to the visibility used to generate docs, allowing it to return a useful error. To confirm: everything works as expected if we run with |
For semver-checking, for a variety of reasons we actually have to run with both private and hidden items included. One such reason: if adding a private field causes a semver break, we want our error message to point to the problematic field specifically by name and span. So our IDs rarely dangle — though they still sometimes do — and we've written our code to be robust to dangling IDs just in case. To a degree, users of rustdoc JSON have to be mindful of various flavors of non-resolvable (or not-easily-resolvable) links to other items, whether because of a dangling ID or because of cross-crate items which are also not included in the JSON file etc. So while I understand that this feels quite broken and offends our general sense of propriety and correctness, I personally don't consider it a particularly high-priority issue to fix or even decide on a firm design for fixing later. In an ideal world, we wouldn't pick an approach with "Omitted"-style items since it feels likely to add more complexity and edge cases that could be hard to foresee. I'd love to get a sense of how much larger JSON files would get if we tried recursively adding |
With the code:
fails to valididate in jsondoclint:
Because it produces (redacted)
This pattern comes up in practice eg:
rust/library/core/src/iter/adapters/flatten.rs
Lines 139 to 146 in a161ab0
where
TrustedLen
andFlatMap
are part ofcore
s public API, butFlattenCompat
isn't.HTML get's arround this by not linking to the item:
I have no idea what the right thing to do here is design-wise.
The text was updated successfully, but these errors were encountered: