Skip to content

Commit acb08e8

Browse files
committed
fall back to use if_chain
1 parent 5d73a2b commit acb08e8

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

clippy_lints/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(control_flow_enum)]
66
#![feature(drain_filter)]
77
#![feature(iter_intersperse)]
8-
#![feature(let_chains)]
98
#![feature(let_else)]
109
#![feature(once_cell)]
1110
#![feature(rustc_private)]

clippy_lints/src/question_mark.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,13 @@ impl QuestionMark {
155155

156156
/// Check whether the encountered expression contains `else if`
157157
fn expr_is_else_if(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
158-
if let ExprKind::If(..) = expr.kind
159-
&& let Some(parent_expr) = clippy_utils::get_parent_expr(cx, expr)
160-
&& let ExprKind::If(..) = parent_expr.kind
161-
{
162-
return true;
158+
if_chain! {
159+
if let ExprKind::If(..) = expr.kind;
160+
if let Some(parent_expr) = clippy_utils::get_parent_expr(cx, expr);
161+
if let ExprKind::If(..) = parent_expr.kind;
162+
then {
163+
return true;
164+
}
163165
}
164166
false
165167
}
@@ -245,16 +247,16 @@ impl QuestionMark {
245247
},
246248
ExprKind::Path(_) => path_to_local(expr).is_some() && path_to_local(expr) == path_to_local(cond_expr),
247249
ExprKind::Call(call_expr, args_expr) => {
248-
if let ExprKind::Path(qpath) = &call_expr.kind
249-
&& let QPath::Resolved(_, path) = qpath
250-
&& let Some(segment) = path.segments.first()
251-
&& let Some(pat_sym) = pat_symbol
252-
&& let Some(arg) = args_expr.first()
253-
&& let ExprKind::Path(arg_qpath) = &arg.kind
254-
&& let QPath::Resolved(_, arg_path) = arg_qpath
255-
&& let Some(PathSegment { ident, .. }) = arg_path.segments.first()
256-
{
257-
return segment.ident.name == sym::Err && pat_sym == ident.name
250+
if_chain! {
251+
if let ExprKind::Path(QPath::Resolved(_, path)) = &call_expr.kind;
252+
if let Some(segment) = path.segments.first();
253+
if let Some(pat_sym) = pat_symbol;
254+
if let Some(arg) = args_expr.first();
255+
if let ExprKind::Path(QPath::Resolved(_, arg_path)) = &arg.kind;
256+
if let Some(PathSegment { ident, .. }) = arg_path.segments.first();
257+
then {
258+
return segment.ident.name == sym::Err && pat_sym == ident.name;
259+
}
258260
}
259261

260262
false

0 commit comments

Comments
 (0)