Skip to content

fix self_named_module_files: track module with relative path #15469

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zihan0822
Copy link
Contributor

@zihan0822 zihan0822 commented Aug 12, 2025

Previous approach roughly works as follows:
For each file, it marks every directory segment of its relative path to crate's working directory as a potential module. If segment foo exists, foo.rs exists and foo/mod.rs does not exist, the lint will trigger. The main issue with that is it ignores all the prefixes. #14697 also explained a bit how it works.

This PR fixes that by tracking each module with its entire relative path to crate's working directory.
If path/to/foo exists, path/to/foo.rs exists and path/to/foo/mod.rs does not exist, the lint will trigger.

Fixes #14697
Fixes #10271
Fixes #11916

changelog: none

@rustbot
Copy link
Collaborator

rustbot commented Aug 12, 2025

r? @Jarcho

rustbot has assigned @Jarcho.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 12, 2025
@rustbot

This comment has been minimized.

tracks each sub folder by its relative path from crate's working
directory instead of individual path segments

changelog: none

Signed-off-by: Zihan <[email protected]>
Copy link

Lintcheck changes for dce16f4

Lint Added Removed Changed
clippy::self_named_module_files 1 3 0

This comment will be updated if you push new changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
3 participants