Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
steffahn opened this issue Oct 7, 2020 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@steffahn
Copy link
Member

steffahn commented Oct 7, 2020

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

@rustbot rustbot added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 7, 2020
@steffahn steffahn changed the title Suggested imports pointing to/through non-pup use-statements in nested modules. Suggested imports pointing to/through non-pub use-statements in nested modules. Oct 7, 2020
@nagisa
Copy link
Member

nagisa commented Oct 10, 2020

Duplicate of #21934 / #50923

@nagisa nagisa closed this as completed Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants