X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftools%2Fclippy%2Fclippy_lints%2Fsrc%2Fbooleans.rs;h=32d0979e99b6071801f8de393d53fc14ec429354;hb=efad203144c25ba6f34e8e53d4c1a7417fb03c23;hp=f92c564543b89bd46aba72bc7646a09bc190a7e9;hpb=a25fbb971095391667e2ec1f05d0d579adb7f3e8;p=rust.git diff --git a/src/tools/clippy/clippy_lints/src/booleans.rs b/src/tools/clippy/clippy_lints/src/booleans.rs index f92c564543b..32d0979e99b 100644 --- a/src/tools/clippy/clippy_lints/src/booleans.rs +++ b/src/tools/clippy/clippy_lints/src/booleans.rs @@ -55,10 +55,10 @@ declare_lint_pass!(NonminimalBool => [NONMINIMAL_BOOL, LOGIC_BUG]); -impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonminimalBool { +impl<'tcx> LateLintPass<'tcx> for NonminimalBool { fn check_fn( &mut self, - cx: &LateContext<'a, 'tcx>, + cx: &LateContext<'tcx>, _: FnKind<'tcx>, _: &'tcx FnDecl<'_>, body: &'tcx Body<'_>, @@ -70,13 +70,13 @@ fn check_fn( } struct NonminimalBoolVisitor<'a, 'tcx> { - cx: &'a LateContext<'a, 'tcx>, + cx: &'a LateContext<'tcx>, } use quine_mc_cluskey::Bool; struct Hir2Qmm<'a, 'tcx, 'v> { terminals: Vec<&'v Expr<'v>>, - cx: &'a LateContext<'a, 'tcx>, + cx: &'a LateContext<'tcx>, } impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { @@ -155,7 +155,7 @@ fn negate(bin_op_kind: BinOpKind) -> Option { struct SuggestContext<'a, 'tcx, 'v> { terminals: &'v [&'v Expr<'v>], - cx: &'a LateContext<'a, 'tcx>, + cx: &'a LateContext<'tcx>, output: String, } @@ -222,7 +222,7 @@ fn recurse(&mut self, suggestion: &Bool) -> Option<()> { } } -fn simplify_not(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Option { +fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { match &expr.kind { ExprKind::Binary(binop, lhs, rhs) => { if !implements_ord(cx, lhs) { @@ -248,7 +248,7 @@ fn simplify_not(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Option { }) }, ExprKind::MethodCall(path, _, args, _) if args.len() == 1 => { - let type_of_receiver = cx.tables.expr_ty(&args[0]); + let type_of_receiver = cx.tables().expr_ty(&args[0]); if !is_type_diagnostic_item(cx, type_of_receiver, sym!(option_type)) && !is_type_diagnostic_item(cx, type_of_receiver, sym!(result_type)) { @@ -268,7 +268,7 @@ fn simplify_not(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Option { } } -fn suggest(cx: &LateContext<'_, '_>, suggestion: &Bool, terminals: &[&Expr<'_>]) -> String { +fn suggest(cx: &LateContext<'_>, suggestion: &Bool, terminals: &[&Expr<'_>]) -> String { let mut suggest_context = SuggestContext { terminals, cx, @@ -450,7 +450,7 @@ fn visit_expr(&mut self, e: &'tcx Expr<'_>) { self.bool_expr(e) }, ExprKind::Unary(UnOp::UnNot, inner) => { - if self.cx.tables.node_types()[inner.hir_id].is_bool() { + if self.cx.tables().node_types()[inner.hir_id].is_bool() { self.bool_expr(e); } else { walk_expr(self, e); @@ -464,13 +464,13 @@ fn nested_visit_map(&mut self) -> NestedVisitorMap { } } -fn implements_ord<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, expr: &Expr<'_>) -> bool { - let ty = cx.tables.expr_ty(expr); +fn implements_ord<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> bool { + let ty = cx.tables().expr_ty(expr); get_trait_def_id(cx, &paths::ORD).map_or(false, |id| implements_trait(cx, ty, id, &[])) } struct NotSimplificationVisitor<'a, 'tcx> { - cx: &'a LateContext<'a, 'tcx>, + cx: &'a LateContext<'tcx>, } impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {