@@ -594,33 +594,55 @@ pub enum Mutability {
594
594
595
595
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug , Copy ) ]
596
596
pub enum BinOp_ {
597
+ /// The `+` operator (addition)
597
598
BiAdd ,
599
+ /// The `-` operator (subtraction)
598
600
BiSub ,
601
+ /// The `*` operator (multiplication)
599
602
BiMul ,
603
+ /// The `/` operator (division)
600
604
BiDiv ,
605
+ /// The `%` operator (modulus)
601
606
BiRem ,
607
+ /// The `&&` operator (logical and)
602
608
BiAnd ,
609
+ /// The `||` operator (logical or)
603
610
BiOr ,
611
+ /// The `^` operator (bitwise xor)
604
612
BiBitXor ,
613
+ /// The `&` operator (bitwise and)
605
614
BiBitAnd ,
615
+ /// The `|` operator (bitwise or)
606
616
BiBitOr ,
617
+ /// The `<<` operator (shift left)
607
618
BiShl ,
619
+ /// The `>>` operator (shift right)
608
620
BiShr ,
621
+ /// The `==` operator (equality)
609
622
BiEq ,
623
+ /// The `<` operator (less than)
610
624
BiLt ,
625
+ /// The `<=` operator (less than or equal to)
611
626
BiLe ,
627
+ /// The `!=` operator (not equal to)
612
628
BiNe ,
629
+ /// The `>=` operator (greater than or equal to)
613
630
BiGe ,
631
+ /// The `>` operator (greater than)
614
632
BiGt ,
615
633
}
616
634
617
635
pub type BinOp = Spanned < BinOp_ > ;
618
636
619
637
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug , Copy ) ]
620
638
pub enum UnOp {
639
+ /// The `box` operator
621
640
UnUniq ,
641
+ /// The `*` operator for dereferencing
622
642
UnDeref ,
643
+ /// The `!` operator for logical inversion
623
644
UnNot ,
645
+ /// The `-` operator for negation
624
646
UnNeg
625
647
}
626
648
@@ -725,54 +747,101 @@ pub struct Expr {
725
747
pub enum Expr_ {
726
748
/// First expr is the place; second expr is the value.
727
749
ExprBox ( Option < P < Expr > > , P < Expr > ) ,
750
+ /// An array (`[a, b, c, d]`)
728
751
ExprVec ( Vec < P < Expr > > ) ,
752
+ /// A function cal
729
753
ExprCall ( P < Expr > , Vec < P < Expr > > ) ,
754
+ /// A method call (`x.foo::<Bar, Baz>(a, b, c, d)`)
755
+ /// The `SpannedIdent` is the identifier for the method name
756
+ /// The vector of `Ty`s are the ascripted type parameters for the method
757
+ /// (within the angle brackets)
758
+ /// The first element of the vector of `Expr`s is the expression that evaluates
759
+ /// to the object on which the method is being called on, and the remaining elements
760
+ /// are the arguments
730
761
ExprMethodCall ( SpannedIdent , Vec < P < Ty > > , Vec < P < Expr > > ) ,
762
+ /// A tuple (`(a, b, c ,d)`)
731
763
ExprTup ( Vec < P < Expr > > ) ,
764
+ /// A binary operation (For example: `a + b`, `a * b`)
732
765
ExprBinary ( BinOp , P < Expr > , P < Expr > ) ,
766
+ /// A unary operation (For example: `!x`, `*x`)
733
767
ExprUnary ( UnOp , P < Expr > ) ,
768
+ /// A literal (For example: `1u8`, `"foo"`)
734
769
ExprLit ( P < Lit > ) ,
770
+ /// A cast (`foo as f64`)
735
771
ExprCast ( P < Expr > , P < Ty > ) ,
772
+ /// An `if` block, with an optional else block
773
+ /// `if expr { block } else { expr }`
736
774
ExprIf ( P < Expr > , P < Block > , Option < P < Expr > > ) ,
775
+ /// An `if let` expression with an optional else block
776
+ /// `if let pat = expr { block } else { expr }`
777
+ /// This is desugared to a `match` expression
737
778
ExprIfLet ( P < Pat > , P < Expr > , P < Block > , Option < P < Expr > > ) ,
738
779
// FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
780
+ /// A while loop, with an optional label
781
+ /// `'label while expr { block }`
739
782
ExprWhile ( P < Expr > , P < Block > , Option < Ident > ) ,
740
783
// FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
784
+ /// A while-let loop, with an optional label
785
+ /// `'label while let pat = expr { block }`
786
+ /// This is desugared to a combination of `loop` and `match` expressions
741
787
ExprWhileLet ( P < Pat > , P < Expr > , P < Block > , Option < Ident > ) ,
742
788
// FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
789
+ /// A for loop, with an optional label
790
+ /// `'label for pat in expr { block }`
791
+ /// This is desugared to a combination of `loop` and `match` expressions
743
792
ExprForLoop ( P < Pat > , P < Expr > , P < Block > , Option < Ident > ) ,
744
- // Conditionless loop (can be exited with break, cont, or ret)
793
+ /// Conditionless loop (can be exited with break, cont, or ret)
794
+ /// `'label loop { block }`
745
795
// FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
746
796
ExprLoop ( P < Block > , Option < Ident > ) ,
797
+ /// A `match` block, with a desugar source
747
798
ExprMatch ( P < Expr > , Vec < Arm > , MatchSource ) ,
799
+ /// A closure (for example, `move |a, b, c| {a + b + c}`)
748
800
ExprClosure ( CaptureClause , P < FnDecl > , P < Block > ) ,
801
+ /// A block
749
802
ExprBlock ( P < Block > ) ,
750
803
804
+ /// An assignment (`a = foo()`)
751
805
ExprAssign ( P < Expr > , P < Expr > ) ,
806
+ /// An assignment with an operator
807
+ /// For example, `a += 1`
752
808
ExprAssignOp ( BinOp , P < Expr > , P < Expr > ) ,
809
+ /// Access of a named struct field (`obj.foo`)
753
810
ExprField ( P < Expr > , SpannedIdent ) ,
811
+ /// Access of an unnamed field of a struct or tuple-struct
812
+ /// For example, `foo.0`
754
813
ExprTupField ( P < Expr > , Spanned < usize > ) ,
814
+ /// An indexing operation (`foo[2]`)
755
815
ExprIndex ( P < Expr > , P < Expr > ) ,
816
+ /// A range (`[1..2]`, `[1..]`, or `[..2]`)
756
817
ExprRange ( Option < P < Expr > > , Option < P < Expr > > ) ,
757
818
758
819
/// Variable reference, possibly containing `::` and/or type
759
820
/// parameters, e.g. foo::bar::<baz>. Optionally "qualified",
760
821
/// e.g. `<Vec<T> as SomeTrait>::SomeType`.
761
822
ExprPath ( Option < QSelf > , Path ) ,
762
823
824
+ /// A referencing operation (`&a` or `&mut a`)
763
825
ExprAddrOf ( Mutability , P < Expr > ) ,
826
+ /// A `break`, with an optional label to break
764
827
ExprBreak ( Option < Ident > ) ,
828
+ /// A `continue`, with an optional label
765
829
ExprAgain ( Option < Ident > ) ,
830
+ /// A `return`, with an optional value to be returned
766
831
ExprRet ( Option < P < Expr > > ) ,
767
832
833
+ /// Output of the `asm!()` macro
768
834
ExprInlineAsm ( InlineAsm ) ,
769
835
836
+ /// A macro invocation; pre-expansion
770
837
ExprMac ( Mac ) ,
771
838
772
839
/// A struct literal expression.
840
+ /// For example, `Foo {x: 1, y: 2}`
773
841
ExprStruct ( Path , Vec < Field > , Option < P < Expr > > /* base */ ) ,
774
842
775
843
/// A vector literal constructed from one repeated element.
844
+ /// For example, `[u8; 5]`
776
845
ExprRepeat ( P < Expr > /* element */ , P < Expr > /* count */ ) ,
777
846
778
847
/// No-op: used solely so we can pretty-print faithfully
0 commit comments