-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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>>),
}
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.