-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Hover on constants should render the display/debug impl if available #15188
Comments
cc @HKalbasi maybe you already had this idea in your head yourself :^) Would be good to know if we can pursue this in the (near) future or not as I think this would be very useful |
I think it is very doable now. We just need to run this: ::core::fmt::format(::core::fmt::Arguments::new_v1(
&[""],
&[::core::fmt::ArgumentV1::new(&(THE_CONST), ::core::fmt::Debug::fmt)],
)); And show its result. The only challanges are:
We also need something similar for displaying panic messages I think. I can do this, but this looks like a good opportunity for increasing the "bus factor" of mir, maybe? |
I'm fine with trying to tackle this myself (once I have time, I'm currently somewhat occupied with things). We should fallback to our current approach no matter what if we have problems running the debug/display implementation. |
I don't think I'll have the capacity to put the work into figuring out our MIR stuff like this in the coming time. So feel free to implement this yourself if you want, I'd look into the PR to catch up on how it was done then (which should teach me more in a shorter time I think) |
Use debug impl in rendering const eval result fix #15188
Might be a crazy idea but I'll take the bitflags crate as an example here (although we fail to calculate the layout for it in const eval due to the projection used I believe, pasting the expansion and fixing that up makes it work):
Hovering
FOO
renders (again<layout-error>
currently) the following:which is obviously not that useful, meanwhile the debug implementation would render as:
Noticed this in a project of mine that works with bitflags where our hover is practically useless
The text was updated successfully, but these errors were encountered: