-
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
Typechecking does not scale well for deeply nested types #21231
Comments
Did some investigating into the cause of this and since I do not think I have the knowledge to fix this I will simply share what I have found so far (this is all done on windows). I compiled rustc with debug information and profiled the execution of the program above which showed that the time was mostly spent inside the instantiate function in combine.rs. Furthermore by turning on logging for this crate led to me seeing a lot of lines like these:
And I just happens to be what I used to name the type parameter for the value above! Indeed if the function is simply specialized the program will compile within a reasonable amount of time. fn value(input: State<&str>) -> ParseResult<Value, &str> { Hopefully this will point someone more knowledgeable into the right direction. |
Probably related to #23069 |
👍 |
Factoring out parsers into their own functions significantly reduces compile time (see Marwes/parser-combinator/#21). This is due to issues in `rustc` (rust-lang/rust#21231).
Closing as this specific performance problem was fixed in #32062. |
Currently trying to write a parser combinator library and ideally I would like to have everything statically dispatched which means that the types created can become very deeply nested. There are ways around this of course but I would still not expect the compiler to hang for so long. Sadly I can't come up with a nice small example since simply creating a generic struct (struct A<X, Y>(X, Y);) and nesting it deeply does not seem to be affected.
56s 1138 characters long type
200s 1264 characters long type (should just be one more type nested)
Code compiled using https://github.com/Marwes/parser-combinators
The text was updated successfully, but these errors were encountered: