-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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: Improve Item::attrs
to not use debug representation.
#137645
Comments
So there's basically two options here:
Doing option 2 would require a lot more design work, but is probably worthwhile (even if we do option 1 initially). Some questions:
|
One advantage of option 1 is that it also improves hir pretty printing. I personally think having them available in a nice and structured way is pretty neat, and hir is not required to look nice. Furthermore, it's also a lot of code (I initially tried). But it in an advantage at least |
Tools attrs are still accessible as tokens. If you try to hir pretty print they even still look like they used to. So that would fit in with option 1 I guess |
@obi1kenobi are there any other attrs except repr you would care about with semver checks? Although I dont think thats the only reason to expose things like this (I'd be in favor of exposing things like inline) it'd be interesting to know if that's literally the only one right now. |
I'm in favor of Option 1 initially, and Option 2 in the long run as a nice-to-have. We already have code that does attribute parsing, so while I'd love to eliminate it eventually, that isn't really a priority. Option 1 sounds like it can be done with less work, and speed is good :)
No, unfortunately we need many more. At minimum (probably not an exhaustive list):
If we can keep
If we can keep it, it'd be great! There are some cases where in the future a warning may be desirable as a lint if e.g. Not a priority today though.
I have no opinion on this, since none of
It's possible |
Thank you both for looking into this issue and helping address it! ❤ |
for the record, although I played devil's advocate a little and posted some arguments for option, I think option 2 gives a lot more flexibility and although I agree you already have parsing for option 1, with option 2 you potentially won't need any parsing at all nor any other tool which I think is very valuable |
I agree option 2 would be nice! But my top priority is having whichever option we can ship faster :) |
Currently, Item::attrs uses a debug-printing
https://github.com/rust-lang/rust/blame/85abb276361c424d64743c0965242dd0e7b866d1/src/rustdoc-json-types/lib.rs#L123-L126
This isn't particularly friendly to users, who need to deal with an internal (and undocumented 😱) attr representation.
This was changed in #135726, as part of the a larger attribute rework (#131229)
MCVE:
which produces (abridged):
CC @jdonszelmann @obi1kenobi
The text was updated successfully, but these errors were encountered: