From 4ca51cfbcfe75b27c21bc269780992f55b4c6d84 Mon Sep 17 00:00:00 2001 From: gfreezy Date: Tue, 26 Mar 2019 01:02:06 +0800 Subject: intelligently add parens when inlining local varaibles --- crates/ra_syntax/src/ast/generated.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/ra_syntax/src/ast') 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> { RangeExpr(&'a RangeExpr), BinExpr(&'a BinExpr), Literal(&'a Literal), + MacroCall(&'a MacroCall), } impl<'a> From<&'a TupleExpr> for &'a Expr { fn from(n: &'a TupleExpr) -> &'a Expr { @@ -851,6 +852,11 @@ impl<'a> From<&'a Literal> for &'a Expr { Expr::cast(&n.syntax).unwrap() } } +impl<'a> From<&'a MacroCall> for &'a Expr { + fn from(n: &'a MacroCall) -> &'a Expr { + Expr::cast(&n.syntax).unwrap() + } +} impl AstNode for Expr { @@ -882,7 +888,8 @@ impl AstNode for Expr { | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR - | LITERAL => Some(Expr::from_repr(syntax.into_repr())), + | LITERAL + | MACRO_CALL => Some(Expr::from_repr(syntax.into_repr())), _ => None, } } @@ -924,6 +931,7 @@ impl Expr { RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()), BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()), LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()), + MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(&self.syntax).unwrap()), _ => unreachable!(), } } -- cgit v1.2.3