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:
@@ -49,6 +49,7 @@ impl LintPass for DoubleComparisonPass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> DoubleComparisonPass {
|
impl<'a, 'tcx> DoubleComparisonPass {
|
||||||
|
#[allow(clippy::similar_names)]
|
||||||
fn check_binop(
|
fn check_binop(
|
||||||
&self,
|
&self,
|
||||||
cx: &LateContext<'a, 'tcx>,
|
cx: &LateContext<'a, 'tcx>,
|
||||||
|
|||||||
@@ -63,16 +63,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
|
|||||||
let variant = &var.node;
|
let variant = &var.node;
|
||||||
if let Some(ref anon_const) = variant.disr_expr {
|
if let Some(ref anon_const) = variant.disr_expr {
|
||||||
let param_env = ty::ParamEnv::empty();
|
let param_env = ty::ParamEnv::empty();
|
||||||
let did = cx.tcx.hir.body_owner_def_id(anon_const.body);
|
let def_id = cx.tcx.hir.body_owner_def_id(anon_const.body);
|
||||||
let substs = Substs::identity_for_item(cx.tcx.global_tcx(), did);
|
let substs = Substs::identity_for_item(cx.tcx.global_tcx(), def_id);
|
||||||
let instance = ty::Instance::new(did, substs);
|
let instance = ty::Instance::new(def_id, substs);
|
||||||
let cid = GlobalId {
|
let c_id = GlobalId {
|
||||||
instance,
|
instance,
|
||||||
promoted: None
|
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)) {
|
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 let ty::Adt(adt, _) = ty.sty {
|
||||||
if adt.is_enum() {
|
if adt.is_enum() {
|
||||||
ty = adt.repr.discr_type().to_ty(cx.tcx);
|
ty = adt.repr.discr_type().to_ty(cx.tcx);
|
||||||
|
|||||||
@@ -255,6 +255,7 @@ impl EarlyLintPass for EnumVariantNames {
|
|||||||
assert!(last.is_some());
|
assert!(last.is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::similar_names)]
|
||||||
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
|
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
|
||||||
let item_name = item.ident.as_str();
|
let item_name = item.ident.as_str();
|
||||||
let item_name_chars = item_name.chars().count();
|
let item_name_chars = item_name.chars().count();
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ impl LintPass for EqOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> 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) {
|
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||||
if let ExprKind::Binary(op, ref left, ref right) = e.node {
|
if let ExprKind::Binary(op, ref left, ref right) = e.node {
|
||||||
if in_macro(e.span) {
|
if in_macro(e.span) {
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ impl LintPass for Pass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> 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) {
|
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 let ExprKind::Match(ref op, ref arms, MatchSource::IfLetDesugar { .. }) = expr.node {
|
||||||
if arms[0].pats.len() == 1 {
|
if arms[0].pats.len() == 1 {
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ impl LintPass for Transmute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> 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) {
|
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::Call(ref path_expr, ref args) = e.node {
|
||||||
if let ExprKind::Path(ref qpath) = path_expr.node {
|
if let ExprKind::Path(ref qpath) = path_expr.node {
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
|||||||
&& both(&left.expr, &right.expr, |l, r| self.eq_expr(l, r))
|
&& 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 {
|
pub fn eq_expr(&mut self, left: &Expr, right: &Expr) -> bool {
|
||||||
if self.ignore_fn && differing_macro_contexts(left.span, right.span) {
|
if self.ignore_fn && differing_macro_contexts(left.span, right.span) {
|
||||||
return false;
|
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 {
|
fn eq_qpath(&mut self, left: &QPath, right: &QPath) -> bool {
|
||||||
match (left, right) {
|
match (left, right) {
|
||||||
(&QPath::Resolved(ref lty, ref lpath), &QPath::Resolved(ref rty, ref rpath)) => {
|
(&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)
|
self.eq_ty_kind(&left.node, &right.node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::similar_names)]
|
||||||
pub fn eq_ty_kind(&mut self, left: &TyKind, right: &TyKind) -> bool {
|
pub fn eq_ty_kind(&mut self, left: &TyKind, right: &TyKind) -> bool {
|
||||||
match (left, right) {
|
match (left, right) {
|
||||||
(&TyKind::Slice(ref l_vec), &TyKind::Slice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
|
(&TyKind::Slice(ref l_vec), &TyKind::Slice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
|
||||||
|
|||||||
@@ -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) {
|
fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
|
||||||
let ind = " ".repeat(indent);
|
let ind = " ".repeat(indent);
|
||||||
println!("{}+", ind);
|
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) {
|
fn print_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat, indent: usize) {
|
||||||
let ind = " ".repeat(indent);
|
let ind = " ".repeat(indent);
|
||||||
println!("{}+", ind);
|
println!("{}+", ind);
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ struct MutVarsDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> MutVarsDelegate {
|
impl<'tcx> MutVarsDelegate {
|
||||||
|
#[allow(clippy::similar_names)]
|
||||||
fn update(&mut self, cat: &'tcx Categorization<'_>) {
|
fn update(&mut self, cat: &'tcx Categorization<'_>) {
|
||||||
match *cat {
|
match *cat {
|
||||||
Categorization::Local(id) => {
|
Categorization::Local(id) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user