-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lints
Description
Given a module lib.rs:
pub mod foo;
and a submodule foo.rs:
extern crate libc;
use libc::size_t;
fn test() {
let sz: size_t = 1024;
}
Compiling it with:
$ rustc --crate-type=rlib lib.rs
gives the following error:
foo.rs:4:5: 4:9 error: unresolved import `libc::size_t`. Did you mean `self::libc`?
foo.rs:4 use libc::size_t;
^~~~
error: aborting due to previous error
The extern crate line in foo.rs is ignored without any message, and compilation only succeeds if this line is moved to lib.rs. This behaviour is quite confusing as the error message doesn't lead you to the correct solution.
It would be nice if you could have extern crate declarations in all modules, but failing that, at least there should be a diagnostic that it is ignored in the submodule and required in the top level module of the crate.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lints