Closed
Description
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
(byuse self::mod1::*
in the crate root)::mod1::mod2::Item
(byuse 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;
}
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:
But not in:
- 1.28.0.