From 8e3e5ab2c81f238ea4e731f55eac79b74d9d84c3 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 5 Jan 2019 22:37:59 +0100 Subject: Make FnScopes use hir::Expr This was a bit complicated. I've added a wrapper type for now that does the LocalSyntaxPtr <-> ExprId translation; we might want to get rid of that or give it a nicer interface. --- crates/ra_syntax/src/ast/generated.rs | 25 +++++++++---------------- crates/ra_syntax/src/grammar.ron | 10 ++++------ 2 files changed, 13 insertions(+), 22 deletions(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index deb4dea88..24f72393a 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -927,12 +927,7 @@ pub enum Expr<'a> { BlockExpr(BlockExpr<'a>), ReturnExpr(ReturnExpr<'a>), MatchExpr(MatchExpr<'a>), - MatchArmList(MatchArmList<'a>), - MatchArm(MatchArm<'a>), - MatchGuard(MatchGuard<'a>), StructLit(StructLit<'a>), - NamedFieldList(NamedFieldList<'a>), - NamedField(NamedField<'a>), CallExpr(CallExpr<'a>), IndexExpr(IndexExpr<'a>), MethodCallExpr(MethodCallExpr<'a>), @@ -964,12 +959,7 @@ impl<'a> AstNode<'a> for Expr<'a> { BLOCK_EXPR => Some(Expr::BlockExpr(BlockExpr { syntax })), RETURN_EXPR => Some(Expr::ReturnExpr(ReturnExpr { syntax })), MATCH_EXPR => Some(Expr::MatchExpr(MatchExpr { syntax })), - MATCH_ARM_LIST => Some(Expr::MatchArmList(MatchArmList { syntax })), - MATCH_ARM => Some(Expr::MatchArm(MatchArm { syntax })), - MATCH_GUARD => Some(Expr::MatchGuard(MatchGuard { syntax })), STRUCT_LIT => Some(Expr::StructLit(StructLit { syntax })), - NAMED_FIELD_LIST => Some(Expr::NamedFieldList(NamedFieldList { syntax })), - NAMED_FIELD => Some(Expr::NamedField(NamedField { syntax })), CALL_EXPR => Some(Expr::CallExpr(CallExpr { syntax })), INDEX_EXPR => Some(Expr::IndexExpr(IndexExpr { syntax })), METHOD_CALL_EXPR => Some(Expr::MethodCallExpr(MethodCallExpr { syntax })), @@ -1001,12 +991,7 @@ impl<'a> AstNode<'a> for Expr<'a> { Expr::BlockExpr(inner) => inner.syntax(), Expr::ReturnExpr(inner) => inner.syntax(), Expr::MatchExpr(inner) => inner.syntax(), - Expr::MatchArmList(inner) => inner.syntax(), - Expr::MatchArm(inner) => inner.syntax(), - Expr::MatchGuard(inner) => inner.syntax(), Expr::StructLit(inner) => inner.syntax(), - Expr::NamedFieldList(inner) => inner.syntax(), - Expr::NamedField(inner) => inner.syntax(), Expr::CallExpr(inner) => inner.syntax(), Expr::IndexExpr(inner) => inner.syntax(), Expr::MethodCallExpr(inner) => inner.syntax(), @@ -4155,7 +4140,15 @@ impl> TupleStructPatNode { } -impl<'a> TupleStructPat<'a> {} +impl<'a> TupleStructPat<'a> { + pub fn args(self) -> impl Iterator> + 'a { + super::children(self) + } + + pub fn path(self) -> Option> { + super::child_opt(self) + } +} // TupleType #[derive(Debug, Clone, Copy,)] diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 5bcdf3f1d..3c640ed47 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -446,12 +446,7 @@ Grammar( "BlockExpr", "ReturnExpr", "MatchExpr", - "MatchArmList", - "MatchArm", - "MatchGuard", "StructLit", - "NamedFieldList", - "NamedField", "CallExpr", "IndexExpr", "MethodCallExpr", @@ -472,7 +467,10 @@ Grammar( "PathPat": (), "StructPat": (), "FieldPatList": (), - "TupleStructPat": (), + "TupleStructPat": ( + options: ["Path"], + collections: [["args", "Pat"]], + ), "TuplePat": (), "SlicePat": (), "RangePat": (), -- cgit v1.2.3