Skip to content

self_named_module_files does trigger for lib.rs for a crate inside of a workspace under lib/ #11916

@TimDiekmann

Description

@TimDiekmann

Summary

Reproduction repository: https://github.com/TimDiekmann/self_named_module_files-false-positive

Given the following workspace layout:

.
├── Cargo.toml
└── lib
    └── test-crate
        ├── Cargo.toml
        └── src
            └── lib.rs

4 directories, 3 files

if test-crate is part of the outer workspace and enables the self_named_module_files this will trigger the lint on lib.rs

Lint Name

self_named_module_files

Reproducer

I tried this code:

#![deny(clippy::self_named_module_files)]

I saw this happen:

error: `mod.rs` files are required, found `lib/test-crate/src/lib.rs`
  |
  = help: move `lib/test-crate/src/lib.rs` to `lib/test-crate/src/lib/mod.rs`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#self_named_module_files
note: the lint level is defined here
 --> lib/test-crate/src/lib.rs:1:9
  |
1 | #![deny(clippy::self_named_module_files)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `test-crate` (lib) due to previous error

I expected to see this happen:
The lint should not trigger

Version

rustc 1.76.0-nightly (90e321d82 2023-12-02)
binary: rustc
commit-hash: 90e321d82a0a9c3d0e3f180d4d17541b729072e0
commit-date: 2023-12-02
host: aarch64-apple-darwin
release: 1.76.0-nightly
LLVM version: 17.0.5

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions