@@ -429,23 +429,23 @@ impl MatchArm {
429429#[ derive( Clone , Debug , Eq , PartialEq , Hash ) ]
430430#[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
431431pub enum MatchPattern {
432- /// Bind inner value of left value to variable name .
433- Left ( Identifier , AliasedType ) ,
434- /// Bind inner value of right value to variable name .
435- Right ( Identifier , AliasedType ) ,
432+ /// Bind inner value of left value to a pattern .
433+ Left ( Pattern , AliasedType ) ,
434+ /// Bind inner value of right value to a pattern .
435+ Right ( Pattern , AliasedType ) ,
436436 /// Match none value (no binding).
437437 None ,
438- /// Bind inner value of some value to variable name .
439- Some ( Identifier , AliasedType ) ,
438+ /// Bind inner value of some value to a pattern .
439+ Some ( Pattern , AliasedType ) ,
440440 /// Match false value (no binding).
441441 False ,
442442 /// Match true value (no binding).
443443 True ,
444444}
445445
446446impl MatchPattern {
447- /// Access the identifier of a pattern that binds a variable .
448- pub fn as_variable ( & self ) -> Option < & Identifier > {
447+ /// Access the pattern of a match pattern that binds a variables .
448+ pub fn as_pattern ( & self ) -> Option < & Pattern > {
449449 match self {
450450 MatchPattern :: Left ( i, _) | MatchPattern :: Right ( i, _) | MatchPattern :: Some ( i, _) => {
451451 Some ( i)
@@ -454,8 +454,8 @@ impl MatchPattern {
454454 }
455455 }
456456
457- /// Access the identifier and the type of a pattern that binds a variable .
458- pub fn as_typed_variable ( & self ) -> Option < ( & Identifier , & AliasedType ) > {
457+ /// Access the pattern and the type of a match pattern that binds a variables .
458+ pub fn as_typed_pattern ( & self ) -> Option < ( & Pattern , & AliasedType ) > {
459459 match self {
460460 MatchPattern :: Left ( i, ty) | MatchPattern :: Right ( i, ty) | MatchPattern :: Some ( i, ty) => {
461461 Some ( ( i, ty) )
@@ -1623,17 +1623,17 @@ impl ChumskyParse for MatchPattern {
16231623 where
16241624 I : ValueInput < ' tokens , Token = Token < ' src > , Span = Span > ,
16251625 {
1626- let wrapper = |name : & ' static str , ctor : fn ( Identifier , AliasedType ) -> Self | {
1626+ let wrapper = |name : & ' static str , ctor : fn ( Pattern , AliasedType ) -> Self | {
16271627 select ! { Token :: Ident ( i) if i == name => i }
16281628 . ignore_then ( delimited_with_recovery (
1629- Identifier :: parser ( )
1629+ Pattern :: parser ( )
16301630 . then_ignore ( just ( Token :: Colon ) )
16311631 . then ( AliasedType :: parser ( ) ) ,
16321632 Token :: LParen ,
16331633 Token :: RParen ,
16341634 |_| {
16351635 (
1636- Identifier :: from_str_unchecked ( "" ) ,
1636+ Pattern :: Ignore ,
16371637 AliasedType :: alias ( AliasName :: from_str_unchecked ( "error" ) ) ,
16381638 )
16391639 } ,
@@ -2130,16 +2130,16 @@ impl crate::ArbitraryRec for Match {
21302130 let scrutinee = Expression :: arbitrary_rec ( u, budget) . map ( Arc :: new) ?;
21312131 let ( pat_l, pat_r) = match u. int_in_range ( 0 ..=2 ) ? {
21322132 0 => {
2133- let id_l = Identifier :: arbitrary ( u) ?;
2133+ let id_l = Pattern :: arbitrary ( u) ?;
21342134 let ty_l = AliasedType :: arbitrary ( u) ?;
21352135 let pat_l = MatchPattern :: Left ( id_l, ty_l) ;
2136- let id_r = Identifier :: arbitrary ( u) ?;
2136+ let id_r = Pattern :: arbitrary ( u) ?;
21372137 let ty_r = AliasedType :: arbitrary ( u) ?;
21382138 let pat_r = MatchPattern :: Right ( id_r, ty_r) ;
21392139 ( pat_l, pat_r)
21402140 }
21412141 1 => {
2142- let id_r = Identifier :: arbitrary ( u) ?;
2142+ let id_r = Pattern :: arbitrary ( u) ?;
21432143 let ty_r = AliasedType :: arbitrary ( u) ?;
21442144 let pat_r = MatchPattern :: Some ( id_r, ty_r) ;
21452145 ( MatchPattern :: None , pat_r)
0 commit comments