From c0d8141930e95f71a6d4fb84114fdc8a449527b7 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 18 Aug 2016 21:40:06 +0800 Subject: All - Support tuple patterns with .. at the start/end - TODO: Support in the middle --- src/hir/pattern.hpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/hir/pattern.hpp') diff --git a/src/hir/pattern.hpp b/src/hir/pattern.hpp index 2a5ebb2a..13877dbc 100644 --- a/src/hir/pattern.hpp +++ b/src/hir/pattern.hpp @@ -57,13 +57,23 @@ struct Pattern }) ); friend ::std::ostream& operator<<(::std::ostream& os, const Pattern::Value& x); + + enum class GlobPos { + None, + Start, + End, + }; TAGGED_UNION(Data, Any, // Irrefutable / destructuring (Any, struct { } ), (Box, struct { ::std::unique_ptr sub; }), (Ref, struct { ::HIR::BorrowType type; ::std::unique_ptr sub; } ), - (Tuple, struct { ::std::vector sub_patterns; } ), + (Tuple, struct { + // NOTE: Has the glob still because the tuple isn't yet known + GlobPos glob_pos; + ::std::vector sub_patterns; + }), (StructValue, struct { GenericPath path; const Struct* binding; @@ -74,10 +84,6 @@ struct Pattern const Struct* binding; ::std::vector sub_patterns; } ), - (StructTupleWildcard, struct { - GenericPath path; - const Struct* binding; - }), (Struct, struct { GenericPath path; const Struct* binding; @@ -98,11 +104,6 @@ struct Pattern unsigned binding_idx; ::std::vector sub_patterns; } ), - (EnumTupleWildcard, struct { - GenericPath path; - const Enum* binding_ptr; - unsigned binding_idx; - } ), (EnumStruct, struct { GenericPath path; const Enum* binding_ptr; -- cgit v1.2.3