about summary refs log tree commit diff
path: root/compiler/rustc_resolve
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-03 22:29:58 +0000
committerbors <bors@rust-lang.org>2022-05-03 22:29:58 +0000
commit1b2e0b60cc5aec81b48835bfc322c426e2f07cd1 (patch)
treea06695d136f1111824848671f84473bff2379264 /compiler/rustc_resolve
parente1b71feb592ba64805689e2b15b9fa570182c442 (diff)
parent17f5c4d255323d331345ffe4cfebb959b1b5fa1a (diff)
downloadrust-1b2e0b60cc5aec81b48835bfc322c426e2f07cd1.tar.gz
rust-1b2e0b60cc5aec81b48835bfc322c426e2f07cd1.zip
Auto merge of #95380 - compiler-errors:unit-destructure-assign, r=nikomatsakis
Fix unit struct/enum variant in destructuring assignment

See https://github.com/rust-lang/rfcs/blob/master/text/2909-destructuring-assignment.md#guide-level-explanation, "including **unit** and tuple structs"

Fixes #94319
Diffstat (limited to 'compiler/rustc_resolve')
-rw-r--r--compiler/rustc_resolve/src/late.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs
index ab353128cbc..3db4d4481b4 100644
--- a/compiler/rustc_resolve/src/late.rs
+++ b/compiler/rustc_resolve/src/late.rs
@@ -396,13 +396,10 @@ impl<'a> PathSource<'a> {
                 ) | Res::Local(..)
                     | Res::SelfCtor(..)
             ),
-            PathSource::Pat => matches!(
-                res,
-                Res::Def(
-                    DefKind::Ctor(_, CtorKind::Const) | DefKind::Const | DefKind::AssocConst,
-                    _,
-                ) | Res::SelfCtor(..)
-            ),
+            PathSource::Pat => {
+                res.expected_in_unit_struct_pat()
+                    || matches!(res, Res::Def(DefKind::Const | DefKind::AssocConst, _))
+            }
             PathSource::TupleStruct(..) => res.expected_in_tuple_struct_pat(),
             PathSource::Struct => matches!(
                 res,