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`
This commit is contained in:
Devon Hollowood 2018-10-11 15:18:58 -07:00
parent 9d3373137b
commit 9afd8abbe3
9 changed files with 17 additions and 6 deletions

View File

@ -49,6 +49,7 @@ impl LintPass for DoubleComparisonPass {
}
impl<'a, 'tcx> DoubleComparisonPass {
#[allow(clippy::similar_names)]
fn check_binop(
&self,
cx: &LateContext<'a, 'tcx>,

View File

@ -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);

View File

@ -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();

View File

@ -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) {

View File

@ -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 {

View File

@ -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 {

View File

@ -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;
@ -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)) => {
@ -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),

View File

@ -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);
@ -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);

View File

@ -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) => {