Apply suggestions from code review

Co-authored-by: Samuel Tardieu <sam@rfc1149.net>
Co-authored-by: Catherine Flores <catherine.3.flores@gmail.com>
This commit is contained in:
J-ZhengLi 2023-09-14 10:17:27 +08:00
parent 22ba7925d6
commit fb4f6035da

View File

@ -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);