aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
authorgfreezy <[email protected]>2019-03-25 17:02:06 +0000
committergfreezy <[email protected]>2019-04-01 15:53:47 +0100
commit4ca51cfbcfe75b27c21bc269780992f55b4c6d84 (patch)
tree371c29b6c8537ba5e0c1062859e6da8c7dd777cc /crates/ra_syntax/src/ast
parent56f3524c693eed6a849f27139b6c8f32986ca4b8 (diff)
intelligently add parens when inlining local varaibles
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 4afe1a146..435d90116 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -715,6 +715,7 @@ pub enum ExprKind<'a> {
715 RangeExpr(&'a RangeExpr), 715 RangeExpr(&'a RangeExpr),
716 BinExpr(&'a BinExpr), 716 BinExpr(&'a BinExpr),
717 Literal(&'a Literal), 717 Literal(&'a Literal),
718 MacroCall(&'a MacroCall),
718} 719}
719impl<'a> From<&'a TupleExpr> for &'a Expr { 720impl<'a> From<&'a TupleExpr> for &'a Expr {
720 fn from(n: &'a TupleExpr) -> &'a Expr { 721 fn from(n: &'a TupleExpr) -> &'a Expr {
@@ -851,6 +852,11 @@ impl<'a> From<&'a Literal> for &'a Expr {
851 Expr::cast(&n.syntax).unwrap() 852 Expr::cast(&n.syntax).unwrap()
852 } 853 }
853} 854}
855impl<'a> From<&'a MacroCall> for &'a Expr {
856 fn from(n: &'a MacroCall) -> &'a Expr {
857 Expr::cast(&n.syntax).unwrap()
858 }
859}
854 860
855 861
856impl AstNode for Expr { 862impl AstNode for Expr {
@@ -882,7 +888,8 @@ impl AstNode for Expr {
882 | PREFIX_EXPR 888 | PREFIX_EXPR
883 | RANGE_EXPR 889 | RANGE_EXPR
884 | BIN_EXPR 890 | BIN_EXPR
885 | LITERAL => Some(Expr::from_repr(syntax.into_repr())), 891 | LITERAL
892 | MACRO_CALL => Some(Expr::from_repr(syntax.into_repr())),
886 _ => None, 893 _ => None,
887 } 894 }
888 } 895 }
@@ -924,6 +931,7 @@ impl Expr {
924 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()), 931 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()),
925 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()), 932 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()),
926 LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()), 933 LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()),
934 MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(&self.syntax).unwrap()),
927 _ => unreachable!(), 935 _ => unreachable!(),
928 } 936 }
929 } 937 }