Skip to content

Commit 2a559e5

Browse files
committed
submodules: Update clippy from 149a988 to 5a11ed7
1 parent dc01658 commit 2a559e5

37 files changed

+120
-128
lines changed

clippy_lints/src/assign_ops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ fn is_commutative(op: hir::BinOpKind) -> bool {
236236
}
237237
}
238238

239-
struct ExprVisitor<'a, 'tcx: 'a> {
239+
struct ExprVisitor<'a, 'tcx> {
240240
assignee: &'a hir::Expr,
241241
counter: u8,
242242
cx: &'a LateContext<'a, 'tcx>,
243243
}
244244

245-
impl<'a, 'tcx: 'a> Visitor<'tcx> for ExprVisitor<'a, 'tcx> {
245+
impl<'a, 'tcx> Visitor<'tcx> for ExprVisitor<'a, 'tcx> {
246246
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
247247
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(self.assignee, expr) {
248248
self.counter += 1;

clippy_lints/src/block_in_if_condition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ declare_clippy_lint! {
4444

4545
declare_lint_pass!(BlockInIfCondition => [BLOCK_IN_IF_CONDITION_EXPR, BLOCK_IN_IF_CONDITION_STMT]);
4646

47-
struct ExVisitor<'a, 'tcx: 'a> {
47+
struct ExVisitor<'a, 'tcx> {
4848
found_block: Option<&'tcx Expr>,
4949
cx: &'a LateContext<'a, 'tcx>,
5050
}
5151

52-
impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
52+
impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
5353
fn visit_expr(&mut self, expr: &'tcx Expr) {
5454
if let ExprKind::Closure(_, _, eid, _, _) = expr.node {
5555
let body = self.cx.tcx.hir().body(eid);

clippy_lints/src/booleans.rs

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ use crate::utils::{
22
get_trait_def_id, implements_trait, in_macro, in_macro_or_desugar, match_type, paths, snippet_opt,
33
span_lint_and_then, SpanlessEq,
44
};
5+
use if_chain::if_chain;
56
use rustc::hir::intravisit::*;
67
use rustc::hir::*;
78
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
89
use rustc::{declare_lint_pass, declare_tool_lint};
9-
use rustc_data_structures::thin_vec::ThinVec;
1010
use rustc_errors::Applicability;
1111
use syntax::ast::LitKind;
12-
use syntax::source_map::{dummy_spanned, Span, DUMMY_SP};
12+
use syntax::source_map::Span;
1313

1414
declare_clippy_lint! {
1515
/// **What it does:** Checks for boolean expressions that can be written more
@@ -68,12 +68,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonminimalBool {
6868
}
6969
}
7070

71-
struct NonminimalBoolVisitor<'a, 'tcx: 'a> {
71+
struct NonminimalBoolVisitor<'a, 'tcx> {
7272
cx: &'a LateContext<'a, 'tcx>,
7373
}
7474

7575
use quine_mc_cluskey::Bool;
76-
struct Hir2Qmm<'a, 'tcx: 'a, 'v> {
76+
struct Hir2Qmm<'a, 'tcx, 'v> {
7777
terminals: Vec<&'v Expr>,
7878
cx: &'a LateContext<'a, 'tcx>,
7979
}
@@ -93,6 +93,18 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
9393
}
9494

9595
fn run(&mut self, e: &'v Expr) -> Result<Bool, String> {
96+
fn negate(bin_op_kind: BinOpKind) -> Option<BinOpKind> {
97+
match bin_op_kind {
98+
BinOpKind::Eq => Some(BinOpKind::Ne),
99+
BinOpKind::Ne => Some(BinOpKind::Eq),
100+
BinOpKind::Gt => Some(BinOpKind::Le),
101+
BinOpKind::Ge => Some(BinOpKind::Lt),
102+
BinOpKind::Lt => Some(BinOpKind::Ge),
103+
BinOpKind::Le => Some(BinOpKind::Gt),
104+
_ => None,
105+
}
106+
}
107+
96108
// prevent folding of `cfg!` macros and the like
97109
if !in_macro_or_desugar(e.span) {
98110
match &e.node {
@@ -115,33 +127,18 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
115127
#[allow(clippy::cast_possible_truncation)]
116128
return Ok(Bool::Term(n as u8));
117129
}
118-
let negated = match &e.node {
119-
ExprKind::Binary(binop, lhs, rhs) => {
120-
if !implements_ord(self.cx, lhs) {
121-
continue;
122-
}
123130

124-
let mk_expr = |op| Expr {
125-
hir_id: DUMMY_HIR_ID,
126-
span: DUMMY_SP,
127-
attrs: ThinVec::new(),
128-
node: ExprKind::Binary(dummy_spanned(op), lhs.clone(), rhs.clone()),
129-
};
130-
match binop.node {
131-
BinOpKind::Eq => mk_expr(BinOpKind::Ne),
132-
BinOpKind::Ne => mk_expr(BinOpKind::Eq),
133-
BinOpKind::Gt => mk_expr(BinOpKind::Le),
134-
BinOpKind::Ge => mk_expr(BinOpKind::Lt),
135-
BinOpKind::Lt => mk_expr(BinOpKind::Ge),
136-
BinOpKind::Le => mk_expr(BinOpKind::Gt),
137-
_ => continue,
138-
}
139-
},
140-
_ => continue,
141-
};
142-
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(&negated, expr) {
143-
#[allow(clippy::cast_possible_truncation)]
144-
return Ok(Bool::Not(Box::new(Bool::Term(n as u8))));
131+
if_chain! {
132+
if let ExprKind::Binary(e_binop, e_lhs, e_rhs) = &e.node;
133+
if implements_ord(self.cx, e_lhs);
134+
if let ExprKind::Binary(expr_binop, expr_lhs, expr_rhs) = &expr.node;
135+
if negate(e_binop.node) == Some(expr_binop.node);
136+
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(e_lhs, expr_lhs);
137+
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(e_rhs, expr_rhs);
138+
then {
139+
#[allow(clippy::cast_possible_truncation)]
140+
return Ok(Bool::Not(Box::new(Bool::Term(n as u8))));
141+
}
145142
}
146143
}
147144
let n = self.terminals.len();
@@ -155,7 +152,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
155152
}
156153
}
157154

158-
struct SuggestContext<'a, 'tcx: 'a, 'v> {
155+
struct SuggestContext<'a, 'tcx, 'v> {
159156
terminals: &'v [&'v Expr],
160157
cx: &'a LateContext<'a, 'tcx>,
161158
output: String,

clippy_lints/src/cognitive_complexity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl CognitiveComplexity {
4141
impl_lint_pass!(CognitiveComplexity => [COGNITIVE_COMPLEXITY]);
4242

4343
impl CognitiveComplexity {
44-
fn check<'a, 'tcx: 'a>(&mut self, cx: &'a LateContext<'a, 'tcx>, body: &'tcx Body, span: Span) {
44+
fn check<'a, 'tcx>(&mut self, cx: &'a LateContext<'a, 'tcx>, body: &'tcx Body, span: Span) {
4545
if in_macro_or_desugar(span) {
4646
return;
4747
}
@@ -132,7 +132,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CognitiveComplexity {
132132
}
133133
}
134134

135-
struct CCHelper<'a, 'tcx: 'a> {
135+
struct CCHelper<'a, 'tcx> {
136136
match_arms: u64,
137137
divergence: u64,
138138
returns: u64,

clippy_lints/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub fn constant_context<'c, 'cc>(
210210
}
211211
}
212212

213-
pub struct ConstEvalLateContext<'a, 'tcx: 'a> {
213+
pub struct ConstEvalLateContext<'a, 'tcx> {
214214
lcx: &'a LateContext<'a, 'tcx>,
215215
tables: &'a ty::TypeckTables<'tcx>,
216216
param_env: ty::ParamEnv<'tcx>,

clippy_lints/src/double_comparison.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ declare_lint_pass!(DoubleComparisons => [DOUBLE_COMPARISONS]);
3636
impl<'a, 'tcx> DoubleComparisons {
3737
#[allow(clippy::similar_names)]
3838
fn check_binop(self, cx: &LateContext<'a, 'tcx>, op: BinOpKind, lhs: &'tcx Expr, rhs: &'tcx Expr, span: Span) {
39-
let (lkind, llhs, lrhs, rkind, rlhs, rrhs) = match (lhs.node.clone(), rhs.node.clone()) {
39+
let (lkind, llhs, lrhs, rkind, rlhs, rrhs) = match (&lhs.node, &rhs.node) {
4040
(ExprKind::Binary(lb, llhs, lrhs), ExprKind::Binary(rb, rlhs, rrhs)) => {
4141
(lb.node, llhs, lrhs, rb.node, rlhs, rrhs)
4242
},

clippy_lints/src/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn check_cond<'a, 'tcx, 'b>(
112112
None
113113
}
114114

115-
struct InsertVisitor<'a, 'tcx: 'a, 'b> {
115+
struct InsertVisitor<'a, 'tcx, 'b> {
116116
cx: &'a LateContext<'a, 'tcx>,
117117
span: Span,
118118
ty: &'static str,

clippy_lints/src/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn is_non_trait_box(ty: Ty<'_>) -> bool {
4343
ty.is_box() && !ty.boxed_ty().is_trait()
4444
}
4545

46-
struct EscapeDelegate<'a, 'tcx: 'a> {
46+
struct EscapeDelegate<'a, 'tcx> {
4747
cx: &'a LateContext<'a, 'tcx>,
4848
set: HirIdSet,
4949
too_large_for_stack: u64,

clippy_lints/src/eval_order_dependence.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
9292
}
9393
}
9494

95-
struct DivergenceVisitor<'a, 'tcx: 'a> {
95+
struct DivergenceVisitor<'a, 'tcx> {
9696
cx: &'a LateContext<'a, 'tcx>,
9797
}
9898

@@ -272,7 +272,7 @@ fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> St
272272
}
273273

274274
/// A visitor that looks for reads from a variable.
275-
struct ReadVisitor<'a, 'tcx: 'a> {
275+
struct ReadVisitor<'a, 'tcx> {
276276
cx: &'a LateContext<'a, 'tcx>,
277277
/// The ID of the variable we're looking for.
278278
var: HirId,

clippy_lints/src/fallible_impl_from.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
4949
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
5050
use rustc::hir::*;
5151

52-
struct FindPanicUnwrap<'a, 'tcx: 'a> {
52+
struct FindPanicUnwrap<'a, 'tcx> {
5353
lcx: &'a LateContext<'a, 'tcx>,
5454
tables: &'tcx ty::TypeckTables<'tcx>,
5555
result: Vec<Span>,
5656
}
5757

58-
impl<'a, 'tcx: 'a> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
58+
impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
5959
fn visit_expr(&mut self, expr: &'tcx Expr) {
6060
// check for `begin_panic`
6161
if_chain! {

0 commit comments

Comments
 (0)