aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-24 14:40:11 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-24 14:40:11 +0000
commit67e768466ff2e2611eead0f30b2e9c4083c80c20 (patch)
tree8984028019837c91131fc30f60eecf8c2a457368 /crates/ra_syntax/src/ast
parentabe09eb5edfe8f4c58baa16140acbd414635836f (diff)
parent4befde1eee5b1e2b7ddc9bf764b77f82b792c318 (diff)
Merge #327
327: Beginnings of type inference r=flodiebold a=flodiebold I was a bit bored, so I thought I'd try to start implementing the type system and see how far I come :wink: This is obviously still extremely WIP, only very basic stuff working, but I thought I'd post this now to get some feedback as to whether this approach makes sense at all. There's no user-visible effect yet, but the type inference has tests similar to the ones for the parser. My next step will probably be to implement struct types, after which this could probably be used to complete fields. I realize this may all get thrown away when/if the compiler query system gets usable, but I feel like there are lots of IDE features that could be implemented with somewhat working type inference in the meantime :smile: Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs60
1 files changed, 52 insertions, 8 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index bf056131e..c73533861 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -523,7 +523,15 @@ impl<R: TreeRoot<RaTypes>> CastExprNode<R> {
523} 523}
524 524
525 525
526impl<'a> CastExpr<'a> {} 526impl<'a> CastExpr<'a> {
527 pub fn expr(self) -> Option<Expr<'a>> {
528 super::child_opt(self)
529 }
530
531 pub fn type_ref(self) -> Option<TypeRef<'a>> {
532 super::child_opt(self)
533 }
534}
527 535
528// Char 536// Char
529#[derive(Debug, Clone, Copy,)] 537#[derive(Debug, Clone, Copy,)]
@@ -1553,6 +1561,10 @@ impl<'a> LetStmt<'a> {
1553 super::child_opt(self) 1561 super::child_opt(self)
1554 } 1562 }
1555 1563
1564 pub fn type_ref(self) -> Option<TypeRef<'a>> {
1565 super::child_opt(self)
1566 }
1567
1556 pub fn initializer(self) -> Option<Expr<'a>> { 1568 pub fn initializer(self) -> Option<Expr<'a>> {
1557 super::child_opt(self) 1569 super::child_opt(self)
1558 } 1570 }
@@ -2312,6 +2324,10 @@ impl<'a> Param<'a> {
2312 pub fn pat(self) -> Option<Pat<'a>> { 2324 pub fn pat(self) -> Option<Pat<'a>> {
2313 super::child_opt(self) 2325 super::child_opt(self)
2314 } 2326 }
2327
2328 pub fn type_ref(self) -> Option<TypeRef<'a>> {
2329 super::child_opt(self)
2330 }
2315} 2331}
2316 2332
2317// ParamList 2333// ParamList
@@ -2394,7 +2410,11 @@ impl<R: TreeRoot<RaTypes>> ParenExprNode<R> {
2394} 2410}
2395 2411
2396 2412
2397impl<'a> ParenExpr<'a> {} 2413impl<'a> ParenExpr<'a> {
2414 pub fn expr(self) -> Option<Expr<'a>> {
2415 super::child_opt(self)
2416 }
2417}
2398 2418
2399// ParenType 2419// ParenType
2400#[derive(Debug, Clone, Copy,)] 2420#[derive(Debug, Clone, Copy,)]
@@ -2681,7 +2701,11 @@ impl<R: TreeRoot<RaTypes>> PathTypeNode<R> {
2681} 2701}
2682 2702
2683 2703
2684impl<'a> PathType<'a> {} 2704impl<'a> PathType<'a> {
2705 pub fn path(self) -> Option<Path<'a>> {
2706 super::child_opt(self)
2707 }
2708}
2685 2709
2686// PlaceholderPat 2710// PlaceholderPat
2687#[derive(Debug, Clone, Copy,)] 2711#[derive(Debug, Clone, Copy,)]
@@ -2829,7 +2853,11 @@ impl<R: TreeRoot<RaTypes>> PrefixExprNode<R> {
2829} 2853}
2830 2854
2831 2855
2832impl<'a> PrefixExpr<'a> {} 2856impl<'a> PrefixExpr<'a> {
2857 pub fn expr(self) -> Option<Expr<'a>> {
2858 super::child_opt(self)
2859 }
2860}
2833 2861
2834// RangeExpr 2862// RangeExpr
2835#[derive(Debug, Clone, Copy,)] 2863#[derive(Debug, Clone, Copy,)]
@@ -2940,7 +2968,11 @@ impl<R: TreeRoot<RaTypes>> RefExprNode<R> {
2940} 2968}
2941 2969
2942 2970
2943impl<'a> RefExpr<'a> {} 2971impl<'a> RefExpr<'a> {
2972 pub fn expr(self) -> Option<Expr<'a>> {
2973 super::child_opt(self)
2974 }
2975}
2944 2976
2945// RefPat 2977// RefPat
2946#[derive(Debug, Clone, Copy,)] 2978#[derive(Debug, Clone, Copy,)]
@@ -3051,7 +3083,11 @@ impl<R: TreeRoot<RaTypes>> RetTypeNode<R> {
3051} 3083}
3052 3084
3053 3085
3054impl<'a> RetType<'a> {} 3086impl<'a> RetType<'a> {
3087 pub fn type_ref(self) -> Option<TypeRef<'a>> {
3088 super::child_opt(self)
3089 }
3090}
3055 3091
3056// ReturnExpr 3092// ReturnExpr
3057#[derive(Debug, Clone, Copy,)] 3093#[derive(Debug, Clone, Copy,)]
@@ -3088,7 +3124,11 @@ impl<R: TreeRoot<RaTypes>> ReturnExprNode<R> {
3088} 3124}
3089 3125
3090 3126
3091impl<'a> ReturnExpr<'a> {} 3127impl<'a> ReturnExpr<'a> {
3128 pub fn expr(self) -> Option<Expr<'a>> {
3129 super::child_opt(self)
3130 }
3131}
3092 3132
3093// SelfParam 3133// SelfParam
3094#[derive(Debug, Clone, Copy,)] 3134#[derive(Debug, Clone, Copy,)]
@@ -3578,7 +3618,11 @@ impl<R: TreeRoot<RaTypes>> TryExprNode<R> {
3578} 3618}
3579 3619
3580 3620
3581impl<'a> TryExpr<'a> {} 3621impl<'a> TryExpr<'a> {
3622 pub fn expr(self) -> Option<Expr<'a>> {
3623 super::child_opt(self)
3624 }
3625}
3582 3626
3583// TupleExpr 3627// TupleExpr
3584#[derive(Debug, Clone, Copy,)] 3628#[derive(Debug, Clone, Copy,)]