Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SimonSapin opened this issue Jul 4, 2013 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@SimonSapin
Copy link
Contributor

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.

@SimonSapin
Copy link
Contributor Author

The weirder part is that stuff from extra can still be used with full names like extra::json::List!

@emberian
Copy link
Member

emberian commented Jul 4, 2013

Does use self::extra::json work? Imports are relative to the top of the crate, not the current mod.

@SimonSapin
Copy link
Contributor Author

@cmr , yes it does work. So the extern mod extra line is not ignored, but I still find the error message on use misleading. I’ll update the issue title.

@emberian
Copy link
Member

emberian commented Jul 4, 2013

Dup of #7584, closing.

@emberian emberian closed this as completed Jul 4, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 3, 2021
Tweak common tool docs on type-implement-trait check

See rust-lang/rust-clippy#7562 (comment).

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

2 participants