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

[mod_module_files] Don't emit lint for mod.rs in tests #11779

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion clippy_lints/src/module_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,11 @@ fn process_paths_for_mod_files<'a>(
}

/// Checks every path for the presence of `mod.rs` files and emits the lint if found.
/// We should not emit a lint for test modules in the presence of `mod.rs`.
/// Using `mod.rs` in integration tests is a [common pattern](https://doc.rust-lang.org/book/ch11-03-test-organization.html#submodules-in-integration-test)
/// for code-sharing between tests.
fn check_self_named_mod_exists(cx: &EarlyContext<'_>, path: &Path, file: &SourceFile) {
if path.ends_with("mod.rs") {
if path.ends_with("mod.rs") && !path.starts_with("tests") {
blyxyas marked this conversation as resolved.
Show resolved Hide resolved
let mut mod_file = path.to_path_buf();
mod_file.pop();
mod_file.set_extension("rs");
Expand Down