"error: illegal recursive type; insert an enum or struct in the cycle, if this is desired" not very helpful #17539
Labels
Comments
Since the size of a fn does not depend on its output type, I doubt this is a necessary restriction in the type system. |
Triage: The error message seems better, but perhaps is still not ideal. Compiling this code: type SomeFn = fn() -> SomeFn;
fn main() {} on a recent nightly (
The "processing" language sounds a bit strange to me. Could it maybe say something like "the definition of the type |
Triage: same as @nham reported. I agree that we could improve on 'processing'. |
Current output is same as above, with new style output:
|
|
I have an idea on how to improve this error. @rustbot claim |
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Aug 27, 2021
… r=<try> Improve errors for recursive type aliases Fixes rust-lang#17539.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've tried to write code that would work like this:
To make coding some_fn and its friends easier, I wanted to create a type:
Unfortunately, this results in some type-theoretic error message that isn't really understandable by mere mortals:
It's not at all clear what 'the cycle' is and where to insert an enum or struct. Turns out that if you know what the compiler is talking about, the fix is simple:
Output:
But I was very confused by the message and tried a contraption like this instead:
A hint in the error message that points the programmer to the right direction would be very helpful. Ergonomy of the solution is also questionable, but at least it compiles.
The text was updated successfully, but these errors were encountered: