about summary refs log tree commit diff
path: root/src
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 /src
parente1b71feb592ba64805689e2b15b9fa570182c442 (diff)
parent17f5c4d255323d331345ffe4cfebb959b1b5fa1a (diff)
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 'src')
-rw-r--r--src/test/ui/destructuring-assignment/struct-or-enum-variant-path.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/destructuring-assignment/struct-or-enum-variant-path.rs b/src/test/ui/destructuring-assignment/struct-or-enum-variant-path.rs
new file mode 100644
index 00000000000..8da7f90c524
--- /dev/null
+++ b/src/test/ui/destructuring-assignment/struct-or-enum-variant-path.rs
@@ -0,0 +1,34 @@
+// check-pass
+
+struct S;
+
+enum E {
+    V,
+}
+
+type A = E;
+
+fn main() {
+    let mut a;
+
+    (S, a) = (S, ());
+
+    (E::V, a) = (E::V, ());
+
+    (<E>::V, a) = (E::V, ());
+    (A::V, a) = (E::V, ());
+}
+
+impl S {
+    fn check() {
+        let a;
+        (Self, a) = (S, ());
+    }
+}
+
+impl E {
+    fn check() {
+        let a;
+        (Self::V, a) = (E::V, ());
+    }
+}