This commit is contained in:
Manish Goregaokar 2021-09-27 22:33:45 -07:00
parent 17155c8dca
commit 13834e6ad2

View file

@ -47,13 +47,14 @@ declare_lint_pass!(MatchResultOk => [MATCH_RESULT_OK]);
impl<'tcx> LateLintPass<'tcx> for MatchResultOk { impl<'tcx> LateLintPass<'tcx> for MatchResultOk {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
let (let_pat, let_expr, ifwhile) = if let Some(higher::IfLet { let_pat, let_expr, .. }) = higher::IfLet::hir(cx, expr) { let (let_pat, let_expr, ifwhile) =
(let_pat, let_expr, "if") if let Some(higher::IfLet { let_pat, let_expr, .. }) = higher::IfLet::hir(cx, expr) {
} else if let Some(higher::WhileLet { let_pat, let_expr, .. }) = higher::WhileLet::hir(expr) { (let_pat, let_expr, "if")
(let_pat, let_expr, "while") } else if let Some(higher::WhileLet { let_pat, let_expr, .. }) = higher::WhileLet::hir(expr) {
} else { (let_pat, let_expr, "while")
return } else {
}; return;
};
if_chain! { if_chain! {
if let ExprKind::MethodCall(_, ok_span, [ref result_types_0, ..], _) = let_expr.kind; //check is expr.ok() has type Result<T,E>.ok(, _) if let ExprKind::MethodCall(_, ok_span, [ref result_types_0, ..], _) = let_expr.kind; //check is expr.ok() has type Result<T,E>.ok(, _)