diff options
| author | J-ZhengLi <lizheng135@huawei.com> | 2023-09-14 10:17:27 +0800 |
|---|---|---|
| committer | J-ZhengLi <lizheng135@huawei.com> | 2023-09-14 10:17:27 +0800 |
| commit | fb4f6035da41ada636bef3a7eed1ec4dae72c606 (patch) | |
| tree | 59c42eae0daeb5cfe0b80b998becdb39ce63390a | |
| parent | 22ba7925d6e7b08fe84ff315b95e2bffd058275f (diff) | |
| download | rust-fb4f6035da41ada636bef3a7eed1ec4dae72c606.tar.gz rust-fb4f6035da41ada636bef3a7eed1ec4dae72c606.zip | |
Apply suggestions from code review
Co-authored-by: Samuel Tardieu <sam@rfc1149.net> Co-authored-by: Catherine Flores <catherine.3.flores@gmail.com>
| -rw-r--r-- | clippy_lints/src/option_if_let_else.rs | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/clippy_lints/src/option_if_let_else.rs b/clippy_lints/src/option_if_let_else.rs index f94dbb40be7..cfe40a829ed 100644 --- a/clippy_lints/src/option_if_let_else.rs +++ b/clippy_lints/src/option_if_let_else.rs @@ -166,10 +166,9 @@ fn try_get_option_occurrence<'tcx>( let mut app = Applicability::Unspecified; - let (none_body, is_argless_call) = if let Some(call_expr) = try_get_argless_call_expr(none_body) { - (call_expr, true) - } else { - (none_body, false) + let (none_body, is_argless_call) = match none_body.kind { + ExprKind::Call(call_expr, []) if !none_body.span.from_expansion() => (call_expr, true), + _ => (none_body, false), }; return Some(OptionOccurrence { @@ -195,14 +194,6 @@ fn try_get_option_occurrence<'tcx>( None } -/// Gets the call expr iff it does not have any args and was not from macro expansion. -fn try_get_argless_call_expr<'tcx>(expr: &Expr<'tcx>) -> Option<&'tcx Expr<'tcx>> { - match expr.kind { - ExprKind::Call(call_expr, []) if !expr.span.from_expansion() => Some(call_expr), - _ => None, - } -} - fn try_get_inner_pat_and_is_result<'tcx>(cx: &LateContext<'tcx>, pat: &Pat<'tcx>) -> Option<(&'tcx Pat<'tcx>, bool)> { if let PatKind::TupleStruct(ref qpath, [inner_pat], ..) = pat.kind { let res = cx.qpath_res(qpath, pat.hir_id); |
