Skip to content

Commit c22455c

Browse files
author
Lukas Stevens
committed
Check for word beginning in stutter lint
1 parent 17e322b commit c22455c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

clippy_lints/src/enum_variants.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,17 @@ impl EarlyLintPass for EnumVariantNames {
264264
let matching = partial_match(mod_camel, &item_camel);
265265
let rmatching = partial_rmatch(mod_camel, &item_camel);
266266
let nchars = mod_camel.chars().count();
267+
268+
let is_word_beginning = |c: char| {
269+
c == '_' || c.is_uppercase() || c.is_numeric()
270+
};
271+
267272
if matching == nchars {
268-
span_lint(cx, STUTTER, item.span, "item name starts with its containing module's name");
273+
match item_camel.chars().nth(nchars) {
274+
Some(c) if is_word_beginning(c) =>
275+
span_lint(cx, STUTTER, item.span, "item name starts with its containing module's name"),
276+
_ => ()
277+
}
269278
}
270279
if rmatching == nchars {
271280
span_lint(cx, STUTTER, item.span, "item name ends with its containing module's name");

0 commit comments

Comments
 (0)