Open
Description
I tried this code:
enum List<S> {
Cons(S, Box<List<S>>),
One(List<S>),
None,
}
fn main() {
let c: List<i32>;
}
I expected to see this happen: just error messages about infinite sized List
Instead, this happened: errored out as
error[E0072]: recursive type `List` has infinite size
--> /data/data/com.termux/files/home/test.rs:1:1
|
1 | enum List<S> {
| ^^^^^^^^^^^^ recursive type has infinite size
2 | Cons(S, Box<List<S>>),
3 | One(List<S>),
| ------- recursive without indirection
|
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `List` representable
|
3 | One(Box<List<S>>),
| ++++ +
error[E0391]: cycle detected when computing drop-check constraints for `List`
--> /data/data/com.termux/files/home/test.rs:1:1
|
1 | enum List<S> {
| ^^^^^^^^^^^^
|
= note: ...which immediately requires computing drop-check constraints for `List` again
= note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing, constness: NotConst }, value: List<i32> } }`
error: aborting due to 2 previous errors
Meta
rustc --version --verbose
:
rustc 1.61.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: armv7-linux-androideabi
release: 1.61.0
LLVM version: 14.0.3
Backtrace
<no backtrace>