Skip to content

Misleading error message "unresolved import. maybe a missing extern mod extra?" #7583

Closed
@SimonSapin

Description

@SimonSapin

The following code does not build on Rust 0.7:

mod a {
    extern mod extra;
    use extra::json;
}

fn main() {}

Output:

/tmp/b.rc:4:8: 4:13 error: unresolved import. maybe a missing `extern mod extra`?
/tmp/b.rc:4     use extra::json;
                    ^~~~~
/tmp/b.rc:4:8: 4:19 error: failed to resolve import `extra::json`
/tmp/b.rc:4     use extra::json;
                    ^~~~~~~~~~~
error: aborting due to 2 previous errors

Moving extern mode extra; to the crate top level fixes the issue. The current error message is very confusing at best, especially if the module is a separate .rs file.

Please either change extern mod foo; to work in modules, or make it an error. Don’t ignore it silently.

UPDATE: See comments below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions