diff options
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 46 | ||||
-rw-r--r-- | crates/ra_hir/src/db.rs | 16 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 25 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide_api/src/call_info.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/presentation.rs | 12 |
10 files changed, 66 insertions, 70 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 6602d1220..10f975b31 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -519,9 +519,8 @@ pub struct Function { | |||
519 | pub(crate) id: FunctionId, | 519 | pub(crate) id: FunctionId, |
520 | } | 520 | } |
521 | 521 | ||
522 | /// The declared signature of a function. | ||
523 | #[derive(Debug, Clone, PartialEq, Eq)] | 522 | #[derive(Debug, Clone, PartialEq, Eq)] |
524 | pub struct FnSignature { | 523 | pub struct FnData { |
525 | pub(crate) name: Name, | 524 | pub(crate) name: Name, |
526 | pub(crate) params: Vec<TypeRef>, | 525 | pub(crate) params: Vec<TypeRef>, |
527 | pub(crate) ret_type: TypeRef, | 526 | pub(crate) ret_type: TypeRef, |
@@ -530,11 +529,11 @@ pub struct FnSignature { | |||
530 | pub(crate) has_self_param: bool, | 529 | pub(crate) has_self_param: bool, |
531 | } | 530 | } |
532 | 531 | ||
533 | impl FnSignature { | 532 | impl FnData { |
534 | pub(crate) fn fn_signature_query( | 533 | pub(crate) fn fn_data_query( |
535 | db: &(impl DefDatabase + AstDatabase), | 534 | db: &(impl DefDatabase + AstDatabase), |
536 | func: Function, | 535 | func: Function, |
537 | ) -> Arc<FnSignature> { | 536 | ) -> Arc<FnData> { |
538 | let src = func.source(db); | 537 | let src = func.source(db); |
539 | let name = src.ast.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); | 538 | let name = src.ast.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); |
540 | let mut params = Vec::new(); | 539 | let mut params = Vec::new(); |
@@ -569,7 +568,7 @@ impl FnSignature { | |||
569 | TypeRef::unit() | 568 | TypeRef::unit() |
570 | }; | 569 | }; |
571 | 570 | ||
572 | let sig = FnSignature { name, params, ret_type, has_self_param }; | 571 | let sig = FnData { name, params, ret_type, has_self_param }; |
573 | Arc::new(sig) | 572 | Arc::new(sig) |
574 | } | 573 | } |
575 | pub fn name(&self) -> &Name { | 574 | pub fn name(&self) -> &Name { |
@@ -597,7 +596,7 @@ impl Function { | |||
597 | } | 596 | } |
598 | 597 | ||
599 | pub fn name(self, db: &impl HirDatabase) -> Name { | 598 | pub fn name(self, db: &impl HirDatabase) -> Name { |
600 | self.signature(db).name.clone() | 599 | self.data(db).name.clone() |
601 | } | 600 | } |
602 | 601 | ||
603 | pub(crate) fn body_source_map(self, db: &impl HirDatabase) -> Arc<BodySourceMap> { | 602 | pub(crate) fn body_source_map(self, db: &impl HirDatabase) -> Arc<BodySourceMap> { |
@@ -612,8 +611,8 @@ impl Function { | |||
612 | db.type_for_def(self.into(), Namespace::Values) | 611 | db.type_for_def(self.into(), Namespace::Values) |
613 | } | 612 | } |
614 | 613 | ||
615 | pub fn signature(self, db: &impl HirDatabase) -> Arc<FnSignature> { | 614 | pub fn data(self, db: &impl HirDatabase) -> Arc<FnData> { |
616 | db.fn_signature(self) | 615 | db.fn_data(self) |
617 | } | 616 | } |
618 | 617 | ||
619 | pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> { | 618 | pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> { |
@@ -670,8 +669,8 @@ impl Const { | |||
670 | self.id.module(db) | 669 | self.id.module(db) |
671 | } | 670 | } |
672 | 671 | ||
673 | pub fn signature(self, db: &impl HirDatabase) -> Arc<ConstSignature> { | 672 | pub fn data(self, db: &impl HirDatabase) -> Arc<ConstData> { |
674 | db.const_signature(self) | 673 | db.const_data(self) |
675 | } | 674 | } |
676 | 675 | ||
677 | pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> { | 676 | pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> { |
@@ -696,14 +695,13 @@ impl Const { | |||
696 | } | 695 | } |
697 | } | 696 | } |
698 | 697 | ||
699 | /// The declared signature of a const. | ||
700 | #[derive(Debug, Clone, PartialEq, Eq)] | 698 | #[derive(Debug, Clone, PartialEq, Eq)] |
701 | pub struct ConstSignature { | 699 | pub struct ConstData { |
702 | pub(crate) name: Name, | 700 | pub(crate) name: Name, |
703 | pub(crate) type_ref: TypeRef, | 701 | pub(crate) type_ref: TypeRef, |
704 | } | 702 | } |
705 | 703 | ||
706 | impl ConstSignature { | 704 | impl ConstData { |
707 | pub fn name(&self) -> &Name { | 705 | pub fn name(&self) -> &Name { |
708 | &self.name | 706 | &self.name |
709 | } | 707 | } |
@@ -712,27 +710,27 @@ impl ConstSignature { | |||
712 | &self.type_ref | 710 | &self.type_ref |
713 | } | 711 | } |
714 | 712 | ||
715 | pub(crate) fn const_signature_query( | 713 | pub(crate) fn const_data_query( |
716 | db: &(impl DefDatabase + AstDatabase), | 714 | db: &(impl DefDatabase + AstDatabase), |
717 | konst: Const, | 715 | konst: Const, |
718 | ) -> Arc<ConstSignature> { | 716 | ) -> Arc<ConstData> { |
719 | let node = konst.source(db).ast; | 717 | let node = konst.source(db).ast; |
720 | const_signature_for(&*node) | 718 | const_data_for(&*node) |
721 | } | 719 | } |
722 | 720 | ||
723 | pub(crate) fn static_signature_query( | 721 | pub(crate) fn static_data_query( |
724 | db: &(impl DefDatabase + AstDatabase), | 722 | db: &(impl DefDatabase + AstDatabase), |
725 | konst: Static, | 723 | konst: Static, |
726 | ) -> Arc<ConstSignature> { | 724 | ) -> Arc<ConstData> { |
727 | let node = konst.source(db).ast; | 725 | let node = konst.source(db).ast; |
728 | const_signature_for(&*node) | 726 | const_data_for(&*node) |
729 | } | 727 | } |
730 | } | 728 | } |
731 | 729 | ||
732 | fn const_signature_for<N: NameOwner + TypeAscriptionOwner>(node: &N) -> Arc<ConstSignature> { | 730 | fn const_data_for<N: NameOwner + TypeAscriptionOwner>(node: &N) -> Arc<ConstData> { |
733 | let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); | 731 | let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); |
734 | let type_ref = TypeRef::from_ast_opt(node.ascribed_type()); | 732 | let type_ref = TypeRef::from_ast_opt(node.ascribed_type()); |
735 | let sig = ConstSignature { name, type_ref }; | 733 | let sig = ConstData { name, type_ref }; |
736 | Arc::new(sig) | 734 | Arc::new(sig) |
737 | } | 735 | } |
738 | 736 | ||
@@ -746,8 +744,8 @@ impl Static { | |||
746 | self.id.module(db) | 744 | self.id.module(db) |
747 | } | 745 | } |
748 | 746 | ||
749 | pub fn signature(self, db: &impl HirDatabase) -> Arc<ConstSignature> { | 747 | pub fn data(self, db: &impl HirDatabase) -> Arc<ConstData> { |
750 | db.static_signature(self) | 748 | db.static_data(self) |
751 | } | 749 | } |
752 | 750 | ||
753 | /// Builds a resolver for code inside this item. | 751 | /// Builds a resolver for code inside this item. |
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index c4dd54596..23c36014b 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -6,9 +6,9 @@ use ra_db::{SourceDatabase, salsa}; | |||
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | HirFileId, MacroDefId, AstIdMap, ErasedFileAstId, Crate, Module, MacroCallLoc, | 8 | HirFileId, MacroDefId, AstIdMap, ErasedFileAstId, Crate, Module, MacroCallLoc, |
9 | Function, FnSignature, ExprScopes, TypeAlias, | 9 | Function, FnData, ExprScopes, TypeAlias, |
10 | Struct, Enum, StructField, | 10 | Struct, Enum, StructField, |
11 | Const, ConstSignature, Static, | 11 | Const, ConstData, Static, |
12 | DefWithBody, Trait, | 12 | DefWithBody, Trait, |
13 | ids, | 13 | ids, |
14 | nameres::{Namespace, ImportSourceMap, RawItems, CrateDefMap}, | 14 | nameres::{Namespace, ImportSourceMap, RawItems, CrateDefMap}, |
@@ -109,17 +109,17 @@ pub trait DefDatabase: SourceDatabase { | |||
109 | #[salsa::invoke(crate::generics::GenericParams::generic_params_query)] | 109 | #[salsa::invoke(crate::generics::GenericParams::generic_params_query)] |
110 | fn generic_params(&self, def: GenericDef) -> Arc<GenericParams>; | 110 | fn generic_params(&self, def: GenericDef) -> Arc<GenericParams>; |
111 | 111 | ||
112 | #[salsa::invoke(crate::FnSignature::fn_signature_query)] | 112 | #[salsa::invoke(crate::FnData::fn_data_query)] |
113 | fn fn_signature(&self, func: Function) -> Arc<FnSignature>; | 113 | fn fn_data(&self, func: Function) -> Arc<FnData>; |
114 | 114 | ||
115 | #[salsa::invoke(crate::type_alias::type_alias_data_query)] | 115 | #[salsa::invoke(crate::type_alias::type_alias_data_query)] |
116 | fn type_alias_data(&self, typ: TypeAlias) -> Arc<TypeAliasData>; | 116 | fn type_alias_data(&self, typ: TypeAlias) -> Arc<TypeAliasData>; |
117 | 117 | ||
118 | #[salsa::invoke(crate::ConstSignature::const_signature_query)] | 118 | #[salsa::invoke(crate::ConstData::const_data_query)] |
119 | fn const_signature(&self, konst: Const) -> Arc<ConstSignature>; | 119 | fn const_data(&self, konst: Const) -> Arc<ConstData>; |
120 | 120 | ||
121 | #[salsa::invoke(crate::ConstSignature::static_signature_query)] | 121 | #[salsa::invoke(crate::ConstData::static_data_query)] |
122 | fn static_signature(&self, konst: Static) -> Arc<ConstSignature>; | 122 | fn static_data(&self, konst: Static) -> Arc<ConstData>; |
123 | 123 | ||
124 | #[salsa::invoke(crate::lang_item::LangItems::lang_items_query)] | 124 | #[salsa::invoke(crate::lang_item::LangItems::lang_items_query)] |
125 | fn lang_items(&self, krate: Crate) -> Arc<LangItems>; | 125 | fn lang_items(&self, krate: Crate) -> Arc<LangItems>; |
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 2e99bdac8..f07a36926 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -75,9 +75,9 @@ pub use self::code_model::{ | |||
75 | DefWithBody, | 75 | DefWithBody, |
76 | Module, ModuleDef, ModuleSource, | 76 | Module, ModuleDef, ModuleSource, |
77 | Struct, Union, Enum, EnumVariant, | 77 | Struct, Union, Enum, EnumVariant, |
78 | Function, FnSignature, | 78 | Function, FnData, |
79 | StructField, FieldSource, | 79 | StructField, FieldSource, |
80 | Static, Const, ConstSignature, | 80 | Static, Const, ConstData, |
81 | Trait, TypeAlias, MacroDef, Container, | 81 | Trait, TypeAlias, MacroDef, Container, |
82 | BuiltinType, | 82 | BuiltinType, |
83 | src::{Source, HasSource}, | 83 | src::{Source, HasSource}, |
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 1ee40c70a..2c05ca734 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -27,7 +27,7 @@ use ra_prof::profile; | |||
27 | use test_utils::tested_by; | 27 | use test_utils::tested_by; |
28 | 28 | ||
29 | use crate::{ | 29 | use crate::{ |
30 | Function, StructField, Path, Name, FnSignature, AdtDef, ConstSignature, HirDatabase, | 30 | Function, StructField, Path, Name, FnData, AdtDef, ConstData, HirDatabase, |
31 | DefWithBody, ImplItem, | 31 | DefWithBody, ImplItem, |
32 | type_ref::{TypeRef, Mutability}, | 32 | type_ref::{TypeRef, Mutability}, |
33 | expr::{ | 33 | expr::{ |
@@ -59,9 +59,9 @@ pub fn infer_query(db: &impl HirDatabase, def: DefWithBody) -> Arc<InferenceResu | |||
59 | let mut ctx = InferenceContext::new(db, body, resolver); | 59 | let mut ctx = InferenceContext::new(db, body, resolver); |
60 | 60 | ||
61 | match def { | 61 | match def { |
62 | DefWithBody::Const(ref c) => ctx.collect_const_signature(&c.signature(db)), | 62 | DefWithBody::Const(ref c) => ctx.collect_const(&c.data(db)), |
63 | DefWithBody::Function(ref f) => ctx.collect_fn_signature(&f.signature(db)), | 63 | DefWithBody::Function(ref f) => ctx.collect_fn(&f.data(db)), |
64 | DefWithBody::Static(ref s) => ctx.collect_const_signature(&s.signature(db)), | 64 | DefWithBody::Static(ref s) => ctx.collect_const(&s.data(db)), |
65 | } | 65 | } |
66 | 66 | ||
67 | ctx.infer_body(); | 67 | ctx.infer_body(); |
@@ -509,8 +509,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
509 | let item: crate::ModuleDef = ty.iterate_impl_items(self.db, krate, |item| { | 509 | let item: crate::ModuleDef = ty.iterate_impl_items(self.db, krate, |item| { |
510 | let matching_def: Option<crate::ModuleDef> = match item { | 510 | let matching_def: Option<crate::ModuleDef> = match item { |
511 | crate::ImplItem::Method(func) => { | 511 | crate::ImplItem::Method(func) => { |
512 | let sig = func.signature(self.db); | 512 | if segment.name == func.name(self.db) { |
513 | if segment.name == *sig.name() { | ||
514 | Some(func.into()) | 513 | Some(func.into()) |
515 | } else { | 514 | } else { |
516 | None | 515 | None |
@@ -518,8 +517,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
518 | } | 517 | } |
519 | 518 | ||
520 | crate::ImplItem::Const(konst) => { | 519 | crate::ImplItem::Const(konst) => { |
521 | let sig = konst.signature(self.db); | 520 | let data = konst.data(self.db); |
522 | if segment.name == *sig.name() { | 521 | if segment.name == *data.name() { |
523 | Some(konst.into()) | 522 | Some(konst.into()) |
524 | } else { | 523 | } else { |
525 | None | 524 | None |
@@ -1283,18 +1282,18 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1283 | ty | 1282 | ty |
1284 | } | 1283 | } |
1285 | 1284 | ||
1286 | fn collect_const_signature(&mut self, signature: &ConstSignature) { | 1285 | fn collect_const(&mut self, data: &ConstData) { |
1287 | self.return_ty = self.make_ty(signature.type_ref()); | 1286 | self.return_ty = self.make_ty(data.type_ref()); |
1288 | } | 1287 | } |
1289 | 1288 | ||
1290 | fn collect_fn_signature(&mut self, signature: &FnSignature) { | 1289 | fn collect_fn(&mut self, data: &FnData) { |
1291 | let body = Arc::clone(&self.body); // avoid borrow checker problem | 1290 | let body = Arc::clone(&self.body); // avoid borrow checker problem |
1292 | for (type_ref, pat) in signature.params().iter().zip(body.params()) { | 1291 | for (type_ref, pat) in data.params().iter().zip(body.params()) { |
1293 | let ty = self.make_ty(type_ref); | 1292 | let ty = self.make_ty(type_ref); |
1294 | 1293 | ||
1295 | self.infer_pat(*pat, &ty, BindingMode::default()); | 1294 | self.infer_pat(*pat, &ty, BindingMode::default()); |
1296 | } | 1295 | } |
1297 | self.return_ty = self.make_ty(signature.ret_type()); | 1296 | self.return_ty = self.make_ty(data.ret_type()); |
1298 | } | 1297 | } |
1299 | 1298 | ||
1300 | fn infer_body(&mut self) { | 1299 | fn infer_body(&mut self) { |
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index 300616a53..cb494baf4 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs | |||
@@ -353,11 +353,10 @@ pub(crate) fn generic_defaults(db: &impl HirDatabase, def: GenericDef) -> Substs | |||
353 | } | 353 | } |
354 | 354 | ||
355 | fn fn_sig_for_fn(db: &impl HirDatabase, def: Function) -> FnSig { | 355 | fn fn_sig_for_fn(db: &impl HirDatabase, def: Function) -> FnSig { |
356 | let signature = def.signature(db); | 356 | let data = def.data(db); |
357 | let resolver = def.resolver(db); | 357 | let resolver = def.resolver(db); |
358 | let params = | 358 | let params = data.params().iter().map(|tr| Ty::from_hir(db, &resolver, tr)).collect::<Vec<_>>(); |
359 | signature.params().iter().map(|tr| Ty::from_hir(db, &resolver, tr)).collect::<Vec<_>>(); | 359 | let ret = Ty::from_hir(db, &resolver, data.ret_type()); |
360 | let ret = Ty::from_hir(db, &resolver, signature.ret_type()); | ||
361 | FnSig::from_params_and_return(params, ret) | 360 | FnSig::from_params_and_return(params, ret) |
362 | } | 361 | } |
363 | 362 | ||
@@ -371,18 +370,18 @@ fn type_for_fn(db: &impl HirDatabase, def: Function) -> Ty { | |||
371 | 370 | ||
372 | /// Build the declared type of a const. | 371 | /// Build the declared type of a const. |
373 | fn type_for_const(db: &impl HirDatabase, def: Const) -> Ty { | 372 | fn type_for_const(db: &impl HirDatabase, def: Const) -> Ty { |
374 | let signature = def.signature(db); | 373 | let data = def.data(db); |
375 | let resolver = def.resolver(db); | 374 | let resolver = def.resolver(db); |
376 | 375 | ||
377 | Ty::from_hir(db, &resolver, signature.type_ref()) | 376 | Ty::from_hir(db, &resolver, data.type_ref()) |
378 | } | 377 | } |
379 | 378 | ||
380 | /// Build the declared type of a static. | 379 | /// Build the declared type of a static. |
381 | fn type_for_static(db: &impl HirDatabase, def: Static) -> Ty { | 380 | fn type_for_static(db: &impl HirDatabase, def: Static) -> Ty { |
382 | let signature = def.signature(db); | 381 | let data = def.data(db); |
383 | let resolver = def.resolver(db); | 382 | let resolver = def.resolver(db); |
384 | 383 | ||
385 | Ty::from_hir(db, &resolver, signature.type_ref()) | 384 | Ty::from_hir(db, &resolver, data.type_ref()) |
386 | } | 385 | } |
387 | 386 | ||
388 | /// Build the declared type of a static. | 387 | /// Build the declared type of a static. |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index ad26d591c..46ec136bd 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -192,8 +192,8 @@ fn iterate_trait_method_candidates<T>( | |||
192 | let mut known_implemented = false; | 192 | let mut known_implemented = false; |
193 | for item in data.items() { | 193 | for item in data.items() { |
194 | if let TraitItem::Function(m) = *item { | 194 | if let TraitItem::Function(m) = *item { |
195 | let sig = m.signature(db); | 195 | let data = m.data(db); |
196 | if name.map_or(true, |name| sig.name() == name) && sig.has_self_param() { | 196 | if name.map_or(true, |name| data.name() == name) && data.has_self_param() { |
197 | if !known_implemented { | 197 | if !known_implemented { |
198 | let trait_ref = canonical_trait_ref(db, t, ty.clone()); | 198 | let trait_ref = canonical_trait_ref(db, t, ty.clone()); |
199 | if db.implements(krate, trait_ref).is_none() { | 199 | if db.implements(krate, trait_ref).is_none() { |
@@ -227,8 +227,8 @@ fn iterate_inherent_methods<T>( | |||
227 | for impl_block in impls.lookup_impl_blocks(&ty.value) { | 227 | for impl_block in impls.lookup_impl_blocks(&ty.value) { |
228 | for item in impl_block.items(db) { | 228 | for item in impl_block.items(db) { |
229 | if let ImplItem::Method(f) = item { | 229 | if let ImplItem::Method(f) = item { |
230 | let sig = f.signature(db); | 230 | let data = f.data(db); |
231 | if name.map_or(true, |name| sig.name() == name) && sig.has_self_param() { | 231 | if name.map_or(true, |name| data.name() == name) && data.has_self_param() { |
232 | if let Some(result) = callback(&ty.value, f) { | 232 | if let Some(result) = callback(&ty.value, f) { |
233 | return Some(result); | 233 | return Some(result); |
234 | } | 234 | } |
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index bd08e183d..2948c646b 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs | |||
@@ -35,7 +35,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal | |||
35 | 35 | ||
36 | // If we have a calling expression let's find which argument we are on | 36 | // If we have a calling expression let's find which argument we are on |
37 | let num_params = call_info.parameters().len(); | 37 | let num_params = call_info.parameters().len(); |
38 | let has_self = function.signature(db).has_self_param(); | 38 | let has_self = function.data(db).has_self_param(); |
39 | 39 | ||
40 | if num_params == 1 { | 40 | if num_params == 1 { |
41 | if !has_self { | 41 | if !has_self { |
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index f26fd06b3..40bd1e75e 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -37,8 +37,8 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) | |||
37 | 37 | ||
38 | fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { | 38 | fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { |
39 | ctx.analyzer.iterate_method_candidates(ctx.db, receiver, None, |_ty, func| { | 39 | ctx.analyzer.iterate_method_candidates(ctx.db, receiver, None, |_ty, func| { |
40 | let sig = func.signature(ctx.db); | 40 | let data = func.data(ctx.db); |
41 | if sig.has_self_param() { | 41 | if data.has_self_param() { |
42 | acc.add_function(ctx, func); | 42 | acc.add_function(ctx, func); |
43 | } | 43 | } |
44 | None::<()> | 44 | None::<()> |
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 99da24142..c14af593b 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -49,8 +49,8 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { | |||
49 | ty.iterate_impl_items(ctx.db, krate, |item| { | 49 | ty.iterate_impl_items(ctx.db, krate, |item| { |
50 | match item { | 50 | match item { |
51 | hir::ImplItem::Method(func) => { | 51 | hir::ImplItem::Method(func) => { |
52 | let sig = func.signature(ctx.db); | 52 | let data = func.data(ctx.db); |
53 | if !sig.has_self_param() { | 53 | if !data.has_self_param() { |
54 | acc.add_function(ctx, func); | 54 | acc.add_function(ctx, func); |
55 | } | 55 | } |
56 | } | 56 | } |
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index f4ff4404b..973936736 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs | |||
@@ -98,13 +98,13 @@ impl Completions { | |||
98 | name: Option<String>, | 98 | name: Option<String>, |
99 | func: hir::Function, | 99 | func: hir::Function, |
100 | ) { | 100 | ) { |
101 | let sig = func.signature(ctx.db); | 101 | let data = func.data(ctx.db); |
102 | let name = name.unwrap_or_else(|| sig.name().to_string()); | 102 | let name = name.unwrap_or_else(|| data.name().to_string()); |
103 | let ast_node = func.source(ctx.db).ast; | 103 | let ast_node = func.source(ctx.db).ast; |
104 | let detail = function_label(&ast_node); | 104 | let detail = function_label(&ast_node); |
105 | 105 | ||
106 | let mut builder = CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name) | 106 | let mut builder = CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name) |
107 | .kind(if sig.has_self_param() { | 107 | .kind(if data.has_self_param() { |
108 | CompletionItemKind::Method | 108 | CompletionItemKind::Method |
109 | } else { | 109 | } else { |
110 | CompletionItemKind::Function | 110 | CompletionItemKind::Function |
@@ -115,10 +115,10 @@ impl Completions { | |||
115 | if ctx.use_item_syntax.is_none() && !ctx.is_call { | 115 | if ctx.use_item_syntax.is_none() && !ctx.is_call { |
116 | tested_by!(inserts_parens_for_function_calls); | 116 | tested_by!(inserts_parens_for_function_calls); |
117 | let snippet = | 117 | let snippet = |
118 | if sig.params().is_empty() || sig.has_self_param() && sig.params().len() == 1 { | 118 | if data.params().is_empty() || data.has_self_param() && data.params().len() == 1 { |
119 | format!("{}()$0", sig.name()) | 119 | format!("{}()$0", data.name()) |
120 | } else { | 120 | } else { |
121 | format!("{}($0)", sig.name()) | 121 | format!("{}($0)", data.name()) |
122 | }; | 122 | }; |
123 | builder = builder.insert_snippet(snippet); | 123 | builder = builder.insert_snippet(snippet); |
124 | } | 124 | } |