X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=clippy_lints%2Fsrc%2Fnon_expressive_names.rs;h=7bdeec0a56f0ee0fc53951b92267d12fa9ab9023;hb=6937d5581af14b71e23af0db81241a3fea11c70a;hp=fbf60db28ee4053a7a19c748a0f771911f3b3126;hpb=27b5dd8886ac0423e059c0817b55a4e618b344a0;p=rust.git diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index fbf60db28ee..7bdeec0a56f 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -7,57 +7,57 @@ use syntax::symbol::LocalInternedString; use syntax::visit::{walk_block, walk_expr, walk_pat, Visitor}; -/// **What it does:** Checks for names that are very similar and thus confusing. -/// -/// **Why is this bad?** It's hard to distinguish between names that differ only -/// by a single character. -/// -/// **Known problems:** None? -/// -/// **Example:** -/// ```rust -/// let checked_exp = something; -/// let checked_expr = something_else; -/// ``` declare_clippy_lint! { + /// **What it does:** Checks for names that are very similar and thus confusing. + /// + /// **Why is this bad?** It's hard to distinguish between names that differ only + /// by a single character. + /// + /// **Known problems:** None? + /// + /// **Example:** + /// ```ignore + /// let checked_exp = something; + /// let checked_expr = something_else; + /// ``` pub SIMILAR_NAMES, pedantic, "similarly named items and bindings" } -/// **What it does:** Checks for too many variables whose name consists of a -/// single character. -/// -/// **Why is this bad?** It's hard to memorize what a variable means without a -/// descriptive name. -/// -/// **Known problems:** None? -/// -/// **Example:** -/// ```rust -/// let (a, b, c, d, e, f, g) = (...); -/// ``` declare_clippy_lint! { + /// **What it does:** Checks for too many variables whose name consists of a + /// single character. + /// + /// **Why is this bad?** It's hard to memorize what a variable means without a + /// descriptive name. + /// + /// **Known problems:** None? + /// + /// **Example:** + /// ```ignore + /// let (a, b, c, d, e, f, g) = (...); + /// ``` pub MANY_SINGLE_CHAR_NAMES, style, "too many single character bindings" } -/// **What it does:** Checks if you have variables whose name consists of just -/// underscores and digits. -/// -/// **Why is this bad?** It's hard to memorize what a variable means without a -/// descriptive name. -/// -/// **Known problems:** None? -/// -/// **Example:** -/// ```rust -/// let _1 = 1; -/// let ___1 = 1; -/// let __1___2 = 11; -/// ``` declare_clippy_lint! { + /// **What it does:** Checks if you have variables whose name consists of just + /// underscores and digits. + /// + /// **Why is this bad?** It's hard to memorize what a variable means without a + /// descriptive name. + /// + /// **Known problems:** None? + /// + /// **Example:** + /// ```rust + /// let _1 = 1; + /// let ___1 = 1; + /// let __1___2 = 11; + /// ``` pub JUST_UNDERSCORES_AND_DIGITS, style, "unclear name" @@ -241,7 +241,7 @@ fn check_name(&mut self, span: Span, name: Name) { // or too many chars differ (x_foo, y_boo) or (xfoo, yboo) continue; } - split_at = interned_name.chars().next().map(|c| c.len_utf8()); + split_at = interned_name.chars().next().map(char::len_utf8); } } span_lint_and_then(