about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-12-13 18:03:33 +0100
committerGitHub <noreply@github.com>2023-12-13 18:03:33 +0100
commitdbc6ec66368d8e15bfde166d7b505d66b9bd031f (patch)
treedbd6c76a25196ef3e1324c08e56d19c1f4cd20c3 /compiler/rustc_ast_lowering/src
parentc3def263a44e07e09ae6d57abfc8650227fb4972 (diff)
parentd473bdfdc3a2c377afd873abd4ace4244af80766 (diff)
downloadrust-dbc6ec66368d8e15bfde166d7b505d66b9bd031f.tar.gz
rust-dbc6ec66368d8e15bfde166d7b505d66b9bd031f.zip
Rollup merge of #118759 - compiler-errors:bare-unit-structs, r=petrochenkov
Support bare unit structs in destructuring assignments

We should be allowed to use destructuring assignments on *bare* unit structs, not just unit structs that are located within other pattern constructors.

Fixes #118753

r? petrochenkov since you reviewed #95380, reassign if you're busy or don't want to review this.
Diffstat (limited to 'compiler/rustc_ast_lowering/src')
-rw-r--r--compiler/rustc_ast_lowering/src/expr.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index a44b408feec..0bbdcb7f09e 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -1222,6 +1222,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
                 | ExprKind::Struct(..)
                 | ExprKind::Tup(..)
                 | ExprKind::Underscore => false,
+                // Check for unit struct constructor.
+                ExprKind::Path(..) => lower_ctx.extract_unit_struct_path(lhs).is_none(),
                 // Check for tuple struct constructor.
                 ExprKind::Call(callee, ..) => lower_ctx.extract_tuple_struct_path(callee).is_none(),
                 ExprKind::Paren(e) => {