Skip to content

Commit 78860a7

Browse files
authored
Merge pull request #3298 from devonhollowood/pedantic-dogfood-naming
Pedantic dogfood: naming and docs
2 parents 7efd4a5 + 335bc1e commit 78860a7

15 files changed

+55
-44
lines changed

clippy_lints/src/double_comparison.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ declare_clippy_lint! {
4040
"unnecessary double comparisons that can be simplified"
4141
}
4242

43-
pub struct DoubleComparisonPass;
43+
pub struct Pass;
4444

45-
impl LintPass for DoubleComparisonPass {
45+
impl LintPass for Pass {
4646
fn get_lints(&self) -> LintArray {
4747
lint_array!(DOUBLE_COMPARISONS)
4848
}
4949
}
5050

51-
impl<'a, 'tcx> DoubleComparisonPass {
51+
impl<'a, 'tcx> Pass {
52+
#[allow(clippy::similar_names)]
5253
fn check_binop(
5354
&self,
5455
cx: &LateContext<'a, 'tcx>,
@@ -87,7 +88,7 @@ impl<'a, 'tcx> DoubleComparisonPass {
8788
}
8889
}
8990

90-
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DoubleComparisonPass {
91+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
9192
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
9293
if let ExprKind::Binary(ref kind, ref lhs, ref rhs) = expr.node {
9394
self.check_binop(cx, kind.node, lhs, rhs, expr.span);

clippy_lints/src/enum_clike.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
6363
let variant = &var.node;
6464
if let Some(ref anon_const) = variant.disr_expr {
6565
let param_env = ty::ParamEnv::empty();
66-
let did = cx.tcx.hir.body_owner_def_id(anon_const.body);
67-
let substs = Substs::identity_for_item(cx.tcx.global_tcx(), did);
68-
let instance = ty::Instance::new(did, substs);
69-
let cid = GlobalId {
66+
let def_id = cx.tcx.hir.body_owner_def_id(anon_const.body);
67+
let substs = Substs::identity_for_item(cx.tcx.global_tcx(), def_id);
68+
let instance = ty::Instance::new(def_id, substs);
69+
let c_id = GlobalId {
7070
instance,
7171
promoted: None
7272
};
73-
let constant = cx.tcx.const_eval(param_env.and(cid)).ok();
73+
let constant = cx.tcx.const_eval(param_env.and(c_id)).ok();
7474
if let Some(Constant::Int(val)) = constant.and_then(|c| miri_to_const(cx.tcx, c)) {
75-
let mut ty = cx.tcx.type_of(did);
75+
let mut ty = cx.tcx.type_of(def_id);
7676
if let ty::Adt(adt, _) = ty.sty {
7777
if adt.is_enum() {
7878
ty = adt.repr.discr_type().to_ty(cx.tcx);

clippy_lints/src/enum_variants.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::syntax::ast::*;
1616
use crate::syntax::source_map::Span;
1717
use crate::syntax::symbol::LocalInternedString;
1818
use crate::utils::{span_help_and_lint, span_lint};
19-
use crate::utils::{camel_case_from, camel_case_until, in_macro};
19+
use crate::utils::{camel_case, in_macro};
2020

2121
/// **What it does:** Detects enumeration variants that are prefixed or suffixed
2222
/// by the same characters.
@@ -184,19 +184,19 @@ fn check_variant(
184184
}
185185
}
186186
let first = var2str(&def.variants[0]);
187-
let mut pre = &first[..camel_case_until(&*first)];
188-
let mut post = &first[camel_case_from(&*first)..];
187+
let mut pre = &first[..camel_case::until(&*first)];
188+
let mut post = &first[camel_case::from(&*first)..];
189189
for var in &def.variants {
190190
let name = var2str(var);
191191

192192
let pre_match = partial_match(pre, &name);
193193
pre = &pre[..pre_match];
194-
let pre_camel = camel_case_until(pre);
194+
let pre_camel = camel_case::until(pre);
195195
pre = &pre[..pre_camel];
196196
while let Some((next, last)) = name[pre.len()..].chars().zip(pre.chars().rev()).next() {
197197
if next.is_lowercase() {
198198
let last = pre.len() - last.len_utf8();
199-
let last_camel = camel_case_until(&pre[..last]);
199+
let last_camel = camel_case::until(&pre[..last]);
200200
pre = &pre[..last_camel];
201201
} else {
202202
break;
@@ -206,7 +206,7 @@ fn check_variant(
206206
let post_match = partial_rmatch(post, &name);
207207
let post_end = post.len() - post_match;
208208
post = &post[post_end..];
209-
let post_camel = camel_case_from(post);
209+
let post_camel = camel_case::from(post);
210210
post = &post[post_camel..];
211211
}
212212
let (what, value) = match (pre.is_empty(), post.is_empty()) {
@@ -255,6 +255,7 @@ impl EarlyLintPass for EnumVariantNames {
255255
assert!(last.is_some());
256256
}
257257

258+
#[allow(clippy::similar_names)]
258259
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
259260
let item_name = item.ident.as_str();
260261
let item_name_chars = item_name.chars().count();

clippy_lints/src/eq_op.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl LintPass for EqOp {
6363
}
6464

6565
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
66+
#[allow(clippy::similar_names)]
6667
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
6768
if let ExprKind::Binary(op, ref left, ref right) = e.node {
6869
if in_macro(e.span) {

clippy_lints/src/excessive_precision.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ impl ExcessivePrecision {
108108
}
109109
}
110110

111+
#[allow(clippy::doc_markdown)]
111112
/// Should we exclude the float because it has a `.0` or `.` suffix
112113
/// Ex 1_000_000_000.0
113114
/// Ex 1_000_000_000.

clippy_lints/src/if_let_redundant_pattern_matching.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ impl LintPass for Pass {
5656
}
5757

5858
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
59+
#[allow(clippy::similar_names)]
5960
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
6061
if let ExprKind::Match(ref op, ref arms, MatchSource::IfLetDesugar { .. }) = expr.node {
6162
if arms[0].pats.len() == 1 {

clippy_lints/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
430430
reg.register_late_lint_pass(box fallible_impl_from::FallibleImplFrom);
431431
reg.register_late_lint_pass(box replace_consts::ReplaceConsts);
432432
reg.register_late_lint_pass(box types::UnitArg);
433-
reg.register_late_lint_pass(box double_comparison::DoubleComparisonPass);
434-
reg.register_late_lint_pass(box question_mark::QuestionMarkPass);
433+
reg.register_late_lint_pass(box double_comparison::Pass);
434+
reg.register_late_lint_pass(box question_mark::Pass);
435435
reg.register_late_lint_pass(box suspicious_trait_impl::SuspiciousImpl);
436436
reg.register_early_lint_pass(box multiple_crate_versions::Pass);
437437
reg.register_late_lint_pass(box map_unit_fn::Pass);

clippy_lints/src/map_unit_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fn unit_closure<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'a hir::Expr) -> Op
179179
None
180180
}
181181

182-
/// Builds a name for the let binding variable (var_arg)
182+
/// Builds a name for the let binding variable (`var_arg`)
183183
///
184184
/// `x.field` => `x_field`
185185
/// `y` => `_y`

clippy_lints/src/question_mark.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ declare_clippy_lint!{
4545
}
4646

4747
#[derive(Copy, Clone)]
48-
pub struct QuestionMarkPass;
48+
pub struct Pass;
4949

50-
impl LintPass for QuestionMarkPass {
50+
impl LintPass for Pass {
5151
fn get_lints(&self) -> LintArray {
5252
lint_array!(QUESTION_MARK)
5353
}
5454
}
5555

56-
impl QuestionMarkPass {
56+
impl Pass {
5757
/// Check if the given expression on the given context matches the following structure:
5858
///
5959
/// ```ignore
@@ -145,7 +145,7 @@ impl QuestionMarkPass {
145145
}
146146
}
147147

148-
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for QuestionMarkPass {
148+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
149149
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
150150
Self::check_is_none_and_early_return_none(cx, expr);
151151
}

clippy_lints/src/transmute.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ impl LintPass for Transmute {
227227
}
228228

229229
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
230+
#[allow(clippy::similar_names)]
230231
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
231232
if let ExprKind::Call(ref path_expr, ref args) = e.node {
232233
if let ExprKind::Path(ref qpath) = path_expr.node {

0 commit comments

Comments
 (0)