diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-06-22 17:35:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-22 17:35:34 +0200 |
| commit | a9a0753e96de8a7b4651d15bed2730725f69ae8b (patch) | |
| tree | b2d4863024508e288a517fd443f2afe3dad57751 /compiler | |
| parent | 7bed341583764c7469d6bad85440e74d7081c2b7 (diff) | |
| parent | fdb76e2296a0dbc4293b85137b75bd62d23f4008 (diff) | |
| download | rust-a9a0753e96de8a7b4651d15bed2730725f69ae8b.tar.gz rust-a9a0753e96de8a7b4651d15bed2730725f69ae8b.zip | |
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
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/demand.rs | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 5b55fbe9150..e5684f8cbe6 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -1110,27 +1110,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - // Returns whether the given expression is a destruct assignment desugaring. - // For example, `(a, b) = (1, &2);` - // Here we try to find the pattern binding of the expression, - // `default_binding_modes` is false only for destruct assignment desugaring. + /// Returns whether the given expression is a destruct assignment desugaring. + /// For example, `(a, b) = (1, &2);` + /// Here we try to find the pattern binding of the expression, + /// `default_binding_modes` is false only for destruct assignment desugaring. pub(crate) fn is_destruct_assignment_desugaring(&self, expr: &hir::Expr<'_>) -> bool { if let hir::ExprKind::Path(hir::QPath::Resolved( _, hir::Path { res: hir::def::Res::Local(bind_hir_id), .. }, )) = expr.kind - { - let bind = self.tcx.hir_node(*bind_hir_id); - let parent = self.tcx.parent_hir_node(*bind_hir_id); - if let hir::Node::Pat(hir::Pat { + && let bind = self.tcx.hir_node(*bind_hir_id) + && let parent = self.tcx.parent_hir_node(*bind_hir_id) + && let hir::Node::Pat(hir::Pat { kind: hir::PatKind::Binding(_, _hir_id, _, _), .. }) = bind - && let hir::Node::Pat(hir::Pat { default_binding_modes: false, .. }) = parent - { - return true; - } + && let hir::Node::Pat(hir::Pat { default_binding_modes: false, .. }) = parent + { + true + } else { + false } - false } fn explain_self_literal( |
