-
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
Improve error message for infinitely recursive impl Trait type #47659
Comments
Just encountered this issue when refactoring large parser using Parsers inherently have many branches and are self-recursive. So after refactoring the codebase I encountered this error and had to guess which parser from 15 refactored functions has this issue. It wasn't very hard when I understood the issue, but the stack overflow error wasn't very informative of what happened at all. |
Would this be a good issue for a relative newcomer to tackle? As I understand it, its mostly about adding a more informative error message. |
@ZerothLaw I'm not sure-- it's hard to know exactly what to report. You know that an overflow has occurred, but not that it is necessarily due to recursive use of |
That's a good point. So before working on it, one should first figure out what the acceptable solution would be? |
@ZerothLaw Did you make any progress on this lately? I can maybe help give you more pointers, if needed. |
I haven't made any attempt on this. Any suggestions? |
@cramertj provides a good approach in his comment. To be specific, you might want to start by:
The rustc development guide is pretty handy if you're curious about how the compiler fits together, or what purpose a particular type or function serves, in many cases. Still, if you have any difficulties with the above, post back here, or hop onto the #compiler channel on Discord. Good luck! |
@ZerothLaw Had a chance to tackle the above yet, by chance? |
…ikomatsakis Forbid recursive impl trait There is no type T, such that `T = [T; 2]`, but impl Trait could sometimes be to circumvented this. This patch makes it a hard error for an opaque type to resolve to such a "type". Before this can be merged it needs - [x] A better error message - it's good enough for now. - [x] A crater run (?) to see if this any real-world code closes #47659
After #47529, attempts to compile code which builds an infinitely recursive
impl Trait
type will error with "overflow evaluating the requirementimpl Quux
". This isn't super user-friendly, and should be improved.The text was updated successfully, but these errors were encountered: