-
Notifications
You must be signed in to change notification settings - Fork 13.5k
rustdoc_json: conversion cleanups #142747
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
base: master
Are you sure you want to change the base?
rustdoc_json: conversion cleanups #142747
Conversation
We currently have both `FromClean<clean::Constant> for Constant` and `FromClean<clean::ConstantKind> for Constant` which are basically identical, but the former is unused.
It's just replicating exactly what is done by `<Vec<GenericParamDef> as FromClean>::into_json`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First 3 commits look good.
4th commit broadly makes sense. I especially like loosing all the .as_ref()
that was just noise, but needs to remove a few impls on tuples that are less clear than just having a function call for when there's not a 1:1 mapping from clean to json.
I think the last 2 commits make things worse and should be dropped. Item
and ItemEnum
are special as they're the "top level" of conversion, and there's special knowedge being shared about what things do and don't get converted. Also, with clean::Item
going to Option<Item>
it's not that sometimes a field is None
, in the output, but it won't be present at all, which is different to every use of FromClean
.
The `FromClean` trait is used a lot for converting to rustdoc-json format. But it's not used universally; there are still some ad hoc functions and methods for converting. This commit fixes this inconsistency by using `FromClean` more. The commit also introduces `FromClean` for `Box` and `Option`. This lets a lot of `as_ref` and `map` calls be removed in favour of simple `into_json` calls.
- `convert_static` -> `from_clean_static` - `from_function` -> `from_clean_function` To match the pre-existing `from_clean_item` and `FromClean::from_clean`. I left `JsonRenderer::convert_item` unchanged because it's a bit different.
06f558f
to
dc8c259
Compare
Thanks for the fast review. I have dropped the last two commits and removed the @rustbot ready |
@bors r+ rollup |
@bors r- |
Thinking some more: this makes sense for |
A bunch of clean-to-types conversion cleanups I found while working on perf-related stuff in rustdoc_json.
r? @aDotInTheVoid