Skip to content

Suggested imports pointing to/through non-pub use-statements in nested modules. #77679

Closed
@steffahn

Description

@steffahn
mod local {
    use std::*;
    use io::BufReader;
}

type T1 = BufReader;
type T2 = BufWriter;

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error[E0412]: cannot find type `BufReader` in this scope
 --> src/lib.rs:7:11
  |
7 | type T1 = BufReader;
  |           ^^^^^^^^^ not found in this scope
  |
help: consider importing one of these items
  |
2 | use crate::local::BufReader;
  |
2 | use futures::io::BufReader;
  |
2 | use futures_util::io::BufReader;
  |
2 | use std::io::BufReader;
  |
    and 1 other candidate

error[E0412]: cannot find type `BufWriter` in this scope
 --> src/lib.rs:8:11
  |
8 | type T2 = BufWriter;
  |           ^^^^^^^^^ not found in this scope
  |
help: consider importing one of these items
  |
2 | use crate::local::io::BufWriter;
  |
2 | use futures::io::BufWriter;
  |
2 | use futures_util::io::BufWriter;
  |
2 | use std::io::BufWriter;
  |
    and 1 other candidate

warning: unused import: `io::BufReader`
 --> src/lib.rs:4:9
  |
4 |     use io::BufReader;
  |         ^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0412`.
error: could not compile `playground`.

To learn more, run the command again with --verbose.

At least, applying the suggestion gives a new error message about the use not being public. But it is IMO particularly bad that these tend to be the first suggestion.

@rustbot modify labels: T-compiler, A-diagnostics, D-papercut, C-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions