Skip to content

redundant_closure_for_method_calls auto-fix used private module #16731

@danieljharvey

Description

@danieljharvey

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions