You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating a struct that includes a self-referential type causes an internal compiler error. It clearly needs to be boxed, but hopefully there could be an error message instead. This appears to be similar to #742, the closed ticket for a similar issues with enums (nee tags).
crash.rs:3:0: 5:1 error: this type cannot be instantiated without an instance of itself; consider using `option<RecursiveType>`
crash.rs:3 struct RecursiveType {
crash.rs:4 self_reference: RecursiveType
crash.rs:5 }
Switching to option doesn't work, as it should be Option:
crash.rs:4:20: 4:41 error: found type name used as a variable
crash.rs:4 self_reference: option<RecursiveType>
^~~~~~~~~~~~~~~~~~~~~
Switching to Option triggers the error:
struct RecursiveType {
self_reference: Option<RecursiveType>
}
$ RUST_LOG=rustc=1,::rt::backtrace rustc crash.rs
rust: task 7fa823d01170 ran out of stack
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /private/tmp/rust-3z40/rust-0.5/src/librustc/rustc.rc:425
rust: domain main @0x7fa824800010 root task failed
rust: task failed at 'killed', /private/tmp/rust-3z40/rust-0.5/src/libcore/task/mod.rs:570
I've tested this in the released 0.5 and the current master branch version of 0.6.
The text was updated successfully, but these errors were encountered:
Creating a struct that includes a self-referential type causes an internal compiler error. It clearly needs to be boxed, but hopefully there could be an error message instead. This appears to be similar to #742, the closed ticket for a similar issues with enums (nee tags).
Starting with a naïve implementation such as:
You get:
Switching to option doesn't work, as it should be Option:
Switching to Option triggers the error:
I've tested this in the released 0.5 and the current master branch version of 0.6.
The text was updated successfully, but these errors were encountered: