-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add a little more infrastructure for building ConversionErrors #235
Conversation
if let Err(e) = self.debug_event(DebugEvent::new().msg("type conversion failed")) { | ||
return e; | ||
} | ||
if let Err(e) = self.debug_event(DebugEvent::new().msg(core::any::type_name::<T>()).arg(v)) |
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.
I think we can combine these two debug events.
Can we format a msg to include the typename? The typename should be known at compile time, and this fn is generic and bound to the type at compile time, so it should be possible to compose the type conversion into T failed
string at compile time.
(We'd need to use something like the const_format crate.)
If we can't do that for some reason, can we truncate and convert the T typename into a Symbol and include it as an arg?
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.
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.
This PR is to just check in Graydon's changes during today's meeting so that I can pick it up and continue on.
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.
Oh neat, I hadn't seen const_format. Maybe! I will also be fleshing out support for multiple static strings (host and guest) as args beyond the initial msg, so this is very much a stopgap, not the final version.
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.
Hmm, I couldn't figure out how to do it with one debug_event.
const_format
(e.g. concatcp! ) doesn't help here because the inputs must be const.
Is there any way to get the compile-time type names?
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.
Ah, so the core::any::typename
is a const fn
, but only in nightly behind the const_type_name
feature. Doh! rust-lang/rust#63084
Closing this as I've incorporated the changes into my follow-up work. |
A little promised code from meeting earlier today, sorry for delay @jayz22 !