|
10 | 10 |
|
11 | 11 | // The Rust abstract syntax tree. |
12 | 12 |
|
13 | | -pub use self::Pat_::*; |
14 | 13 | pub use self::StructFieldKind::*; |
15 | 14 | pub use self::TyParamBound::*; |
16 | 15 | pub use self::UnsafeSource::*; |
@@ -521,7 +520,7 @@ pub struct Block { |
521 | 520 | #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] |
522 | 521 | pub struct Pat { |
523 | 522 | pub id: NodeId, |
524 | | - pub node: Pat_, |
| 523 | + pub node: PatKind, |
525 | 524 | pub span: Span, |
526 | 525 | } |
527 | 526 |
|
@@ -552,47 +551,53 @@ pub enum BindingMode { |
552 | 551 | } |
553 | 552 |
|
554 | 553 | #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] |
555 | | -pub enum Pat_ { |
| 554 | +pub enum PatKind { |
556 | 555 | /// Represents a wildcard pattern (`_`) |
557 | | - PatWild, |
| 556 | + Wild, |
558 | 557 |
|
559 | | - /// A PatIdent may either be a new bound variable, |
560 | | - /// or a nullary enum (in which case the third field |
561 | | - /// is None). |
| 558 | + /// A `PatKind::Ident` may either be a new bound variable, |
| 559 | + /// or a unit struct/variant pattern, or a const pattern (in the last two cases |
| 560 | + /// the third field must be `None`). |
562 | 561 | /// |
563 | | - /// In the nullary enum case, the parser can't determine |
| 562 | + /// In the unit or const pattern case, the parser can't determine |
564 | 563 | /// which it is. The resolver determines this, and |
565 | | - /// records this pattern's NodeId in an auxiliary |
566 | | - /// set (of "PatIdents that refer to nullary enums") |
567 | | - PatIdent(BindingMode, SpannedIdent, Option<P<Pat>>), |
| 564 | + /// records this pattern's `NodeId` in an auxiliary |
| 565 | + /// set (of "PatIdents that refer to unit patterns or constants"). |
| 566 | + Ident(BindingMode, SpannedIdent, Option<P<Pat>>), |
568 | 567 |
|
| 568 | + /// A struct or struct variant pattern, e.g. `Variant {x, y, ..}`. |
| 569 | + /// The `bool` is `true` in the presence of a `..`. |
| 570 | + Struct(Path, Vec<Spanned<FieldPat>>, bool), |
| 571 | + |
| 572 | + /// A tuple struct/variant pattern `Variant(x, y, z)`. |
569 | 573 | /// "None" means a `Variant(..)` pattern where we don't bind the fields to names. |
570 | | - PatEnum(Path, Option<Vec<P<Pat>>>), |
| 574 | + TupleStruct(Path, Option<Vec<P<Pat>>>), |
| 575 | + |
| 576 | + /// A path pattern. |
| 577 | + /// Such pattern can be resolved to a unit struct/variant or a constant. |
| 578 | + Path(Path), |
571 | 579 |
|
572 | 580 | /// An associated const named using the qualified path `<T>::CONST` or |
573 | 581 | /// `<T as Trait>::CONST`. Associated consts from inherent impls can be |
574 | 582 | /// referred to as simply `T::CONST`, in which case they will end up as |
575 | | - /// PatEnum, and the resolver will have to sort that out. |
576 | | - PatQPath(QSelf, Path), |
| 583 | + /// PatKind::Enum, and the resolver will have to sort that out. |
| 584 | + QPath(QSelf, Path), |
577 | 585 |
|
578 | | - /// Destructuring of a struct, e.g. `Foo {x, y, ..}` |
579 | | - /// The `bool` is `true` in the presence of a `..` |
580 | | - PatStruct(Path, Vec<Spanned<FieldPat>>, bool), |
581 | 586 | /// A tuple pattern `(a, b)` |
582 | | - PatTup(Vec<P<Pat>>), |
| 587 | + Tup(Vec<P<Pat>>), |
583 | 588 | /// A `box` pattern |
584 | | - PatBox(P<Pat>), |
| 589 | + Box(P<Pat>), |
585 | 590 | /// A reference pattern, e.g. `&mut (a, b)` |
586 | | - PatRegion(P<Pat>, Mutability), |
| 591 | + Ref(P<Pat>, Mutability), |
587 | 592 | /// A literal |
588 | | - PatLit(P<Expr>), |
| 593 | + Lit(P<Expr>), |
589 | 594 | /// A range pattern, e.g. `1...2` |
590 | | - PatRange(P<Expr>, P<Expr>), |
| 595 | + Range(P<Expr>, P<Expr>), |
591 | 596 | /// `[a, b, ..i, y, z]` is represented as: |
592 | | - /// `PatVec(box [a, b], Some(i), box [y, z])` |
593 | | - PatVec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>), |
| 597 | + /// `PatKind::Vec(box [a, b], Some(i), box [y, z])` |
| 598 | + Vec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>), |
594 | 599 | /// A macro pattern; pre-expansion |
595 | | - PatMac(Mac), |
| 600 | + Mac(Mac), |
596 | 601 | } |
597 | 602 |
|
598 | 603 | #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] |
@@ -1609,7 +1614,7 @@ impl Arg { |
1609 | 1614 | }), |
1610 | 1615 | pat: P(Pat { |
1611 | 1616 | id: DUMMY_NODE_ID, |
1612 | | - node: PatIdent(BindingMode::ByValue(mutability), path, None), |
| 1617 | + node: PatKind::Ident(BindingMode::ByValue(mutability), path, None), |
1613 | 1618 | span: span |
1614 | 1619 | }), |
1615 | 1620 | id: DUMMY_NODE_ID |
|
0 commit comments