Skip to content

Wildcard imports do not seem to propagate as expected for tuple-like struct types having at least one non-pub field #53140

Closed
@yvt

Description

@yvt

In the following code, ::mod1::Item is expected to be imported as ::mod1::mod2::Item via the following route:

  1. ::mod1::Item (the original definition)
  2. ::Item (by use self::mod1::* in the crate root)
  3. ::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:

  • 1.28.0.

Metadata

Metadata

Assignees

Labels

A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyE-help-wantedCall for participation: Help is requested to fix this issue.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions