Closed
Description
It seems a compiler bug to me. I tried this code:
type S = Option<Box<S>>;
I expected it could compile, but instead:
lihz:linkedlist lihzhang$ cargo build
Compiling linkedlist v0.1.0 (/Users/lihzhang/Documents/com.github/linkedlist)
error[E0391]: cycle detected when processing `S`
--> src/lib.rs:1:21
|
1 | type S = Option<Box<S>>;
| ^
|
= note: ...which again requires processing `S`, completing the cycle
note: cycle used when collecting item types in top-level module
--> src/lib.rs:1:1
|
1 | type S = Option<Box<S>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0391`.
error: Could not compile `linkedlist`.
To learn more, run the command again with --verbose.
However, the equivalent code as following compiles fine:
enum S {
T(Option<Box<S>>),
}