Closed
Description
Summary
I propose that, to better align with idiomatic Rust naming, module_name_repetitions
should not lint if deleting the repetition would leave only a preposition such as “as
”, “to
”, “from
”, or “into
”.
Or more generally, there could be a configuration option for the list of such words, which is by default filled with English prepositions.
Lint Name
module_name_repetitions
Reproducer
I tried this code:
#![warn(clippy::module_name_repetitions)]
pub mod widget {
pub fn to_widget<T: ToWidget>(_: T) {}
pub trait AsWidget {}
pub trait ToWidget {}
pub trait IntoWidget {}
}
I saw this happen:
warning: item name ends with its containing module's name
--> src/lib.rs:4:12
|
4 | pub fn to_widget<T: ToWidget>(_: T) {}
| ^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repetitions
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![warn(clippy::module_name_repetitions)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: item name ends with its containing module's name
--> src/lib.rs:5:15
|
5 | pub trait AsWidget {}
| ^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repetitions
warning: item name ends with its containing module's name
--> src/lib.rs:6:15
|
6 | pub trait ToWidget {}
| ^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repetitions
warning: item name ends with its containing module's name
--> src/lib.rs:7:15
|
7 | pub trait IntoWidget {}
| ^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repetitions
I hoped to see this happen: no warnings
Version
1.77.0 and 1.79.0-nightly (2024-03-22 85e449a)