-
Notifications
You must be signed in to change notification settings - Fork 23
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
Error post-processor #23
Comments
This sounds like something that could be built into the compiler (I'm thinking through an RFC) where if a type had a specific method defined it is used by the compiler in error messages? |
Yeah, that would be ideal. I was just trying to think of a way I could do it without editing the compiler. |
That is reasonable. On the other hand, writing code to parse rust error messages might be considerably more challenging and more fragile, than editing the compiler. I'm not sure if a compiler plugin could manage this, but if so that would be nice. Can you think of any other examples of a library that might have multiple representations of types, where users might prefer a particular representation? I guess typenum would be a good example that could also benefit from the same treatment, but it'd be lovely if there were another library (you didn't create) that could benefit from this sort of error-message simplification. btw, contrary to your example, I would recommend using a syntactically correct representation in the error message, which even though it might seem less "physical" than f64 m, could be easier for uses to make use of Meter to fix their code. |
I agree that this would be better, but I'm not sure how it would work. An option would be to display the type like |
@paholg have you seen @killercup's latest post? "A way to customize Rust error messages" |
@jonysy I had, but thanks for pointing it out! I was meaning to mention it here, but now I don't have to. :) |
An error-post processor has been written for typenum that could be leveraged here: https://github.com/auxoncorp/tnfilt |
Dimensioned has terrible error messages. For example,
produces the following message:
where I have added line breaks to increase legibility.
I would like it to look something like this:
I imagine this could be accomplished by having a post-processor that creates a short Rust program which just creates variables with those type signatures and then prints them, then replaces the text.
It might only end up working for units created in dimensioned, but that's a start. It might also get hard to parse with other types mixed in there. Perhaps there's a better way?
The text was updated successfully, but these errors were encountered: