[`string_add_assign`]: https://github.com/Manishearth/rust-clippy/wiki#string_add_assign
[`string_lit_as_bytes`]: https://github.com/Manishearth/rust-clippy/wiki#string_lit_as_bytes
[`string_to_string`]: https://github.com/Manishearth/rust-clippy/wiki#string_to_string
+[`stutter`]: https://github.com/Manishearth/rust-clippy/wiki#stutter
[`suspicious_assignment_formatting`]: https://github.com/Manishearth/rust-clippy/wiki#suspicious_assignment_formatting
[`suspicious_else_formatting`]: https://github.com/Manishearth/rust-clippy/wiki#suspicious_else_formatting
[`temporary_assignment`]: https://github.com/Manishearth/rust-clippy/wiki#temporary_assignment
## Lints
-There are 153 lints included in this crate:
+There are 154 lints included in this crate:
name | default | meaning
---------------------------------------------------------------------------------------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[string_add](https://github.com/Manishearth/rust-clippy/wiki#string_add) | allow | using `x + ..` where x is a `String`; suggests using `push_str()` instead
[string_add_assign](https://github.com/Manishearth/rust-clippy/wiki#string_add_assign) | allow | using `x = x + ..` where x is a `String`; suggests using `push_str()` instead
[string_lit_as_bytes](https://github.com/Manishearth/rust-clippy/wiki#string_lit_as_bytes) | warn | calling `as_bytes` on a string literal; suggests using a byte string literal instead
+[stutter](https://github.com/Manishearth/rust-clippy/wiki#stutter) | allow | finds type names prefixed/postfixed with their containing module's name
[suspicious_assignment_formatting](https://github.com/Manishearth/rust-clippy/wiki#suspicious_assignment_formatting) | warn | suspicious formatting of `*=`, `-=` or `!=`
[suspicious_else_formatting](https://github.com/Manishearth/rust-clippy/wiki#suspicious_else_formatting) | warn | suspicious formatting of `else if`
[temporary_assignment](https://github.com/Manishearth/rust-clippy/wiki#temporary_assignment) | warn | assignments to temporaries
"finds enums where all variants share a prefix/postfix"
}
+/// **What it does:** Warns on type names that are prefixed or suffixed by the containing module's name
+///
+/// **Why is this bad?** It requires the user to type the module name twice
+///
+/// **Known problems:** None
+///
+/// **Example:** mod cake { struct BlackForestCake; }
+declare_lint! {
+ pub STUTTER, Allow,
+ "finds type names prefixed/postfixed with their containing module's name"
+}
+
#[derive(Default)]
pub struct EnumVariantNames {
modules: Vec<String>,
impl LintPass for EnumVariantNames {
fn get_lints(&self) -> LintArray {
- lint_array!(ENUM_VARIANT_NAMES)
+ lint_array!(ENUM_VARIANT_NAMES, STUTTER)
}
}
let rmatching = partial_rmatch(mod_camel, &item_camel);
let nchars = mod_camel.chars().count();
if matching == nchars {
- span_lint(cx, ENUM_VARIANT_NAMES, item.span, &format!("Item name ({}) starts with its containing module's name ({})", item_camel, mod_camel));
+ span_lint(cx, STUTTER, item.span, &format!("Item name ({}) starts with its containing module's name ({})", item_camel, mod_camel));
}
if rmatching == nchars {
- span_lint(cx, ENUM_VARIANT_NAMES, item.span, &format!("Item name ({}) ends with its containing module's name ({})", item_camel, mod_camel));
+ span_lint(cx, STUTTER, item.span, &format!("Item name ({}) ends with its containing module's name ({})", item_camel, mod_camel));
}
}
}
array_indexing::INDEXING_SLICING,
booleans::NONMINIMAL_BOOL,
enum_glob_use::ENUM_GLOB_USE,
+ enum_variants::STUTTER,
if_not_else::IF_NOT_ELSE,
items_after_statements::ITEMS_AFTER_STATEMENTS,
matches::SINGLE_MATCH_ELSE,