Skip to content

Commit fb4f603

Browse files
J-ZhengLisamueltardieuCentri3
committed
Apply suggestions from code review
Co-authored-by: Samuel Tardieu <sam@rfc1149.net> Co-authored-by: Catherine Flores <catherine.3.flores@gmail.com>
1 parent 22ba792 commit fb4f603

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

clippy_lints/src/option_if_let_else.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,9 @@ fn try_get_option_occurrence<'tcx>(
166166

167167
let mut app = Applicability::Unspecified;
168168

169-
let (none_body, is_argless_call) = if let Some(call_expr) = try_get_argless_call_expr(none_body) {
170-
(call_expr, true)
171-
} else {
172-
(none_body, false)
169+
let (none_body, is_argless_call) = match none_body.kind {
170+
ExprKind::Call(call_expr, []) if !none_body.span.from_expansion() => (call_expr, true),
171+
_ => (none_body, false),
173172
};
174173

175174
return Some(OptionOccurrence {
@@ -195,14 +194,6 @@ fn try_get_option_occurrence<'tcx>(
195194
None
196195
}
197196

198-
/// Gets the call expr iff it does not have any args and was not from macro expansion.
199-
fn try_get_argless_call_expr<'tcx>(expr: &Expr<'tcx>) -> Option<&'tcx Expr<'tcx>> {
200-
match expr.kind {
201-
ExprKind::Call(call_expr, []) if !expr.span.from_expansion() => Some(call_expr),
202-
_ => None,
203-
}
204-
}
205-
206197
fn try_get_inner_pat_and_is_result<'tcx>(cx: &LateContext<'tcx>, pat: &Pat<'tcx>) -> Option<(&'tcx Pat<'tcx>, bool)> {
207198
if let PatKind::TupleStruct(ref qpath, [inner_pat], ..) = pat.kind {
208199
let res = cx.qpath_res(qpath, pat.hir_id);

0 commit comments

Comments
 (0)