Skip to content

Using mod <name> in <name>.rs leads to "internal compiler error: unexpected failure" #4338

Closed
@mike-brown

Description

@mike-brown

The following code snippet:

// foo.rs
mod foo;
fn main() {}

will result in the compiler throwing:

error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug

with the top line of the backtrace that the error told me to run being:

rust: task b4d04940 ran out of stack

Removing the mod foo; statement fixes, and is seemingly because of the cyclic import that this causes. Is there a way that self-references using mod can be caught and handled nicely? With something like this sample it's easy to see the error and to debug, but I was chasing a typo in my mod statement for 5 minutes before I found it in my source...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions