Skip to content

Commit 9afd8ab

Browse files
Fix similar_names warnings
Most of these are just `#![allow]`ed, because they are things like using l vs r to differentiate left vs right. These would be made less clear by taking the advice of `similar_names`
1 parent 9d33731 commit 9afd8ab

File tree

9 files changed

+17
-6
lines changed

9 files changed

+17
-6
lines changed

clippy_lints/src/double_comparison.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl LintPass for DoubleComparisonPass {
4949
}
5050

5151
impl<'a, 'tcx> DoubleComparisonPass {
52+
#[allow(clippy::similar_names)]
5253
fn check_binop(
5354
&self,
5455
cx: &LateContext<'a, 'tcx>,

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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/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/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 {

clippy_lints/src/utils/hir_utils.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
7373
&& both(&left.expr, &right.expr, |l, r| self.eq_expr(l, r))
7474
}
7575

76+
#[allow(clippy::similar_names)]
7677
pub fn eq_expr(&mut self, left: &Expr, right: &Expr) -> bool {
7778
if self.ignore_fn && differing_macro_contexts(left.span, right.span) {
7879
return false;
@@ -208,6 +209,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
208209
}
209210
}
210211

212+
#[allow(clippy::similar_names)]
211213
fn eq_qpath(&mut self, left: &QPath, right: &QPath) -> bool {
212214
match (left, right) {
213215
(&QPath::Resolved(ref lty, ref lpath), &QPath::Resolved(ref rty, ref rpath)) => {
@@ -262,6 +264,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
262264
self.eq_ty_kind(&left.node, &right.node)
263265
}
264266

267+
#[allow(clippy::similar_names)]
265268
pub fn eq_ty_kind(&mut self, left: &TyKind, right: &TyKind) -> bool {
266269
match (left, right) {
267270
(&TyKind::Slice(ref l_vec), &TyKind::Slice(ref r_vec)) => self.eq_ty(l_vec, r_vec),

clippy_lints/src/utils/inspector.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ fn print_decl(cx: &LateContext<'_, '_>, decl: &hir::Decl) {
166166
}
167167
}
168168

169+
#[allow(clippy::similar_names)]
169170
fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
170171
let ind = " ".repeat(indent);
171172
println!("{}+", ind);
@@ -424,6 +425,7 @@ fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item) {
424425
}
425426
}
426427

428+
#[allow(clippy::similar_names)]
427429
fn print_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat, indent: usize) {
428430
let ind = " ".repeat(indent);
429431
println!("{}+", ind);

clippy_lints/src/utils/usage.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct MutVarsDelegate {
5454
}
5555

5656
impl<'tcx> MutVarsDelegate {
57+
#[allow(clippy::similar_names)]
5758
fn update(&mut self, cat: &'tcx Categorization<'_>) {
5859
match *cat {
5960
Categorization::Local(id) => {

0 commit comments

Comments
 (0)