mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 05:26:23 +03:00
Fix missing unused_variables lint when using a match guard
Within a binding pattern match guard, only real reads of a bound local impact its liveness analysis - not the fake read that is injected.
This commit is contained in:
@@ -85,7 +85,7 @@ impl LateLintPass<'_> for UncheckedTimeSubtraction {
|
||||
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) {
|
||||
let (lhs, rhs) = match expr.kind {
|
||||
ExprKind::Binary(op, lhs, rhs) if matches!(op.node, BinOpKind::Sub,) => (lhs, rhs),
|
||||
ExprKind::MethodCall(fn_name, lhs, [rhs], _) if cx.ty_based_def(expr).is_diag_item(cx, sym::sub) => {
|
||||
ExprKind::MethodCall(_, lhs, [rhs], _) if cx.ty_based_def(expr).is_diag_item(cx, sym::sub) => {
|
||||
(lhs, rhs)
|
||||
},
|
||||
_ => return,
|
||||
|
||||
Reference in New Issue
Block a user