Skip to content

Commit

Permalink
clippy: LetSource
Browse files Browse the repository at this point in the history
  • Loading branch information
camsteffen committed Aug 20, 2021
1 parent ea8dfd3 commit dd612a0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/loops/never_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/utils/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/utils/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_utils/src/higher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl<'hir> IfLet<'hir> {
pub const fn hir(expr: &Expr<'hir>) -> Option<Self> {
if let ExprKind::If(
Expr {
kind: ExprKind::Let(let_pat, let_expr, _),
kind: ExprKind::Let(let_pat, let_expr, ..),
..
},
if_then,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions src/tools/clippy/clippy_utils/src/hir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, _)) => {
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit dd612a0

Please sign in to comment.