Skip to content

Commit e94cd79

Browse files
authored
Unrolled build for #142740
Rollup merge of #142740 - ada4a:is-destruct-assignment-desugaring, r=fee1-dead Clean-up `FnCtxt::is_destruct_assignment_desugaring` I noticed the docstring thing and fixed that; then I thought I'd rewrite the method using let-chains while I'm at it, since that seemed appropriate. But I don't feel too strongly about the second change, so let me know if I should remove it
2 parents c2ec753 + fdb76e2 commit e94cd79

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,27 +1110,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11101110
}
11111111
}
11121112

1113-
// Returns whether the given expression is a destruct assignment desugaring.
1114-
// For example, `(a, b) = (1, &2);`
1115-
// Here we try to find the pattern binding of the expression,
1116-
// `default_binding_modes` is false only for destruct assignment desugaring.
1113+
/// Returns whether the given expression is a destruct assignment desugaring.
1114+
/// For example, `(a, b) = (1, &2);`
1115+
/// Here we try to find the pattern binding of the expression,
1116+
/// `default_binding_modes` is false only for destruct assignment desugaring.
11171117
pub(crate) fn is_destruct_assignment_desugaring(&self, expr: &hir::Expr<'_>) -> bool {
11181118
if let hir::ExprKind::Path(hir::QPath::Resolved(
11191119
_,
11201120
hir::Path { res: hir::def::Res::Local(bind_hir_id), .. },
11211121
)) = expr.kind
1122-
{
1123-
let bind = self.tcx.hir_node(*bind_hir_id);
1124-
let parent = self.tcx.parent_hir_node(*bind_hir_id);
1125-
if let hir::Node::Pat(hir::Pat {
1122+
&& let bind = self.tcx.hir_node(*bind_hir_id)
1123+
&& let parent = self.tcx.parent_hir_node(*bind_hir_id)
1124+
&& let hir::Node::Pat(hir::Pat {
11261125
kind: hir::PatKind::Binding(_, _hir_id, _, _), ..
11271126
}) = bind
1128-
&& let hir::Node::Pat(hir::Pat { default_binding_modes: false, .. }) = parent
1129-
{
1130-
return true;
1131-
}
1127+
&& let hir::Node::Pat(hir::Pat { default_binding_modes: false, .. }) = parent
1128+
{
1129+
true
1130+
} else {
1131+
false
11321132
}
1133-
false
11341133
}
11351134

11361135
fn explain_self_literal(

0 commit comments

Comments
 (0)