diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-18 21:40:06 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-18 21:40:06 +0800 |
commit | c0d8141930e95f71a6d4fb84114fdc8a449527b7 (patch) | |
tree | 828892e2cbee599bc15227ba3270f6ddc82d2581 /src/hir/pattern.hpp | |
parent | 65aba167033019994e35f43b819d8fbd3620e9ff (diff) | |
download | mrust-c0d8141930e95f71a6d4fb84114fdc8a449527b7.tar.gz |
All - Support tuple patterns with .. at the start/end - TODO: Support in the middle
Diffstat (limited to 'src/hir/pattern.hpp')
-rw-r--r-- | src/hir/pattern.hpp | 21 |
1 files changed, 11 insertions, 10 deletions
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<Pattern> sub; }), (Ref, struct { ::HIR::BorrowType type; ::std::unique_ptr<Pattern> sub; } ), - (Tuple, struct { ::std::vector<Pattern> sub_patterns; } ), + (Tuple, struct { + // NOTE: Has the glob still because the tuple isn't yet known + GlobPos glob_pos; + ::std::vector<Pattern> sub_patterns; + }), (StructValue, struct { GenericPath path; const Struct* binding; @@ -74,10 +84,6 @@ struct Pattern const Struct* binding; ::std::vector<Pattern> 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<Pattern> sub_patterns; } ), - (EnumTupleWildcard, struct { - GenericPath path; - const Enum* binding_ptr; - unsigned binding_idx; - } ), (EnumStruct, struct { GenericPath path; const Enum* binding_ptr; |