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

Consider splitting unused_import's glob re-export visibility warning into its own lint #123210

Open
arifd opened this issue Mar 29, 2024 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@arifd
Copy link

arifd commented Mar 29, 2024

Code

mod foo {
    pub use bar::*;
    mod bar {
        pub(crate) fn baz() {}
    }
}

fn main() {
    foo::baz();
}

Current output

warning: glob import doesn't reexport anything because no candidate is public enough
 --> src/main.rs:2:13
  |
2 |     pub use bar::*;
  |             ^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Desired output

No response

Rationale and extra context

An unused import lint feels wrong to be because i am using baz.

Other cases

No response

Rust Version

rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: aarch64-apple-darwin
release: 1.75.0
LLVM version: 17.0.6

Anything else?

No response

@arifd arifd added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 29, 2024
@workingjubilee workingjubilee added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Mar 29, 2024
@workingjubilee
Copy link
Contributor

workingjubilee commented Mar 29, 2024

@workingjubilee workingjubilee added the C-bug Category: This is a bug. label Mar 29, 2024
@workingjubilee
Copy link
Contributor

Gonna call this one a bug because it seems simply incorrect in this case, yeah. 🤔

@petrochenkov
Copy link
Contributor

This was addressed recently, the message and suggestion on nightly is different.

warning: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough
 --> src/main.rs:2:13
  |
2 |     pub use bar::*;
  |             ^^^^^^
  |
note: the most public imported item is `pub(crate)`
 --> src/main.rs:2:13
  |
2 |     pub use bar::*;
  |             ^^^^^^
  = help: reduce the glob import's visibility or increase visibility of imported items
  = note: `#[warn(unused_imports)]` on by default

@arifd
Copy link
Author

arifd commented Apr 2, 2024

That is much better, as I can see now it'sbar whose pub export is triggering the "unused", rather than baz which is patently being used. (Although that second code example??)

It's still wrong to me that the lint this falls under the category called "unused imports" but if it's one of those unfortunate grey areas that just doesn't have a nice solution. I'm happy enough to close this.

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 A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants