In the following code, ::mod1::Item is expected to be imported as ::mod1::mod2::Item via the following route:
::mod1::Item (the original definition)
::Item (by use self::mod1::* in the crate root)
::mod1::mod2::Item (by use Item in ::mod1::mod2)
However, an “unresolved import” error is reported for the last use as shown below:
#![allow(unused_imports)]
mod mod1 {
mod mod2 {
use Item; // <--- Causes an "unresolved import" error
// use ::Item; // <--- So does this too
// use super::super::Item; // <--- This, three
// use super::Item; // <--- But not this one
}
pub struct Item(usize);
// The "unresolved import" error no longer occurs if the above definition
// was replaced with any one of the following:
// pub struct Item(pub usize);
// pub struct Item();
// pub struct Item { x: usize }
}
use self::mod1::*; // `Item` is supposed to re-exported here
// Replacing the above `use` with the following one makes the error disappear
// use self::mod1::Item;
fn main() {
let _: Option<Item> = None;
}
(Playground)
Errors:
Compiling playground v0.0.1 (file:///playground)
error[E0432]: unresolved import
--> src/main.rs:5:13
|
5 | use Item; // <--- Causes an "unresolved import" error
| ^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0432`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
This issue can be reproduced in:
- 1.30.0-nightly (73c7873 2018-08-05).
- 1.29.0-beta.2 (ea82e08 2018-08-05).
But not in:
In the following code,
::mod1::Itemis expected to be imported as::mod1::mod2::Itemvia the following route:::mod1::Item(the original definition)::Item(byuse self::mod1::*in the crate root)::mod1::mod2::Item(byuse Itemin::mod1::mod2)However, an “unresolved import” error is reported for the last
useas shown below:(Playground)
Errors:
This issue can be reproduced in:
But not in: