Skip to content

Commit

Permalink
Fix similar_names warnings
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
devonhollowood committed Oct 11, 2018
1 parent 9d33731 commit 9afd8ab
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions clippy_lints/src/double_comparison.rs
Expand Up @@ -49,6 +49,7 @@ impl LintPass for DoubleComparisonPass {
}

impl<'a, 'tcx> DoubleComparisonPass {
#[allow(clippy::similar_names)]
fn check_binop(
&self,
cx: &LateContext<'a, 'tcx>,
Expand Down
12 changes: 6 additions & 6 deletions clippy_lints/src/enum_clike.rs
Expand Up @@ -63,16 +63,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
let variant = &var.node;
if let Some(ref anon_const) = variant.disr_expr {
let param_env = ty::ParamEnv::empty();
let did = cx.tcx.hir.body_owner_def_id(anon_const.body);
let substs = Substs::identity_for_item(cx.tcx.global_tcx(), did);
let instance = ty::Instance::new(did, substs);
let cid = GlobalId {
let def_id = cx.tcx.hir.body_owner_def_id(anon_const.body);
let substs = Substs::identity_for_item(cx.tcx.global_tcx(), def_id);
let instance = ty::Instance::new(def_id, substs);
let c_id = GlobalId {
instance,
promoted: None
};
let constant = cx.tcx.const_eval(param_env.and(cid)).ok();
let constant = cx.tcx.const_eval(param_env.and(c_id)).ok();
if let Some(Constant::Int(val)) = constant.and_then(|c| miri_to_const(cx.tcx, c)) {
let mut ty = cx.tcx.type_of(did);
let mut ty = cx.tcx.type_of(def_id);
if let ty::Adt(adt, _) = ty.sty {
if adt.is_enum() {
ty = adt.repr.discr_type().to_ty(cx.tcx);
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/enum_variants.rs
Expand Up @@ -255,6 +255,7 @@ impl EarlyLintPass for EnumVariantNames {
assert!(last.is_some());
}

#[allow(clippy::similar_names)]
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
let item_name = item.ident.as_str();
let item_name_chars = item_name.chars().count();
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/eq_op.rs
Expand Up @@ -63,6 +63,7 @@ impl LintPass for EqOp {
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
#[allow(clippy::similar_names)]
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
if let ExprKind::Binary(op, ref left, ref right) = e.node {
if in_macro(e.span) {
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/if_let_redundant_pattern_matching.rs
Expand Up @@ -56,6 +56,7 @@ impl LintPass for Pass {
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
#[allow(clippy::similar_names)]
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
if let ExprKind::Match(ref op, ref arms, MatchSource::IfLetDesugar { .. }) = expr.node {
if arms[0].pats.len() == 1 {
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/transmute.rs
Expand Up @@ -227,6 +227,7 @@ impl LintPass for Transmute {
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
#[allow(clippy::similar_names)]
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
if let ExprKind::Call(ref path_expr, ref args) = e.node {
if let ExprKind::Path(ref qpath) = path_expr.node {
Expand Down
3 changes: 3 additions & 0 deletions clippy_lints/src/utils/hir_utils.rs
Expand Up @@ -73,6 +73,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
&& both(&left.expr, &right.expr, |l, r| self.eq_expr(l, r))
}

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

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

#[allow(clippy::similar_names)]
pub fn eq_ty_kind(&mut self, left: &TyKind, right: &TyKind) -> bool {
match (left, right) {
(&TyKind::Slice(ref l_vec), &TyKind::Slice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/utils/inspector.rs
Expand Up @@ -166,6 +166,7 @@ fn print_decl(cx: &LateContext<'_, '_>, decl: &hir::Decl) {
}
}

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

#[allow(clippy::similar_names)]
fn print_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat, indent: usize) {
let ind = " ".repeat(indent);
println!("{}+", ind);
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/utils/usage.rs
Expand Up @@ -54,6 +54,7 @@ struct MutVarsDelegate {
}

impl<'tcx> MutVarsDelegate {
#[allow(clippy::similar_names)]
fn update(&mut self, cat: &'tcx Categorization<'_>) {
match *cat {
Categorization::Local(id) => {
Expand Down

0 comments on commit 9afd8ab

Please sign in to comment.