aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/adt.rs4
-rw-r--r--crates/ra_hir/src/code_model_impl/function.rs6
-rw-r--r--crates/ra_hir/src/expr.rs6
-rw-r--r--crates/ra_hir/src/type_ref.rs4
-rw-r--r--crates/ra_syntax/src/ast/generated.rs30
-rw-r--r--crates/ra_syntax/src/grammar.ron17
6 files changed, 24 insertions, 43 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs
index 6d917bb1b..325f1d7b6 100644
--- a/crates/ra_hir/src/adt.rs
+++ b/crates/ra_hir/src/adt.rs
@@ -6,7 +6,7 @@ use std::sync::Arc;
6use ra_arena::{RawId, Arena, impl_arena_id}; 6use ra_arena::{RawId, Arena, impl_arena_id};
7use ra_syntax::{ 7use ra_syntax::{
8 TreeArc, 8 TreeArc,
9 ast::{self, NameOwner, StructFlavor} 9 ast::{self, NameOwner, StructFlavor, TypeAscriptionOwner}
10}; 10};
11 11
12use crate::{ 12use crate::{
@@ -164,7 +164,7 @@ impl VariantData {
164 .fields() 164 .fields()
165 .map(|fd| StructFieldData { 165 .map(|fd| StructFieldData {
166 name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), 166 name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing),
167 type_ref: TypeRef::from_ast_opt(fd.type_ref()), 167 type_ref: TypeRef::from_ast_opt(fd.ascribed_type()),
168 }) 168 })
169 .collect(); 169 .collect();
170 VariantDataInner::Struct(fields) 170 VariantDataInner::Struct(fields)
diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs
index c401528c6..c1654b069 100644
--- a/crates/ra_hir/src/code_model_impl/function.rs
+++ b/crates/ra_hir/src/code_model_impl/function.rs
@@ -1,6 +1,6 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use ra_syntax::ast::{self, NameOwner}; 3use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
4 4
5use crate::{ 5use crate::{
6 Name, AsName, Function, FnSignature, 6 Name, AsName, Function, FnSignature,
@@ -19,7 +19,7 @@ impl FnSignature {
19 let mut has_self_param = false; 19 let mut has_self_param = false;
20 if let Some(param_list) = node.param_list() { 20 if let Some(param_list) = node.param_list() {
21 if let Some(self_param) = param_list.self_param() { 21 if let Some(self_param) = param_list.self_param() {
22 let self_type = if let Some(type_ref) = self_param.type_ref() { 22 let self_type = if let Some(type_ref) = self_param.ascribed_type() {
23 TypeRef::from_ast(type_ref) 23 TypeRef::from_ast(type_ref)
24 } else { 24 } else {
25 let self_type = TypeRef::Path(Name::self_type().into()); 25 let self_type = TypeRef::Path(Name::self_type().into());
@@ -37,7 +37,7 @@ impl FnSignature {
37 has_self_param = true; 37 has_self_param = true;
38 } 38 }
39 for param in param_list.params() { 39 for param in param_list.params() {
40 let type_ref = TypeRef::from_ast_opt(param.type_ref()); 40 let type_ref = TypeRef::from_ast_opt(param.ascribed_type());
41 params.push(type_ref); 41 params.push(type_ref);
42 } 42 }
43 } 43 }
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index e9db8282f..aa39d28ed 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -6,7 +6,7 @@ use rustc_hash::FxHashMap;
6use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; 6use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap};
7use ra_syntax::{ 7use ra_syntax::{
8 SyntaxNodePtr, AstNode, 8 SyntaxNodePtr, AstNode,
9 ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor} 9 ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor, TypeAscriptionOwner}
10}; 10};
11 11
12use crate::{ 12use crate::{
@@ -709,7 +709,7 @@ impl ExprCollector {
709 if let Some(pl) = e.param_list() { 709 if let Some(pl) = e.param_list() {
710 for param in pl.params() { 710 for param in pl.params() {
711 let pat = self.collect_pat_opt(param.pat()); 711 let pat = self.collect_pat_opt(param.pat());
712 let type_ref = param.type_ref().map(TypeRef::from_ast); 712 let type_ref = param.ascribed_type().map(TypeRef::from_ast);
713 args.push(pat); 713 args.push(pat);
714 arg_types.push(type_ref); 714 arg_types.push(type_ref);
715 } 715 }
@@ -790,7 +790,7 @@ impl ExprCollector {
790 .map(|s| match s.kind() { 790 .map(|s| match s.kind() {
791 ast::StmtKind::LetStmt(stmt) => { 791 ast::StmtKind::LetStmt(stmt) => {
792 let pat = self.collect_pat_opt(stmt.pat()); 792 let pat = self.collect_pat_opt(stmt.pat());
793 let type_ref = stmt.type_ref().map(TypeRef::from_ast); 793 let type_ref = stmt.ascribed_type().map(TypeRef::from_ast);
794 let initializer = stmt.initializer().map(|e| self.collect_expr(e)); 794 let initializer = stmt.initializer().map(|e| self.collect_expr(e));
795 Statement::Let { pat, type_ref, initializer } 795 Statement::Let { pat, type_ref, initializer }
796 } 796 }
diff --git a/crates/ra_hir/src/type_ref.rs b/crates/ra_hir/src/type_ref.rs
index ee8b7376a..8aa807648 100644
--- a/crates/ra_hir/src/type_ref.rs
+++ b/crates/ra_hir/src/type_ref.rs
@@ -1,7 +1,7 @@
1//! HIR for references to types. Paths in these are not yet resolved. They can 1//! HIR for references to types. Paths in these are not yet resolved. They can
2//! be directly created from an ast::TypeRef, without further queries. 2//! be directly created from an ast::TypeRef, without further queries.
3 3
4use ra_syntax::ast; 4use ra_syntax::ast::{self, TypeAscriptionOwner};
5 5
6use crate::Path; 6use crate::Path;
7 7
@@ -81,7 +81,7 @@ impl TypeRef {
81 FnPointerType(inner) => { 81 FnPointerType(inner) => {
82 let ret_ty = TypeRef::from_ast_opt(inner.ret_type().and_then(|rt| rt.type_ref())); 82 let ret_ty = TypeRef::from_ast_opt(inner.ret_type().and_then(|rt| rt.type_ref()));
83 let mut params = if let Some(pl) = inner.param_list() { 83 let mut params = if let Some(pl) = inner.param_list() {
84 pl.params().map(|p| p.type_ref()).map(TypeRef::from_ast_opt).collect() 84 pl.params().map(|p| p.ascribed_type()).map(TypeRef::from_ast_opt).collect()
85 } else { 85 } else {
86 Vec::new() 86 Vec::new()
87 }; 87 };
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 6db2f74ef..7572225b8 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -629,11 +629,7 @@ impl ast::TypeParamsOwner for ConstDef {}
629impl ast::AttrsOwner for ConstDef {} 629impl ast::AttrsOwner for ConstDef {}
630impl ast::DocCommentsOwner for ConstDef {} 630impl ast::DocCommentsOwner for ConstDef {}
631impl ast::TypeAscriptionOwner for ConstDef {} 631impl ast::TypeAscriptionOwner for ConstDef {}
632impl ConstDef { 632impl ConstDef {}
633 pub fn type_ref(&self) -> Option<&TypeRef> {
634 super::child_opt(self)
635 }
636}
637 633
638// ContinueExpr 634// ContinueExpr
639#[derive(Debug, PartialEq, Eq, Hash)] 635#[derive(Debug, PartialEq, Eq, Hash)]
@@ -1774,10 +1770,6 @@ impl LetStmt {
1774 super::child_opt(self) 1770 super::child_opt(self)
1775 } 1771 }
1776 1772
1777 pub fn type_ref(&self) -> Option<&TypeRef> {
1778 super::child_opt(self)
1779 }
1780
1781 pub fn initializer(&self) -> Option<&Expr> { 1773 pub fn initializer(&self) -> Option<&Expr> {
1782 super::child_opt(self) 1774 super::child_opt(self)
1783 } 1775 }
@@ -2595,11 +2587,7 @@ impl ast::NameOwner for NamedFieldDef {}
2595impl ast::AttrsOwner for NamedFieldDef {} 2587impl ast::AttrsOwner for NamedFieldDef {}
2596impl ast::DocCommentsOwner for NamedFieldDef {} 2588impl ast::DocCommentsOwner for NamedFieldDef {}
2597impl ast::TypeAscriptionOwner for NamedFieldDef {} 2589impl ast::TypeAscriptionOwner for NamedFieldDef {}
2598impl NamedFieldDef { 2590impl NamedFieldDef {}
2599 pub fn type_ref(&self) -> Option<&TypeRef> {
2600 super::child_opt(self)
2601 }
2602}
2603 2591
2604// NamedFieldDefList 2592// NamedFieldDefList
2605#[derive(Debug, PartialEq, Eq, Hash)] 2593#[derive(Debug, PartialEq, Eq, Hash)]
@@ -2782,10 +2770,6 @@ impl Param {
2782 pub fn pat(&self) -> Option<&Pat> { 2770 pub fn pat(&self) -> Option<&Pat> {
2783 super::child_opt(self) 2771 super::child_opt(self)
2784 } 2772 }
2785
2786 pub fn type_ref(&self) -> Option<&TypeRef> {
2787 super::child_opt(self)
2788 }
2789} 2773}
2790 2774
2791// ParamList 2775// ParamList
@@ -3691,10 +3675,6 @@ impl ToOwned for SelfParam {
3691 3675
3692impl ast::TypeAscriptionOwner for SelfParam {} 3676impl ast::TypeAscriptionOwner for SelfParam {}
3693impl SelfParam { 3677impl SelfParam {
3694 pub fn type_ref(&self) -> Option<&TypeRef> {
3695 super::child_opt(self)
3696 }
3697
3698 pub fn self_kw(&self) -> Option<&SelfKw> { 3678 pub fn self_kw(&self) -> Option<&SelfKw> {
3699 super::child_opt(self) 3679 super::child_opt(self)
3700 } 3680 }
@@ -3826,11 +3806,7 @@ impl ast::TypeParamsOwner for StaticDef {}
3826impl ast::AttrsOwner for StaticDef {} 3806impl ast::AttrsOwner for StaticDef {}
3827impl ast::DocCommentsOwner for StaticDef {} 3807impl ast::DocCommentsOwner for StaticDef {}
3828impl ast::TypeAscriptionOwner for StaticDef {} 3808impl ast::TypeAscriptionOwner for StaticDef {}
3829impl StaticDef { 3809impl StaticDef {}
3830 pub fn type_ref(&self) -> Option<&TypeRef> {
3831 super::child_opt(self)
3832 }
3833}
3834 3810
3835// Stmt 3811// Stmt
3836#[derive(Debug, PartialEq, Eq, Hash)] 3812#[derive(Debug, PartialEq, Eq, Hash)]
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index a3bfc74a7..b7a2d1c01 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -271,7 +271,15 @@ Grammar(
271 ] 271 ]
272 ), 272 ),
273 "NamedFieldDefList": (collections: [["fields", "NamedFieldDef"]]), 273 "NamedFieldDefList": (collections: [["fields", "NamedFieldDef"]]),
274 "NamedFieldDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeAscriptionOwner"], options: ["TypeRef"] ), 274 "NamedFieldDef": (
275 traits: [
276 "VisibilityOwner",
277 "NameOwner",
278 "AttrsOwner",
279 "DocCommentsOwner",
280 "TypeAscriptionOwner"
281 ]
282 ),
275 "PosFieldDefList": (collections: [["fields", "PosFieldDef"]]), 283 "PosFieldDefList": (collections: [["fields", "PosFieldDef"]]),
276 "PosFieldDef": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]), 284 "PosFieldDef": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]),
277 "EnumDef": ( traits: [ 285 "EnumDef": ( traits: [
@@ -301,7 +309,6 @@ Grammar(
301 "DocCommentsOwner", 309 "DocCommentsOwner",
302 "TypeAscriptionOwner", 310 "TypeAscriptionOwner",
303 ], 311 ],
304 options: ["TypeRef"]
305 ), 312 ),
306 "StaticDef": ( 313 "StaticDef": (
307 traits: [ 314 traits: [
@@ -312,7 +319,6 @@ Grammar(
312 "DocCommentsOwner", 319 "DocCommentsOwner",
313 "TypeAscriptionOwner", 320 "TypeAscriptionOwner",
314 ], 321 ],
315 options: ["TypeRef"]
316 ), 322 ),
317 "TypeAliasDef": ( 323 "TypeAliasDef": (
318 traits: [ 324 traits: [
@@ -574,7 +580,6 @@ Grammar(
574 "LetStmt": ( 580 "LetStmt": (
575 options: [ 581 options: [
576 ["pat", "Pat"], 582 ["pat", "Pat"],
577 ["type_ref", "TypeRef"],
578 ["initializer", "Expr"], 583 ["initializer", "Expr"],
579 ], 584 ],
580 traits: [ 585 traits: [
@@ -603,14 +608,14 @@ Grammar(
603 ] 608 ]
604 ), 609 ),
605 "SelfParam": ( 610 "SelfParam": (
606 options: ["TypeRef", "SelfKw"], 611 options: ["SelfKw"],
607 traits: [ 612 traits: [
608 "TypeAscriptionOwner", 613 "TypeAscriptionOwner",
609 ] 614 ]
610 ), 615 ),
611 "SelfKw": (), 616 "SelfKw": (),
612 "Param": ( 617 "Param": (
613 options: [ "Pat", "TypeRef" ], 618 options: [ "Pat" ],
614 traits: [ 619 traits: [
615 "TypeAscriptionOwner", 620 "TypeAscriptionOwner",
616 ] 621 ]