-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Cosmetics: Don't print full module path in errors when the source file imports the Structs/Traits concerned by the error. #58088
Comments
What if you have multible structs |
@hellow554 Could you show an example. As far as I can tell when you import an Identifier with Maybe some consideration needs to be made for how imports happen within macros. That's not exactly clear to me. |
Duplicate of #21934. CC @pnkfelix as per our conversation in the all-hands, this is something tangential to other things you'll be tackling. I know that this won't happen in the short term, but would you be able to spare cycles to help mentor someone to do the work needed for this when you do start making the changes needed to enable this? |
@estebank Even though the issues seem related, I would specifically suggest shortening the names, regardless of private vs public paths. As an example, in the following image all paths are public, but that's not the point: This code Link from hackernews with more examples of unwieldy long error messages. |
I would even suggest to ban paths completely from types in error messages and to include the relevant use statements from the users code for disambiguation like: use tokio :: { net::{ TcpStream }, codec::{ Framed } };
use futures :: { stream::SplitSink };
let mb: Inbox<MyPeer> = Inbox::new();
error: the trait bound `SplitSink<Framed<TcpStream, [...]> is not satisfied` For clarity, I abbreviated the error message here with the elipsis [...] for simplicity. I don't suggest rustc to do this. Also, I can't show the underlining rustc does in github markdown... |
Ha, this does seem to be a duplicate of #50310 though. Only just found that one now, and it's still open. |
I'm sorry if I bring something up that has been thought of before, but I couldn't find any issue through search. Currently rustc will print errors like this:
Given that the source file in question has:
This error could look like this:
Now the example above is pretty trivial, but we all know how unwieldy and unreadable error messages can get, and I think any chance to shave off some text and make it brief and readable should be taken.
One could fear that it might be harder to figure out the exact constructs referred to, but given that errors are against code the dev wrote, and the dev uses these shortcuts through
use
I think that in practice this should be preferred in almost all cases. In the worst case the dev has to look at their own code to know what modules errors refer to.Unfortunately I can't promise that I could provide a pull request implementing this since I have never hacked on rustc and I have limited time available, but if the fundamental idea is appreciated and someone is willing to seriously mentor a complete beginner in rustc dev, I would be up for trying. I will have time to develop between mid febuari and mid april.
The text was updated successfully, but these errors were encountered: