about summary refs log tree commit diff
path: root/compiler/rustc_hir/src
diff options
context:
space:
mode:
authorFabian Zaiser <fabian.zaiser@gmail.com>2020-11-07 14:28:55 +0000
committerFabian Zaiser <fabian.zaiser@gmail.com>2020-11-11 12:10:52 +0000
commitde84ad95b4b097e504171c7c606bf3715803c13b (patch)
tree79e31aeb6e1fa6c147157399446837511900dcfc /compiler/rustc_hir/src
parentcf9cf7c923eb01146971429044f216a3ca905e06 (diff)
downloadrust-de84ad95b4b097e504171c7c606bf3715803c13b.tar.gz
rust-de84ad95b4b097e504171c7c606bf3715803c13b.zip
Implement destructuring assignment for structs and slices
Co-authored-by: varkor <github@varkor.com>
Diffstat (limited to 'compiler/rustc_hir/src')
-rw-r--r--compiler/rustc_hir/src/def.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs
index 193247af584..298cfcc254c 100644
--- a/compiler/rustc_hir/src/def.rs
+++ b/compiler/rustc_hir/src/def.rs
@@ -484,4 +484,9 @@ impl<Id> Res<Id> {
     pub fn matches_ns(&self, ns: Namespace) -> bool {
         self.ns().map_or(true, |actual_ns| actual_ns == ns)
     }
+
+    /// Returns whether such a resolved path can occur in a tuple struct/variant pattern
+    pub fn expected_in_tuple_struct_pat(&self) -> bool {
+        matches!(self, Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) | Res::SelfCtor(..))
+    }
 }