aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-06-28 21:04:00 +0100
committerPaul Daniel Faria <[email protected]>2020-08-10 13:44:54 +0100
commitc5cc24cb312c70159e63315ea49769b575e8cb65 (patch)
treefc2f5fe712e5776e0356c8e4f09135692a5ccc20 /crates/ra_hir_def
parentaca3d6c57ec2c668cdb51eca34d6f7bc8fa7412b (diff)
Revert function structs back to using bool to track self param, use first param for self information in syntax highlighting instead
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/data.rs6
-rw-r--r--crates/ra_hir_def/src/item_tree.rs8
-rw-r--r--crates/ra_hir_def/src/item_tree/lower.rs9
3 files changed, 7 insertions, 16 deletions
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs
index 2a26b0183..88a8ef9bf 100644
--- a/crates/ra_hir_def/src/data.rs
+++ b/crates/ra_hir_def/src/data.rs
@@ -10,7 +10,7 @@ use crate::{
10 attr::Attrs, 10 attr::Attrs,
11 body::Expander, 11 body::Expander,
12 db::DefDatabase, 12 db::DefDatabase,
13 item_tree::{AssocItem, ItemTreeId, ModItem, SelfParam}, 13 item_tree::{AssocItem, ItemTreeId, ModItem},
14 type_ref::{TypeBound, TypeRef}, 14 type_ref::{TypeBound, TypeRef},
15 visibility::RawVisibility, 15 visibility::RawVisibility,
16 AssocContainerId, AssocItemId, ConstId, ConstLoc, FunctionId, FunctionLoc, HasModule, ImplId, 16 AssocContainerId, AssocItemId, ConstId, ConstLoc, FunctionId, FunctionLoc, HasModule, ImplId,
@@ -25,7 +25,7 @@ pub struct FunctionData {
25 pub attrs: Attrs, 25 pub attrs: Attrs,
26 /// True if the first param is `self`. This is relevant to decide whether this 26 /// True if the first param is `self`. This is relevant to decide whether this
27 /// can be called as a method. 27 /// can be called as a method.
28 pub self_param: Option<SelfParam>, 28 pub has_self_param: bool,
29 pub is_unsafe: bool, 29 pub is_unsafe: bool,
30 pub is_varargs: bool, 30 pub is_varargs: bool,
31 pub visibility: RawVisibility, 31 pub visibility: RawVisibility,
@@ -42,7 +42,7 @@ impl FunctionData {
42 params: func.params.to_vec(), 42 params: func.params.to_vec(),
43 ret_type: func.ret_type.clone(), 43 ret_type: func.ret_type.clone(),
44 attrs: item_tree.attrs(ModItem::from(loc.id.value).into()).clone(), 44 attrs: item_tree.attrs(ModItem::from(loc.id.value).into()).clone(),
45 self_param: func.self_param, 45 has_self_param: func.has_self_param,
46 is_unsafe: func.is_unsafe, 46 is_unsafe: func.is_unsafe,
47 is_varargs: func.is_varargs, 47 is_varargs: func.is_varargs,
48 visibility: item_tree[func.visibility].clone(), 48 visibility: item_tree[func.visibility].clone(),
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs
index 1eaea66e4..a67e75dac 100644
--- a/crates/ra_hir_def/src/item_tree.rs
+++ b/crates/ra_hir_def/src/item_tree.rs
@@ -500,7 +500,7 @@ pub struct Function {
500 pub name: Name, 500 pub name: Name,
501 pub visibility: RawVisibilityId, 501 pub visibility: RawVisibilityId,
502 pub generic_params: GenericParamsId, 502 pub generic_params: GenericParamsId,
503 pub self_param: Option<SelfParam>, 503 pub has_self_param: bool,
504 pub is_unsafe: bool, 504 pub is_unsafe: bool,
505 pub params: Box<[TypeRef]>, 505 pub params: Box<[TypeRef]>,
506 pub is_varargs: bool, 506 pub is_varargs: bool,
@@ -508,12 +508,6 @@ pub struct Function {
508 pub ast_id: FileAstId<ast::Fn>, 508 pub ast_id: FileAstId<ast::Fn>,
509} 509}
510 510
511#[derive(Debug, Copy, Clone, Eq, PartialEq)]
512pub struct SelfParam {
513 pub is_ref: bool,
514 pub is_mut: bool,
515}
516
517#[derive(Debug, Clone, Eq, PartialEq)] 511#[derive(Debug, Clone, Eq, PartialEq)]
518pub struct Struct { 512pub struct Struct {
519 pub name: Name, 513 pub name: Name,
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs
index 89ad91d37..450ef8798 100644
--- a/crates/ra_hir_def/src/item_tree/lower.rs
+++ b/crates/ra_hir_def/src/item_tree/lower.rs
@@ -283,7 +283,7 @@ impl Ctx {
283 let name = func.name()?.as_name(); 283 let name = func.name()?.as_name();
284 284
285 let mut params = Vec::new(); 285 let mut params = Vec::new();
286 let mut func_self_param = None; 286 let mut has_self_param = false;
287 if let Some(param_list) = func.param_list() { 287 if let Some(param_list) = func.param_list() {
288 if let Some(self_param) = param_list.self_param() { 288 if let Some(self_param) = param_list.self_param() {
289 let self_type = match self_param.ty() { 289 let self_type = match self_param.ty() {
@@ -302,10 +302,7 @@ impl Ctx {
302 } 302 }
303 }; 303 };
304 params.push(self_type); 304 params.push(self_type);
305 func_self_param = Some(SelfParam { 305 has_self_param = true;
306 is_ref: self_param.amp_token().is_some(),
307 is_mut: self_param.mut_token().is_some(),
308 });
309 } 306 }
310 for param in param_list.params() { 307 for param in param_list.params() {
311 let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ty()); 308 let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ty());
@@ -338,7 +335,7 @@ impl Ctx {
338 name, 335 name,
339 visibility, 336 visibility,
340 generic_params: GenericParamsId::EMPTY, 337 generic_params: GenericParamsId::EMPTY,
341 self_param: func_self_param, 338 has_self_param,
342 is_unsafe: func.unsafe_token().is_some(), 339 is_unsafe: func.unsafe_token().is_some(),
343 params: params.into_boxed_slice(), 340 params: params.into_boxed_slice(),
344 is_varargs, 341 is_varargs,