rust-lang / rust-lang/rust-clippy
`redundant_closure_for_method_calls` auto-fix used private module
Open
@swjng is already working on this.
Since Apr 28, 2026.
C-bug
I-suggestion-causes-error
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
Hello! Clippy fix mode used a private module directly in place of it's public re-export, and recommended I open an issue.
Here is the original output:
The following errors were reported:
error[E0603]: module `auth` is private
--> crates/server/src/handlers/foo.rs:74:85
|
74 | ServerMode::Cloud { .. } => user_session.and_then(super::super::middleware::auth::types::UserSession::foo).map(f),
| ^^^^ private module
|
note: the module `auth` is defined here
--> crates/server/src/middleware/mod.rs:1:1
|
1 | mod auth;
| ^^^^^^^^^
help: consider importing this struct through its public re-export instead
|
74 - ServerMode::Cloud { .. } => user_session.and_then(super::super::middleware::auth::types::UserSession::foo).map(f),
74 + ServerMode::Cloud { .. } => user_session.and_then(crate::UserSession::foo).map(f),
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0603`.
Original diagnostics will follow.
warning: redundant closure
--> crates/server/src/handlers/foo.rs:74:59
|
74 | ServerMode::Cloud { .. } => user_session.and_then(|us| us.foo()).map(f),
| ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `super::super::middleware::auth::types::UserSession::foo`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#redundant_closure_for_method_calls
= note: `-W clippy::redundant-closure-for-method-calls` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::redundant_closure_for_method_calls)]`
Reproducer
Code:
<code>
Current output:
Desired output:
Version
rustc 1.94.0 (4a4ef493e 2026-03-02)
binary: rustc
commit-hash: 4a4ef493e3a1488c6e321570238084b38948f6db
commit-date: 2026-03-02
host: aarch64-apple-darwin
release: 1.94.0
LLVM version: 21.1.8
Additional Labels
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.