aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/call_info.rs4
-rw-r--r--crates/ra_ide_api/src/impls.rs8
-rw-r--r--crates/ra_ide_api/src/inlay_hints.rs22
-rw-r--r--crates/ra_ide_api/src/references.rs2
-rw-r--r--crates/ra_ide_api/src/runnables.rs4
5 files changed, 19 insertions, 21 deletions
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs
index 212448d41..d5e116526 100644
--- a/crates/ra_ide_api/src/call_info.rs
+++ b/crates/ra_ide_api/src/call_info.rs
@@ -91,8 +91,8 @@ impl FnCallNode {
91 91
92 fn name_ref(&self) -> Option<ast::NameRef> { 92 fn name_ref(&self) -> Option<ast::NameRef> {
93 match self { 93 match self {
94 FnCallNode::CallExpr(call_expr) => Some(match call_expr.expr()?.kind() { 94 FnCallNode::CallExpr(call_expr) => Some(match call_expr.expr()? {
95 ast::ExprKind::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?, 95 ast::Expr::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?,
96 _ => return None, 96 _ => return None,
97 }), 97 }),
98 98
diff --git a/crates/ra_ide_api/src/impls.rs b/crates/ra_ide_api/src/impls.rs
index 638f4cbde..c5620dd52 100644
--- a/crates/ra_ide_api/src/impls.rs
+++ b/crates/ra_ide_api/src/impls.rs
@@ -33,13 +33,11 @@ fn impls_for_def(
33 node: &ast::NominalDef, 33 node: &ast::NominalDef,
34 module: hir::Module, 34 module: hir::Module,
35) -> Option<Vec<NavigationTarget>> { 35) -> Option<Vec<NavigationTarget>> {
36 let ty = match node.kind() { 36 let ty = match node {
37 ast::NominalDefKind::StructDef(def) => { 37 ast::NominalDef::StructDef(def) => {
38 source_binder::struct_from_module(db, module, &def).ty(db) 38 source_binder::struct_from_module(db, module, &def).ty(db)
39 } 39 }
40 ast::NominalDefKind::EnumDef(def) => { 40 ast::NominalDef::EnumDef(def) => source_binder::enum_from_module(db, module, &def).ty(db),
41 source_binder::enum_from_module(db, module, &def).ty(db)
42 }
43 }; 41 };
44 42
45 let krate = module.krate(db)?; 43 let krate = module.krate(db)?;
diff --git a/crates/ra_ide_api/src/inlay_hints.rs b/crates/ra_ide_api/src/inlay_hints.rs
index 0b3c96d26..058cd68e2 100644
--- a/crates/ra_ide_api/src/inlay_hints.rs
+++ b/crates/ra_ide_api/src/inlay_hints.rs
@@ -3,7 +3,7 @@ use hir::{HirDisplay, SourceAnalyzer, Ty};
3use ra_syntax::{ 3use ra_syntax::{
4 algo::visit::{visitor, Visitor}, 4 algo::visit::{visitor, Visitor},
5 ast::{ 5 ast::{
6 AstNode, ForExpr, IfExpr, LambdaExpr, LetStmt, MatchArmList, Pat, PatKind, SourceFile, 6 self, AstNode, ForExpr, IfExpr, LambdaExpr, LetStmt, MatchArmList, SourceFile,
7 TypeAscriptionOwner, WhileExpr, 7 TypeAscriptionOwner, WhileExpr,
8 }, 8 },
9 SmolStr, SyntaxKind, SyntaxNode, TextRange, 9 SmolStr, SyntaxKind, SyntaxNode, TextRange,
@@ -88,7 +88,7 @@ fn get_inlay_hints(
88fn get_pat_type_hints( 88fn get_pat_type_hints(
89 db: &RootDatabase, 89 db: &RootDatabase,
90 analyzer: &SourceAnalyzer, 90 analyzer: &SourceAnalyzer,
91 root_pat: Pat, 91 root_pat: ast::Pat,
92 skip_root_pat_hint: bool, 92 skip_root_pat_hint: bool,
93) -> Vec<InlayHint> { 93) -> Vec<InlayHint> {
94 let original_pat = &root_pat.clone(); 94 let original_pat = &root_pat.clone();
@@ -108,27 +108,27 @@ fn get_pat_type_hints(
108 .collect() 108 .collect()
109} 109}
110 110
111fn get_leaf_pats(root_pat: Pat) -> Vec<Pat> { 111fn get_leaf_pats(root_pat: ast::Pat) -> Vec<ast::Pat> {
112 let mut pats_to_process = std::collections::VecDeque::<Pat>::new(); 112 let mut pats_to_process = std::collections::VecDeque::<ast::Pat>::new();
113 pats_to_process.push_back(root_pat); 113 pats_to_process.push_back(root_pat);
114 114
115 let mut leaf_pats = Vec::new(); 115 let mut leaf_pats = Vec::new();
116 116
117 while let Some(maybe_leaf_pat) = pats_to_process.pop_front() { 117 while let Some(maybe_leaf_pat) = pats_to_process.pop_front() {
118 match maybe_leaf_pat.kind() { 118 match &maybe_leaf_pat {
119 PatKind::BindPat(bind_pat) => { 119 ast::Pat::BindPat(bind_pat) => {
120 if let Some(pat) = bind_pat.pat() { 120 if let Some(pat) = bind_pat.pat() {
121 pats_to_process.push_back(pat); 121 pats_to_process.push_back(pat);
122 } else { 122 } else {
123 leaf_pats.push(maybe_leaf_pat); 123 leaf_pats.push(maybe_leaf_pat);
124 } 124 }
125 } 125 }
126 PatKind::TuplePat(tuple_pat) => { 126 ast::Pat::TuplePat(tuple_pat) => {
127 for arg_pat in tuple_pat.args() { 127 for arg_pat in tuple_pat.args() {
128 pats_to_process.push_back(arg_pat); 128 pats_to_process.push_back(arg_pat);
129 } 129 }
130 } 130 }
131 PatKind::StructPat(struct_pat) => { 131 ast::Pat::StructPat(struct_pat) => {
132 if let Some(pat_list) = struct_pat.field_pat_list() { 132 if let Some(pat_list) = struct_pat.field_pat_list() {
133 pats_to_process.extend( 133 pats_to_process.extend(
134 pat_list 134 pat_list
@@ -139,12 +139,12 @@ fn get_leaf_pats(root_pat: Pat) -> Vec<Pat> {
139 .filter(|pat| pat.syntax().kind() != SyntaxKind::BIND_PAT) 139 .filter(|pat| pat.syntax().kind() != SyntaxKind::BIND_PAT)
140 }) 140 })
141 .chain(pat_list.bind_pats().map(|bind_pat| { 141 .chain(pat_list.bind_pats().map(|bind_pat| {
142 bind_pat.pat().unwrap_or_else(|| Pat::from(bind_pat)) 142 bind_pat.pat().unwrap_or_else(|| ast::Pat::from(bind_pat))
143 })), 143 })),
144 ); 144 );
145 } 145 }
146 } 146 }
147 PatKind::TupleStructPat(tuple_struct_pat) => { 147 ast::Pat::TupleStructPat(tuple_struct_pat) => {
148 for arg_pat in tuple_struct_pat.args() { 148 for arg_pat in tuple_struct_pat.args() {
149 pats_to_process.push_back(arg_pat); 149 pats_to_process.push_back(arg_pat);
150 } 150 }
@@ -158,7 +158,7 @@ fn get_leaf_pats(root_pat: Pat) -> Vec<Pat> {
158fn get_node_displayable_type( 158fn get_node_displayable_type(
159 db: &RootDatabase, 159 db: &RootDatabase,
160 analyzer: &SourceAnalyzer, 160 analyzer: &SourceAnalyzer,
161 node_pat: &Pat, 161 node_pat: &ast::Pat,
162) -> Option<Ty> { 162) -> Option<Ty> {
163 analyzer.type_of_pat(db, node_pat).and_then(|resolved_type| { 163 analyzer.type_of_pat(db, node_pat).and_then(|resolved_type| {
164 if let Ty::Apply(_) = resolved_type { 164 if let Ty::Apply(_) = resolved_type {
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs
index 2118e7ad3..342e73fd3 100644
--- a/crates/ra_ide_api/src/references.rs
+++ b/crates/ra_ide_api/src/references.rs
@@ -75,7 +75,7 @@ pub(crate) fn find_all_refs(
75 let analyzer = hir::SourceAnalyzer::new(db, position.file_id, name_ref.syntax(), None); 75 let analyzer = hir::SourceAnalyzer::new(db, position.file_id, name_ref.syntax(), None);
76 let resolved = analyzer.resolve_local_name(&name_ref)?; 76 let resolved = analyzer.resolve_local_name(&name_ref)?;
77 if let Either::A(ptr) = resolved.ptr() { 77 if let Either::A(ptr) = resolved.ptr() {
78 if let ast::PatKind::BindPat(binding) = ptr.to_node(source_file.syntax()).kind() { 78 if let ast::Pat::BindPat(binding) = ptr.to_node(source_file.syntax()) {
79 return Some((binding, analyzer)); 79 return Some((binding, analyzer));
80 } 80 }
81 } 81 }
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs
index 09c082de9..9ea96909e 100644
--- a/crates/ra_ide_api/src/runnables.rs
+++ b/crates/ra_ide_api/src/runnables.rs
@@ -54,8 +54,8 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: ast::Module) -> Opti
54 let has_test_function = module 54 let has_test_function = module
55 .item_list()? 55 .item_list()?
56 .items() 56 .items()
57 .filter_map(|it| match it.kind() { 57 .filter_map(|it| match it {
58 ast::ModuleItemKind::FnDef(it) => Some(it), 58 ast::ModuleItem::FnDef(it) => Some(it),
59 _ => None, 59 _ => None,
60 }) 60 })
61 .any(|f| f.has_atom_attr("test")); 61 .any(|f| f.has_atom_attr("test"));