aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/function.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/function.rs')
-rw-r--r--crates/ra_hir/src/function.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/crates/ra_hir/src/function.rs b/crates/ra_hir/src/function.rs
index 4627be071..81b790c5f 100644
--- a/crates/ra_hir/src/function.rs
+++ b/crates/ra_hir/src/function.rs
@@ -7,7 +7,7 @@ use std::{
7 7
8use ra_db::Cancelable; 8use ra_db::Cancelable;
9use ra_syntax::{ 9use ra_syntax::{
10 TextRange, TextUnit, 10 TextRange, TextUnit, TreePtr,
11 ast::{self, AstNode, DocCommentsOwner, NameOwner}, 11 ast::{self, AstNode, DocCommentsOwner, NameOwner},
12}; 12};
13 13
@@ -29,11 +29,11 @@ impl Function {
29 self.def_id 29 self.def_id
30 } 30 }
31 31
32 pub fn syntax(&self, db: &impl HirDatabase) -> ast::FnDefNode { 32 pub fn syntax(&self, db: &impl HirDatabase) -> TreePtr<ast::FnDef> {
33 let def_loc = self.def_id.loc(db); 33 let def_loc = self.def_id.loc(db);
34 assert!(def_loc.kind == DefKind::Function); 34 assert!(def_loc.kind == DefKind::Function);
35 let syntax = db.file_item(def_loc.source_item_id); 35 let syntax = db.file_item(def_loc.source_item_id);
36 ast::FnDef::cast(syntax.borrowed()).unwrap().owned() 36 ast::FnDef::cast(&syntax).unwrap().to_owned()
37 } 37 }
38 38
39 pub fn body(&self, db: &impl HirDatabase) -> Cancelable<Arc<Body>> { 39 pub fn body(&self, db: &impl HirDatabase) -> Cancelable<Arc<Body>> {
@@ -59,7 +59,7 @@ impl Function {
59 59
60 pub fn signature_info(&self, db: &impl HirDatabase) -> Option<FnSignatureInfo> { 60 pub fn signature_info(&self, db: &impl HirDatabase) -> Option<FnSignatureInfo> {
61 let syntax = self.syntax(db); 61 let syntax = self.syntax(db);
62 FnSignatureInfo::new(syntax.borrowed()) 62 FnSignatureInfo::new(&syntax)
63 } 63 }
64 64
65 pub fn infer(&self, db: &impl HirDatabase) -> Cancelable<Arc<InferenceResult>> { 65 pub fn infer(&self, db: &impl HirDatabase) -> Cancelable<Arc<InferenceResult>> {
@@ -99,8 +99,7 @@ impl FnSignature {
99 99
100pub(crate) fn fn_signature(db: &impl HirDatabase, def_id: DefId) -> Arc<FnSignature> { 100pub(crate) fn fn_signature(db: &impl HirDatabase, def_id: DefId) -> Arc<FnSignature> {
101 let func = Function::new(def_id); 101 let func = Function::new(def_id);
102 let syntax = func.syntax(db); 102 let node = func.syntax(db);
103 let node = syntax.borrowed();
104 let mut args = Vec::new(); 103 let mut args = Vec::new();
105 if let Some(param_list) = node.param_list() { 104 if let Some(param_list) = node.param_list() {
106 if let Some(self_param) = param_list.self_param() { 105 if let Some(self_param) = param_list.self_param() {
@@ -144,7 +143,7 @@ pub struct FnSignatureInfo {
144} 143}
145 144
146impl FnSignatureInfo { 145impl FnSignatureInfo {
147 fn new(node: ast::FnDef) -> Option<Self> { 146 fn new(node: &ast::FnDef) -> Option<Self> {
148 let name = node.name()?.text().to_string(); 147 let name = node.name()?.text().to_string();
149 148
150 let mut doc = None; 149 let mut doc = None;
@@ -207,7 +206,7 @@ impl FnSignatureInfo {
207 }) 206 })
208 } 207 }
209 208
210 fn extract_doc_comments(node: ast::FnDef) -> Option<(TextRange, String)> { 209 fn extract_doc_comments(node: &ast::FnDef) -> Option<(TextRange, String)> {
211 if node.doc_comments().count() == 0 { 210 if node.doc_comments().count() == 0 {
212 return None; 211 return None;
213 } 212 }
@@ -227,7 +226,7 @@ impl FnSignatureInfo {
227 Some((range, comment_text)) 226 Some((range, comment_text))
228 } 227 }
229 228
230 fn param_list(node: ast::FnDef) -> Vec<String> { 229 fn param_list(node: &ast::FnDef) -> Vec<String> {
231 let mut res = vec![]; 230 let mut res = vec![];
232 if let Some(param_list) = node.param_list() { 231 if let Some(param_list) = node.param_list() {
233 if let Some(self_param) = param_list.self_param() { 232 if let Some(self_param) = param_list.self_param() {