From dd612a000a6171d8a3911b8374ae4ac48406f9cd Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Fri, 20 Aug 2021 12:23:58 -0500 Subject: [PATCH] clippy: LetSource --- src/tools/clippy/clippy_lints/src/loops/never_loop.rs | 2 +- src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs | 2 +- src/tools/clippy/clippy_lints/src/utils/author.rs | 2 +- src/tools/clippy/clippy_lints/src/utils/inspector.rs | 2 +- src/tools/clippy/clippy_utils/src/higher.rs | 4 ++-- src/tools/clippy/clippy_utils/src/hir_utils.rs | 7 ++++--- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/loops/never_loop.rs b/src/tools/clippy/clippy_lints/src/loops/never_loop.rs index 2c46971d5f741..1c56e4a39b28c 100644 --- a/src/tools/clippy/clippy_lints/src/loops/never_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/never_loop.rs @@ -111,7 +111,7 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult { | ExprKind::Unary(_, e) | ExprKind::Cast(e, _) | ExprKind::Type(e, _) - | ExprKind::Let(_, e, _) + | ExprKind::Let(_, e, ..) | ExprKind::Field(e, _) | ExprKind::AddrOf(_, _, e) | ExprKind::Struct(_, _, Some(e)) diff --git a/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs b/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs index 35cff4141a903..217e87e317dd2 100644 --- a/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs +++ b/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs @@ -117,7 +117,7 @@ impl<'tcx> LateLintPass<'tcx> for PatternTypeMismatch { } } } - if let ExprKind::Let(let_pat, let_expr, _) = expr.kind { + if let ExprKind::Let(let_pat, let_expr, ..) = expr.kind { if let Some(ref expr_ty) = cx.typeck_results().node_type_opt(let_expr.hir_id) { if in_external_macro(cx.sess(), let_pat.span) { return; diff --git a/src/tools/clippy/clippy_lints/src/utils/author.rs b/src/tools/clippy/clippy_lints/src/utils/author.rs index f93d7782e2511..00670aec8d18f 100644 --- a/src/tools/clippy/clippy_lints/src/utils/author.rs +++ b/src/tools/clippy/clippy_lints/src/utils/author.rs @@ -208,7 +208,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { print!(" if let ExprKind::"); let current = format!("{}.kind", self.current); match expr.kind { - ExprKind::Let(pat, expr, _) => { + ExprKind::Let(pat, expr, ..) => { let let_pat = self.next("pat"); let let_expr = self.next("expr"); println!(" Let(ref {}, ref {}, _) = {};", let_pat, let_expr, current); diff --git a/src/tools/clippy/clippy_lints/src/utils/inspector.rs b/src/tools/clippy/clippy_lints/src/utils/inspector.rs index 6bf216cec1670..35403aa42a0df 100644 --- a/src/tools/clippy/clippy_lints/src/utils/inspector.rs +++ b/src/tools/clippy/clippy_lints/src/utils/inspector.rs @@ -142,7 +142,7 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) { print_expr(cx, arg, indent + 1); } }, - hir::ExprKind::Let(ref pat, ref expr, _) => { + hir::ExprKind::Let(ref pat, ref expr, ..) => { print_pat(cx, pat, indent + 1); print_expr(cx, expr, indent + 1); }, diff --git a/src/tools/clippy/clippy_utils/src/higher.rs b/src/tools/clippy/clippy_utils/src/higher.rs index 29b698e56e3c0..977348b50efed 100644 --- a/src/tools/clippy/clippy_utils/src/higher.rs +++ b/src/tools/clippy/clippy_utils/src/higher.rs @@ -90,7 +90,7 @@ impl<'hir> IfLet<'hir> { pub const fn hir(expr: &Expr<'hir>) -> Option { if let ExprKind::If( Expr { - kind: ExprKind::Let(let_pat, let_expr, _), + kind: ExprKind::Let(let_pat, let_expr, ..), .. }, if_then, @@ -329,7 +329,7 @@ impl<'hir> WhileLet<'hir> { kind: ExprKind::If( Expr { - kind: ExprKind::Let(let_pat, let_expr, _), + kind: ExprKind::Let(let_pat, let_expr, ..), .. }, if_then, diff --git a/src/tools/clippy/clippy_utils/src/hir_utils.rs b/src/tools/clippy/clippy_utils/src/hir_utils.rs index a44f2df2fd631..e66f12324c17e 100644 --- a/src/tools/clippy/clippy_utils/src/hir_utils.rs +++ b/src/tools/clippy/clippy_utils/src/hir_utils.rs @@ -232,8 +232,8 @@ impl HirEqInterExpr<'_, '_, '_> { (&ExprKind::If(lc, lt, ref le), &ExprKind::If(rc, rt, ref re)) => { self.eq_expr(lc, rc) && self.eq_expr(&**lt, &**rt) && both(le, re, |l, r| self.eq_expr(l, r)) }, - (&ExprKind::Let(ref lp, ref le, _), &ExprKind::Let(ref rp, ref re, _)) => { - self.eq_pat(lp, rp) && self.eq_expr(le, re) + (&ExprKind::Let(ref lp, ref le, _, ls), &ExprKind::Let(ref rp, ref re, _, rs)) => { + self.eq_pat(lp, rp) && self.eq_expr(le, re) && ls == rs }, (&ExprKind::Lit(ref l), &ExprKind::Lit(ref r)) => l.node == r.node, (&ExprKind::Loop(lb, ref ll, ref lls, _), &ExprKind::Loop(rb, ref rl, ref rls, _)) => { @@ -668,9 +668,10 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { } } }, - ExprKind::Let(ref pat, ref expr, _) => { + ExprKind::Let(ref pat, ref expr, _, source) => { self.hash_expr(expr); self.hash_pat(pat); + std::mem::discriminant(&source).hash(&mut self.s); }, ExprKind::LlvmInlineAsm(..) | ExprKind::Err => {}, ExprKind::Lit(ref l) => {