aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-01 22:05:10 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-01 22:05:10 +0100
commit9282c6d3d03ac236a6d33b6f0a6ac076d0b11725 (patch)
tree371c29b6c8537ba5e0c1062859e6da8c7dd777cc /crates/ra_syntax/src
parent56f3524c693eed6a849f27139b6c8f32986ca4b8 (diff)
parent4ca51cfbcfe75b27c21bc269780992f55b4c6d84 (diff)
Merge #1050
1050: Intelligently add parens when inlining local varaibles r=matklad a=gfreezy fixed this. https://github.com/rust-analyzer/rust-analyzer/pull/1037#discussion_r268627141 Co-authored-by: gfreezy <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs10
-rw-r--r--crates/ra_syntax/src/grammar.ron1
2 files changed, 10 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 }
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index 6d7a5a1cb..3d97bea7f 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -494,6 +494,7 @@ Grammar(
494 "RangeExpr", 494 "RangeExpr",
495 "BinExpr", 495 "BinExpr",
496 "Literal", 496 "Literal",
497 "MacroCall",
497 ], 498 ],
498 ), 499 ),
499 500