aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/ast_transform.rs8
-rw-r--r--crates/ra_assists/src/handlers/add_missing_impl_members.rs6
-rw-r--r--crates/ra_assists/src/handlers/add_new.rs16
-rw-r--r--crates/ra_assists/src/handlers/move_bounds.rs2
-rw-r--r--crates/ra_assists/src/utils.rs10
-rw-r--r--crates/ra_assists/src/utils/insert_use.rs2
-rw-r--r--crates/ra_hir/src/code_model.rs36
-rw-r--r--crates/ra_hir/src/from_id.rs4
-rw-r--r--crates/ra_hir/src/has_source.rs8
-rw-r--r--crates/ra_hir/src/lib.rs2
-rw-r--r--crates/ra_hir/src/semantics.rs2
-rw-r--r--crates/ra_hir/src/semantics/source_to_def.rs6
-rw-r--r--crates/ra_hir/src/source_analyzer.rs2
-rw-r--r--crates/ra_hir_def/src/body/lower.rs2
-rw-r--r--crates/ra_hir_def/src/data.rs6
-rw-r--r--crates/ra_hir_def/src/keys.rs2
-rw-r--r--crates/ra_hir_def/src/lang_item.rs10
-rw-r--r--crates/ra_hir_def/src/lib.rs2
-rw-r--r--crates/ra_hir_def/src/nameres/raw.rs6
-rw-r--r--crates/ra_hir_def/src/resolver.rs20
-rw-r--r--crates/ra_hir_ty/src/db.rs6
-rw-r--r--crates/ra_hir_ty/src/infer.rs8
-rw-r--r--crates/ra_hir_ty/src/infer/expr.rs26
-rw-r--r--crates/ra_hir_ty/src/method_resolution.rs63
-rw-r--r--crates/ra_hir_ty/src/tests/macros.rs12
-rw-r--r--crates/ra_hir_ty/src/tests/method_resolution.rs18
-rw-r--r--crates/ra_hir_ty/src/tests/traits.rs28
-rw-r--r--crates/ra_hir_ty/src/traits.rs6
-rw-r--r--crates/ra_hir_ty/src/traits/builtin.rs2
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs8
-rw-r--r--crates/ra_ide/src/completion/complete_trait_impl.rs50
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs8
-rw-r--r--crates/ra_ide/src/display/navigation_target.rs2
-rw-r--r--crates/ra_ide/src/display/structure.rs6
-rw-r--r--crates/ra_ide/src/expand_macro.rs4
-rw-r--r--crates/ra_ide/src/goto_definition.rs12
-rw-r--r--crates/ra_ide/src/impls.rs28
-rw-r--r--crates/ra_ide/src/inlay_hints.rs127
-rw-r--r--crates/ra_ide/src/references/classify.rs2
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs1
-rw-r--r--crates/ra_ide_db/src/defs.rs4
-rw-r--r--crates/ra_parser/src/grammar.rs2
-rw-r--r--crates/ra_parser/src/grammar/items.rs4
-rw-r--r--crates/ra_parser/src/grammar/items/traits.rs6
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs2
-rw-r--r--crates/ra_project_model/src/sysroot.rs2
-rw-r--r--crates/ra_syntax/src/ast.rs2
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs2
-rw-r--r--crates/ra_syntax/src/ast/generated.rs28
-rw-r--r--crates/ra_syntax/src/validation.rs5
-rw-r--r--crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rs (renamed from crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.rs)0
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.txt (renamed from crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.txt)2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rs (renamed from crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.rs)0
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.txt (renamed from crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.txt)2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt2
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs4
-rw-r--r--crates/rust-analyzer/src/conv.rs2
76 files changed, 386 insertions, 302 deletions
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs
index a74ac42d5..0e53c1eee 100644
--- a/crates/ra_assists/src/ast_transform.rs
+++ b/crates/ra_assists/src/ast_transform.rs
@@ -40,9 +40,9 @@ impl<'a> SubstituteTypeParams<'a> {
40 db: &'a RootDatabase, 40 db: &'a RootDatabase,
41 // FIXME: there's implicit invariant that `trait_` and `source_scope` match... 41 // FIXME: there's implicit invariant that `trait_` and `source_scope` match...
42 trait_: hir::Trait, 42 trait_: hir::Trait,
43 impl_block: ast::ImplBlock, 43 impl_def: ast::ImplDef,
44 ) -> SubstituteTypeParams<'a> { 44 ) -> SubstituteTypeParams<'a> {
45 let substs = get_syntactic_substs(impl_block).unwrap_or_default(); 45 let substs = get_syntactic_substs(impl_def).unwrap_or_default();
46 let generic_def: hir::GenericDef = trait_.into(); 46 let generic_def: hir::GenericDef = trait_.into();
47 let substs_by_param: FxHashMap<_, _> = generic_def 47 let substs_by_param: FxHashMap<_, _> = generic_def
48 .params(db) 48 .params(db)
@@ -59,8 +59,8 @@ impl<'a> SubstituteTypeParams<'a> {
59 59
60 // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the 60 // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the
61 // trait ref, and then go from the types in the substs back to the syntax) 61 // trait ref, and then go from the types in the substs back to the syntax)
62 fn get_syntactic_substs(impl_block: ast::ImplBlock) -> Option<Vec<ast::TypeRef>> { 62 fn get_syntactic_substs(impl_def: ast::ImplDef) -> Option<Vec<ast::TypeRef>> {
63 let target_trait = impl_block.target_trait()?; 63 let target_trait = impl_def.target_trait()?;
64 let path_type = match target_trait { 64 let path_type = match target_trait {
65 ast::TypeRef::PathType(path) => path, 65 ast::TypeRef::PathType(path) => path,
66 _ => return None, 66 _ => return None,
diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs
index 4005014bd..639180d37 100644
--- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs
+++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs
@@ -101,7 +101,7 @@ fn add_missing_impl_members_inner(
101 label: &'static str, 101 label: &'static str,
102) -> Option<Assist> { 102) -> Option<Assist> {
103 let _p = ra_prof::profile("add_missing_impl_members_inner"); 103 let _p = ra_prof::profile("add_missing_impl_members_inner");
104 let impl_node = ctx.find_node_at_offset::<ast::ImplBlock>()?; 104 let impl_node = ctx.find_node_at_offset::<ast::ImplDef>()?;
105 let impl_item_list = impl_node.item_list()?; 105 let impl_item_list = impl_node.item_list()?;
106 106
107 let trait_ = resolve_target_trait(&ctx.sema, &impl_node)?; 107 let trait_ = resolve_target_trait(&ctx.sema, &impl_node)?;
@@ -257,7 +257,7 @@ impl Foo for S {
257 } 257 }
258 258
259 #[test] 259 #[test]
260 fn test_empty_impl_block() { 260 fn test_empty_impl_def() {
261 check_assist( 261 check_assist(
262 add_missing_impl_members, 262 add_missing_impl_members,
263 " 263 "
@@ -308,7 +308,7 @@ impl<U> Foo<U> for S {
308 } 308 }
309 309
310 #[test] 310 #[test]
311 fn test_cursor_after_empty_impl_block() { 311 fn test_cursor_after_empty_impl_def() {
312 check_assist( 312 check_assist(
313 add_missing_impl_members, 313 add_missing_impl_members,
314 " 314 "
diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs
index 166e907fb..697e7cda6 100644
--- a/crates/ra_assists/src/handlers/add_new.rs
+++ b/crates/ra_assists/src/handlers/add_new.rs
@@ -41,14 +41,14 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> {
41 }; 41 };
42 42
43 // Return early if we've found an existing new fn 43 // Return early if we've found an existing new fn
44 let impl_block = find_struct_impl(&ctx, &strukt)?; 44 let impl_def = find_struct_impl(&ctx, &strukt)?;
45 45
46 ctx.add_assist(AssistId("add_new"), "Add default constructor", |edit| { 46 ctx.add_assist(AssistId("add_new"), "Add default constructor", |edit| {
47 edit.target(strukt.syntax().text_range()); 47 edit.target(strukt.syntax().text_range());
48 48
49 let mut buf = String::with_capacity(512); 49 let mut buf = String::with_capacity(512);
50 50
51 if impl_block.is_some() { 51 if impl_def.is_some() {
52 buf.push('\n'); 52 buf.push('\n');
53 } 53 }
54 54
@@ -71,10 +71,10 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> {
71 71
72 buf.push_str("} }"); 72 buf.push_str("} }");
73 73
74 let (start_offset, end_offset) = impl_block 74 let (start_offset, end_offset) = impl_def
75 .and_then(|impl_block| { 75 .and_then(|impl_def| {
76 buf.push('\n'); 76 buf.push('\n');
77 let start = impl_block 77 let start = impl_def
78 .syntax() 78 .syntax()
79 .descendants_with_tokens() 79 .descendants_with_tokens()
80 .find(|t| t.kind() == T!['{'])? 80 .find(|t| t.kind() == T!['{'])?
@@ -128,7 +128,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
128// 128//
129// FIXME: change the new fn checking to a more semantic approach when that's more 129// FIXME: change the new fn checking to a more semantic approach when that's more
130// viable (e.g. we process proc macros, etc) 130// viable (e.g. we process proc macros, etc)
131fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<ast::ImplBlock>> { 131fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> {
132 let db = ctx.db; 132 let db = ctx.db;
133 let module = strukt.syntax().ancestors().find(|node| { 133 let module = strukt.syntax().ancestors().find(|node| {
134 ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) 134 ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind())
@@ -136,7 +136,7 @@ fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<a
136 136
137 let struct_def = ctx.sema.to_def(strukt)?; 137 let struct_def = ctx.sema.to_def(strukt)?;
138 138
139 let block = module.descendants().filter_map(ast::ImplBlock::cast).find_map(|impl_blk| { 139 let block = module.descendants().filter_map(ast::ImplDef::cast).find_map(|impl_blk| {
140 let blk = ctx.sema.to_def(&impl_blk)?; 140 let blk = ctx.sema.to_def(&impl_blk)?;
141 141
142 // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}` 142 // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}`
@@ -164,7 +164,7 @@ fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<a
164 Some(block) 164 Some(block)
165} 165}
166 166
167fn has_new_fn(imp: &ast::ImplBlock) -> bool { 167fn has_new_fn(imp: &ast::ImplDef) -> bool {
168 if let Some(il) = imp.item_list() { 168 if let Some(il) = imp.item_list() {
169 for item in il.impl_items() { 169 for item in il.impl_items() {
170 if let ast::ImplItem::FnDef(f) = item { 170 if let ast::ImplItem::FnDef(f) = item {
diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs
index 86b235366..0b501f3e5 100644
--- a/crates/ra_assists/src/handlers/move_bounds.rs
+++ b/crates/ra_assists/src/handlers/move_bounds.rs
@@ -37,7 +37,7 @@ pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx) -> Option<Assist> {
37 let anchor: SyntaxElement = match parent.kind() { 37 let anchor: SyntaxElement = match parent.kind() {
38 FN_DEF => ast::FnDef::cast(parent)?.body()?.syntax().clone().into(), 38 FN_DEF => ast::FnDef::cast(parent)?.body()?.syntax().clone().into(),
39 TRAIT_DEF => ast::TraitDef::cast(parent)?.item_list()?.syntax().clone().into(), 39 TRAIT_DEF => ast::TraitDef::cast(parent)?.item_list()?.syntax().clone().into(),
40 IMPL_BLOCK => ast::ImplBlock::cast(parent)?.item_list()?.syntax().clone().into(), 40 IMPL_DEF => ast::ImplDef::cast(parent)?.item_list()?.syntax().clone().into(),
41 ENUM_DEF => ast::EnumDef::cast(parent)?.variant_list()?.syntax().clone().into(), 41 ENUM_DEF => ast::EnumDef::cast(parent)?.variant_list()?.syntax().clone().into(),
42 STRUCT_DEF => parent 42 STRUCT_DEF => parent
43 .children_with_tokens() 43 .children_with_tokens()
diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs
index d544caee7..3d6c59bda 100644
--- a/crates/ra_assists/src/utils.rs
+++ b/crates/ra_assists/src/utils.rs
@@ -13,14 +13,14 @@ pub use insert_use::insert_use_statement;
13 13
14pub fn get_missing_impl_items( 14pub fn get_missing_impl_items(
15 sema: &Semantics<RootDatabase>, 15 sema: &Semantics<RootDatabase>,
16 impl_block: &ast::ImplBlock, 16 impl_def: &ast::ImplDef,
17) -> Vec<hir::AssocItem> { 17) -> Vec<hir::AssocItem> {
18 // Names must be unique between constants and functions. However, type aliases 18 // Names must be unique between constants and functions. However, type aliases
19 // may share the same name as a function or constant. 19 // may share the same name as a function or constant.
20 let mut impl_fns_consts = FxHashSet::default(); 20 let mut impl_fns_consts = FxHashSet::default();
21 let mut impl_type = FxHashSet::default(); 21 let mut impl_type = FxHashSet::default();
22 22
23 if let Some(item_list) = impl_block.item_list() { 23 if let Some(item_list) = impl_def.item_list() {
24 for item in item_list.impl_items() { 24 for item in item_list.impl_items() {
25 match item { 25 match item {
26 ast::ImplItem::FnDef(f) => { 26 ast::ImplItem::FnDef(f) => {
@@ -44,7 +44,7 @@ pub fn get_missing_impl_items(
44 } 44 }
45 } 45 }
46 46
47 resolve_target_trait(sema, impl_block).map_or(vec![], |target_trait| { 47 resolve_target_trait(sema, impl_def).map_or(vec![], |target_trait| {
48 target_trait 48 target_trait
49 .items(sema.db) 49 .items(sema.db)
50 .iter() 50 .iter()
@@ -65,9 +65,9 @@ pub fn get_missing_impl_items(
65 65
66pub(crate) fn resolve_target_trait( 66pub(crate) fn resolve_target_trait(
67 sema: &Semantics<RootDatabase>, 67 sema: &Semantics<RootDatabase>,
68 impl_block: &ast::ImplBlock, 68 impl_def: &ast::ImplDef,
69) -> Option<hir::Trait> { 69) -> Option<hir::Trait> {
70 let ast_path = impl_block 70 let ast_path = impl_def
71 .target_trait() 71 .target_trait()
72 .map(|it| it.syntax().clone()) 72 .map(|it| it.syntax().clone())
73 .and_then(ast::PathType::cast)? 73 .and_then(ast::PathType::cast)?
diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/ra_assists/src/utils/insert_use.rs
index 36fd2fc0b..c507e71e0 100644
--- a/crates/ra_assists/src/utils/insert_use.rs
+++ b/crates/ra_assists/src/utils/insert_use.rs
@@ -1,4 +1,6 @@
1//! Handle syntactic aspects of inserting a new `use`. 1//! Handle syntactic aspects of inserting a new `use`.
2// FIXME: rewrite according to the plan, outlined in
3// https://github.com/rust-analyzer/rust-analyzer/issues/3301#issuecomment-592931553
2 4
3use hir::{self, ModPath}; 5use hir::{self, ModPath};
4use ra_syntax::{ 6use ra_syntax::{
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 034fb7cfa..b71ee764a 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -229,8 +229,8 @@ impl Module {
229 } 229 }
230 } 230 }
231 231
232 for impl_block in self.impl_blocks(db) { 232 for impl_def in self.impl_defs(db) {
233 for item in impl_block.items(db) { 233 for item in impl_def.items(db) {
234 if let AssocItem::Function(f) = item { 234 if let AssocItem::Function(f) = item {
235 f.diagnostics(db, sink); 235 f.diagnostics(db, sink);
236 } 236 }
@@ -243,9 +243,9 @@ impl Module {
243 def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect() 243 def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect()
244 } 244 }
245 245
246 pub fn impl_blocks(self, db: &impl DefDatabase) -> Vec<ImplBlock> { 246 pub fn impl_defs(self, db: &impl DefDatabase) -> Vec<ImplDef> {
247 let def_map = db.crate_def_map(self.id.krate); 247 let def_map = db.crate_def_map(self.id.krate);
248 def_map[self.id.local_id].scope.impls().map(ImplBlock::from).collect() 248 def_map[self.id.local_id].scope.impls().map(ImplDef::from).collect()
249 } 249 }
250 250
251 pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module { 251 pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module {
@@ -686,7 +686,7 @@ pub enum AssocItem {
686} 686}
687pub enum AssocItemContainer { 687pub enum AssocItemContainer {
688 Trait(Trait), 688 Trait(Trait),
689 ImplBlock(ImplBlock), 689 ImplDef(ImplDef),
690} 690}
691pub trait AsAssocItem { 691pub trait AsAssocItem {
692 fn as_assoc_item(self, db: &impl DefDatabase) -> Option<AssocItem>; 692 fn as_assoc_item(self, db: &impl DefDatabase) -> Option<AssocItem>;
@@ -736,7 +736,7 @@ impl AssocItem {
736 }; 736 };
737 match container { 737 match container {
738 AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()), 738 AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()),
739 AssocContainerId::ImplId(id) => AssocItemContainer::ImplBlock(id.into()), 739 AssocContainerId::ImplId(id) => AssocItemContainer::ImplDef(id.into()),
740 AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"), 740 AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"),
741 } 741 }
742 } 742 }
@@ -748,7 +748,7 @@ pub enum GenericDef {
748 Adt(Adt), 748 Adt(Adt),
749 Trait(Trait), 749 Trait(Trait),
750 TypeAlias(TypeAlias), 750 TypeAlias(TypeAlias),
751 ImplBlock(ImplBlock), 751 ImplDef(ImplDef),
752 // enum variants cannot have generics themselves, but their parent enums 752 // enum variants cannot have generics themselves, but their parent enums
753 // can, and this makes some code easier to write 753 // can, and this makes some code easier to write
754 EnumVariant(EnumVariant), 754 EnumVariant(EnumVariant),
@@ -760,7 +760,7 @@ impl_froms!(
760 Adt(Struct, Enum, Union), 760 Adt(Struct, Enum, Union),
761 Trait, 761 Trait,
762 TypeAlias, 762 TypeAlias,
763 ImplBlock, 763 ImplDef,
764 EnumVariant, 764 EnumVariant,
765 Const 765 Const
766); 766);
@@ -850,20 +850,20 @@ impl TypeParam {
850 } 850 }
851} 851}
852 852
853// FIXME: rename from `ImplBlock` to `Impl` 853// FIXME: rename from `ImplDef` to `Impl`
854#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 854#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
855pub struct ImplBlock { 855pub struct ImplDef {
856 pub(crate) id: ImplId, 856 pub(crate) id: ImplId,
857} 857}
858 858
859impl ImplBlock { 859impl ImplDef {
860 pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec<ImplBlock> { 860 pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec<ImplDef> {
861 let impls = db.impls_in_crate(krate.id); 861 let impls = db.impls_in_crate(krate.id);
862 impls.all_impls().map(Self::from).collect() 862 impls.all_impls().map(Self::from).collect()
863 } 863 }
864 pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec<ImplBlock> { 864 pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec<ImplDef> {
865 let impls = db.impls_in_crate(krate.id); 865 let impls = db.impls_in_crate(krate.id);
866 impls.lookup_impl_blocks_for_trait(trait_.id).map(Self::from).collect() 866 impls.lookup_impl_defs_for_trait(trait_.id).map(Self::from).collect()
867 } 867 }
868 868
869 pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> { 869 pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> {
@@ -1077,7 +1077,7 @@ impl Type {
1077 } 1077 }
1078 1078
1079 // This would be nicer if it just returned an iterator, but that runs into 1079 // This would be nicer if it just returned an iterator, but that runs into
1080 // lifetime problems, because we need to borrow temp `CrateImplBlocks`. 1080 // lifetime problems, because we need to borrow temp `CrateImplDefs`.
1081 pub fn iterate_impl_items<T>( 1081 pub fn iterate_impl_items<T>(
1082 self, 1082 self,
1083 db: &impl HirDatabase, 1083 db: &impl HirDatabase,
@@ -1087,8 +1087,8 @@ impl Type {
1087 for krate in self.ty.value.def_crates(db, krate.id)? { 1087 for krate in self.ty.value.def_crates(db, krate.id)? {
1088 let impls = db.impls_in_crate(krate); 1088 let impls = db.impls_in_crate(krate);
1089 1089
1090 for impl_block in impls.lookup_impl_blocks(&self.ty.value) { 1090 for impl_def in impls.lookup_impl_defs(&self.ty.value) {
1091 for &item in db.impl_data(impl_block).items.iter() { 1091 for &item in db.impl_data(impl_def).items.iter() {
1092 if let Some(result) = callback(item.into()) { 1092 if let Some(result) = callback(item.into()) {
1093 return Some(result); 1093 return Some(result);
1094 } 1094 }
@@ -1196,7 +1196,7 @@ pub enum ScopeDef {
1196 ModuleDef(ModuleDef), 1196 ModuleDef(ModuleDef),
1197 MacroDef(MacroDef), 1197 MacroDef(MacroDef),
1198 GenericParam(TypeParam), 1198 GenericParam(TypeParam),
1199 ImplSelfType(ImplBlock), 1199 ImplSelfType(ImplDef),
1200 AdtSelfType(Adt), 1200 AdtSelfType(Adt),
1201 Local(Local), 1201 Local(Local),
1202 Unknown, 1202 Unknown,
diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs
index cbfa91d6c..c179b13c6 100644
--- a/crates/ra_hir/src/from_id.rs
+++ b/crates/ra_hir/src/from_id.rs
@@ -39,7 +39,7 @@ from_id![
39 (hir_def::StaticId, crate::Static), 39 (hir_def::StaticId, crate::Static),
40 (hir_def::ConstId, crate::Const), 40 (hir_def::ConstId, crate::Const),
41 (hir_def::FunctionId, crate::Function), 41 (hir_def::FunctionId, crate::Function),
42 (hir_def::ImplId, crate::ImplBlock), 42 (hir_def::ImplId, crate::ImplDef),
43 (hir_def::TypeParamId, crate::TypeParam), 43 (hir_def::TypeParamId, crate::TypeParam),
44 (hir_expand::MacroDefId, crate::MacroDef) 44 (hir_expand::MacroDefId, crate::MacroDef)
45]; 45];
@@ -145,7 +145,7 @@ impl From<GenericDef> for GenericDefId {
145 GenericDef::Adt(it) => GenericDefId::AdtId(it.into()), 145 GenericDef::Adt(it) => GenericDefId::AdtId(it.into()),
146 GenericDef::Trait(it) => GenericDefId::TraitId(it.id), 146 GenericDef::Trait(it) => GenericDefId::TraitId(it.id),
147 GenericDef::TypeAlias(it) => GenericDefId::TypeAliasId(it.id), 147 GenericDef::TypeAlias(it) => GenericDefId::TypeAliasId(it.id),
148 GenericDef::ImplBlock(it) => GenericDefId::ImplId(it.id), 148 GenericDef::ImplDef(it) => GenericDefId::ImplId(it.id),
149 GenericDef::EnumVariant(it) => { 149 GenericDef::EnumVariant(it) => {
150 GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id }) 150 GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id })
151 } 151 }
diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs
index 5541266e2..f121e1eff 100644
--- a/crates/ra_hir/src/has_source.rs
+++ b/crates/ra_hir/src/has_source.rs
@@ -9,7 +9,7 @@ use hir_def::{
9use ra_syntax::ast; 9use ra_syntax::ast;
10 10
11use crate::{ 11use crate::{
12 db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, MacroDef, Module, 12 db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplDef, MacroDef, Module,
13 Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union, 13 Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union,
14}; 14};
15 15
@@ -111,9 +111,9 @@ impl HasSource for MacroDef {
111 } 111 }
112 } 112 }
113} 113}
114impl HasSource for ImplBlock { 114impl HasSource for ImplDef {
115 type Ast = ast::ImplBlock; 115 type Ast = ast::ImplDef;
116 fn source(self, db: &impl DefDatabase) -> InFile<ast::ImplBlock> { 116 fn source(self, db: &impl DefDatabase) -> InFile<ast::ImplDef> {
117 self.id.lookup(db).source(db) 117 self.id.lookup(db).source(db)
118 } 118 }
119} 119}
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index cefbd80e6..e1cb12cca 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -41,7 +41,7 @@ pub use crate::{
41 code_model::{ 41 code_model::{
42 Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency, 42 Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency,
43 DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs, 43 DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs,
44 HasVisibility, ImplBlock, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, 44 HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct,
45 StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, 45 StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef,
46 }, 46 },
47 has_source::HasSource, 47 has_source::HasSource,
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 74901e318..a0853957c 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -262,7 +262,7 @@ to_def_impls![
262 (crate::Enum, ast::EnumDef, enum_to_def), 262 (crate::Enum, ast::EnumDef, enum_to_def),
263 (crate::Union, ast::UnionDef, union_to_def), 263 (crate::Union, ast::UnionDef, union_to_def),
264 (crate::Trait, ast::TraitDef, trait_to_def), 264 (crate::Trait, ast::TraitDef, trait_to_def),
265 (crate::ImplBlock, ast::ImplBlock, impl_to_def), 265 (crate::ImplDef, ast::ImplDef, impl_to_def),
266 (crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def), 266 (crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def),
267 (crate::Const, ast::ConstDef, const_to_def), 267 (crate::Const, ast::ConstDef, const_to_def),
268 (crate::Static, ast::StaticDef, static_to_def), 268 (crate::Static, ast::StaticDef, static_to_def),
diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs
index 884b535b2..67b243222 100644
--- a/crates/ra_hir/src/semantics/source_to_def.rs
+++ b/crates/ra_hir/src/semantics/source_to_def.rs
@@ -67,7 +67,7 @@ impl<DB: HirDatabase> SourceToDefCtx<'_, &'_ DB> {
67 pub(super) fn trait_to_def(&mut self, src: InFile<ast::TraitDef>) -> Option<TraitId> { 67 pub(super) fn trait_to_def(&mut self, src: InFile<ast::TraitDef>) -> Option<TraitId> {
68 self.to_def(src, keys::TRAIT) 68 self.to_def(src, keys::TRAIT)
69 } 69 }
70 pub(super) fn impl_to_def(&mut self, src: InFile<ast::ImplBlock>) -> Option<ImplId> { 70 pub(super) fn impl_to_def(&mut self, src: InFile<ast::ImplDef>) -> Option<ImplId> {
71 self.to_def(src, keys::IMPL) 71 self.to_def(src, keys::IMPL)
72 } 72 }
73 pub(super) fn fn_to_def(&mut self, src: InFile<ast::FnDef>) -> Option<FunctionId> { 73 pub(super) fn fn_to_def(&mut self, src: InFile<ast::FnDef>) -> Option<FunctionId> {
@@ -166,7 +166,7 @@ impl<DB: HirDatabase> SourceToDefCtx<'_, &'_ DB> {
166 let def = self.trait_to_def(container.with_value(it))?; 166 let def = self.trait_to_def(container.with_value(it))?;
167 def.into() 167 def.into()
168 }, 168 },
169 ast::ImplBlock(it) => { 169 ast::ImplDef(it) => {
170 let def = self.impl_to_def(container.with_value(it))?; 170 let def = self.impl_to_def(container.with_value(it))?;
171 def.into() 171 def.into()
172 }, 172 },
@@ -213,7 +213,7 @@ impl<DB: HirDatabase> SourceToDefCtx<'_, &'_ DB> {
213 ast::EnumDef(it) => { self.enum_to_def(container.with_value(it))?.into() }, 213 ast::EnumDef(it) => { self.enum_to_def(container.with_value(it))?.into() },
214 ast::TraitDef(it) => { self.trait_to_def(container.with_value(it))?.into() }, 214 ast::TraitDef(it) => { self.trait_to_def(container.with_value(it))?.into() },
215 ast::TypeAliasDef(it) => { self.type_alias_to_def(container.with_value(it))?.into() }, 215 ast::TypeAliasDef(it) => { self.type_alias_to_def(container.with_value(it))?.into() },
216 ast::ImplBlock(it) => { self.impl_to_def(container.with_value(it))?.into() }, 216 ast::ImplDef(it) => { self.impl_to_def(container.with_value(it))?.into() },
217 _ => continue, 217 _ => continue,
218 } 218 }
219 }; 219 };
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs
index c650a9e08..4c121eb73 100644
--- a/crates/ra_hir/src/source_analyzer.rs
+++ b/crates/ra_hir/src/source_analyzer.rs
@@ -49,7 +49,7 @@ pub enum PathResolution {
49 Local(Local), 49 Local(Local),
50 /// A generic parameter 50 /// A generic parameter
51 TypeParam(TypeParam), 51 TypeParam(TypeParam),
52 SelfType(crate::ImplBlock), 52 SelfType(crate::ImplDef),
53 Macro(MacroDef), 53 Macro(MacroDef),
54 AssocItem(crate::AssocItem), 54 AssocItem(crate::AssocItem),
55} 55}
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index b3fb6d452..c18e6879b 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -544,7 +544,7 @@ where
544 let ast_id = self.expander.ast_id(&def); 544 let ast_id = self.expander.ast_id(&def);
545 (TraitLoc { container, ast_id }.intern(self.db).into(), def.name()) 545 (TraitLoc { container, ast_id }.intern(self.db).into(), def.name())
546 } 546 }
547 ast::ModuleItem::ImplBlock(_) 547 ast::ModuleItem::ImplDef(_)
548 | ast::ModuleItem::UseItem(_) 548 | ast::ModuleItem::UseItem(_)
549 | ast::ModuleItem::ExternCrateItem(_) 549 | ast::ModuleItem::ExternCrateItem(_)
550 | ast::ModuleItem::Module(_) => continue, 550 | ast::ModuleItem::Module(_) => continue,
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs
index c900a6a18..c5fb9428e 100644
--- a/crates/ra_hir_def/src/data.rs
+++ b/crates/ra_hir_def/src/data.rs
@@ -238,16 +238,16 @@ impl ConstData {
238fn collect_impl_items_in_macros( 238fn collect_impl_items_in_macros(
239 db: &impl DefDatabase, 239 db: &impl DefDatabase,
240 module_id: ModuleId, 240 module_id: ModuleId,
241 impl_block: &InFile<ast::ItemList>, 241 impl_def: &InFile<ast::ItemList>,
242 id: ImplId, 242 id: ImplId,
243) -> Vec<AssocItemId> { 243) -> Vec<AssocItemId> {
244 let mut expander = Expander::new(db, impl_block.file_id, module_id); 244 let mut expander = Expander::new(db, impl_def.file_id, module_id);
245 let mut res = Vec::new(); 245 let mut res = Vec::new();
246 246
247 // We set a limit to protect against infinite recursion 247 // We set a limit to protect against infinite recursion
248 let limit = 100; 248 let limit = 100;
249 249
250 for m in impl_block.value.syntax().children().filter_map(ast::MacroCall::cast) { 250 for m in impl_def.value.syntax().children().filter_map(ast::MacroCall::cast) {
251 res.extend(collect_impl_items_in_macro(db, &mut expander, m, id, limit)) 251 res.extend(collect_impl_items_in_macro(db, &mut expander, m, id, limit))
252 } 252 }
253 253
diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs
index 5913f12b1..8cd70eb9a 100644
--- a/crates/ra_hir_def/src/keys.rs
+++ b/crates/ra_hir_def/src/keys.rs
@@ -18,7 +18,7 @@ pub const FUNCTION: Key<ast::FnDef, FunctionId> = Key::new();
18pub const CONST: Key<ast::ConstDef, ConstId> = Key::new(); 18pub const CONST: Key<ast::ConstDef, ConstId> = Key::new();
19pub const STATIC: Key<ast::StaticDef, StaticId> = Key::new(); 19pub const STATIC: Key<ast::StaticDef, StaticId> = Key::new();
20pub const TYPE_ALIAS: Key<ast::TypeAliasDef, TypeAliasId> = Key::new(); 20pub const TYPE_ALIAS: Key<ast::TypeAliasDef, TypeAliasId> = Key::new();
21pub const IMPL: Key<ast::ImplBlock, ImplId> = Key::new(); 21pub const IMPL: Key<ast::ImplDef, ImplId> = Key::new();
22pub const TRAIT: Key<ast::TraitDef, TraitId> = Key::new(); 22pub const TRAIT: Key<ast::TraitDef, TraitId> = Key::new();
23pub const STRUCT: Key<ast::StructDef, StructId> = Key::new(); 23pub const STRUCT: Key<ast::StructDef, StructId> = Key::new();
24pub const UNION: Key<ast::UnionDef, UnionId> = Key::new(); 24pub const UNION: Key<ast::UnionDef, UnionId> = Key::new();
diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs
index 37c861a87..5a336ea1f 100644
--- a/crates/ra_hir_def/src/lang_item.rs
+++ b/crates/ra_hir_def/src/lang_item.rs
@@ -16,7 +16,7 @@ use crate::{
16pub enum LangItemTarget { 16pub enum LangItemTarget {
17 EnumId(EnumId), 17 EnumId(EnumId),
18 FunctionId(FunctionId), 18 FunctionId(FunctionId),
19 ImplBlockId(ImplId), 19 ImplDefId(ImplId),
20 StaticId(StaticId), 20 StaticId(StaticId),
21 StructId(StructId), 21 StructId(StructId),
22 TraitId(TraitId), 22 TraitId(TraitId),
@@ -37,9 +37,9 @@ impl LangItemTarget {
37 } 37 }
38 } 38 }
39 39
40 pub fn as_impl_block(self) -> Option<ImplId> { 40 pub fn as_impl_def(self) -> Option<ImplId> {
41 match self { 41 match self {
42 LangItemTarget::ImplBlockId(id) => Some(id), 42 LangItemTarget::ImplDefId(id) => Some(id),
43 _ => None, 43 _ => None,
44 } 44 }
45 } 45 }
@@ -125,8 +125,8 @@ impl LangItems {
125 // Look for impl targets 125 // Look for impl targets
126 let def_map = db.crate_def_map(module.krate); 126 let def_map = db.crate_def_map(module.krate);
127 let module_data = &def_map[module.local_id]; 127 let module_data = &def_map[module.local_id];
128 for impl_block in module_data.scope.impls() { 128 for impl_def in module_data.scope.impls() {
129 self.collect_lang_item(db, impl_block, LangItemTarget::ImplBlockId) 129 self.collect_lang_item(db, impl_def, LangItemTarget::ImplDefId)
130 } 130 }
131 131
132 for def in module_data.scope.declarations() { 132 for def in module_data.scope.declarations() {
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 564b5fec5..c9b14d0c8 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -164,7 +164,7 @@ impl_intern!(TypeAliasId, TypeAliasLoc, intern_type_alias, lookup_intern_type_al
164 164
165#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 165#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
166pub struct ImplId(salsa::InternId); 166pub struct ImplId(salsa::InternId);
167type ImplLoc = ItemLoc<ast::ImplBlock>; 167type ImplLoc = ItemLoc<ast::ImplDef>;
168impl_intern!(ImplId, ImplLoc, intern_impl, lookup_intern_impl); 168impl_intern!(ImplId, ImplLoc, intern_impl, lookup_intern_impl);
169 169
170#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 170#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs
index 0e8c9da76..ea3c00da8 100644
--- a/crates/ra_hir_def/src/nameres/raw.rs
+++ b/crates/ra_hir_def/src/nameres/raw.rs
@@ -213,7 +213,7 @@ impl_arena_id!(Impl);
213 213
214#[derive(Debug, PartialEq, Eq)] 214#[derive(Debug, PartialEq, Eq)]
215pub(super) struct ImplData { 215pub(super) struct ImplData {
216 pub(super) ast_id: FileAstId<ast::ImplBlock>, 216 pub(super) ast_id: FileAstId<ast::ImplDef>,
217} 217}
218 218
219struct RawItemsCollector { 219struct RawItemsCollector {
@@ -249,7 +249,7 @@ impl RawItemsCollector {
249 self.add_extern_crate_item(current_module, extern_crate); 249 self.add_extern_crate_item(current_module, extern_crate);
250 return; 250 return;
251 } 251 }
252 ast::ModuleItem::ImplBlock(it) => { 252 ast::ModuleItem::ImplDef(it) => {
253 self.add_impl(current_module, it); 253 self.add_impl(current_module, it);
254 return; 254 return;
255 } 255 }
@@ -395,7 +395,7 @@ impl RawItemsCollector {
395 self.push_item(current_module, attrs, RawItemKind::Macro(m)); 395 self.push_item(current_module, attrs, RawItemKind::Macro(m));
396 } 396 }
397 397
398 fn add_impl(&mut self, current_module: Option<Module>, imp: ast::ImplBlock) { 398 fn add_impl(&mut self, current_module: Option<Module>, imp: ast::ImplDef) {
399 let attrs = self.parse_attrs(&imp); 399 let attrs = self.parse_attrs(&imp);
400 let ast_id = self.source_ast_id_map.ast_id(&imp); 400 let ast_id = self.source_ast_id_map.ast_id(&imp);
401 let imp = self.raw_items.impls.alloc(ImplData { ast_id }); 401 let imp = self.raw_items.impls.alloc(ImplData { ast_id });
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs
index 9dd4fa555..2734d51a0 100644
--- a/crates/ra_hir_def/src/resolver.rs
+++ b/crates/ra_hir_def/src/resolver.rs
@@ -52,7 +52,7 @@ enum Scope {
52 /// Brings the generic parameters of an item into scope 52 /// Brings the generic parameters of an item into scope
53 GenericParams { def: GenericDefId, params: Arc<GenericParams> }, 53 GenericParams { def: GenericDefId, params: Arc<GenericParams> },
54 /// Brings `Self` in `impl` block into scope 54 /// Brings `Self` in `impl` block into scope
55 ImplBlockScope(ImplId), 55 ImplDefScope(ImplId),
56 /// Brings `Self` in enum, struct and union definitions into scope 56 /// Brings `Self` in enum, struct and union definitions into scope
57 AdtScope(AdtId), 57 AdtScope(AdtId),
58 /// Local bindings 58 /// Local bindings
@@ -154,7 +154,7 @@ impl Resolver {
154 match scope { 154 match scope {
155 Scope::ExprScope(_) => continue, 155 Scope::ExprScope(_) => continue,
156 Scope::GenericParams { .. } 156 Scope::GenericParams { .. }
157 | Scope::ImplBlockScope(_) 157 | Scope::ImplDefScope(_)
158 | Scope::LocalItemsScope(_) 158 | Scope::LocalItemsScope(_)
159 if skip_to_mod => 159 if skip_to_mod =>
160 { 160 {
@@ -170,7 +170,7 @@ impl Resolver {
170 )); 170 ));
171 } 171 }
172 } 172 }
173 Scope::ImplBlockScope(impl_) => { 173 Scope::ImplDefScope(impl_) => {
174 if first_name == &name![Self] { 174 if first_name == &name![Self] {
175 let idx = if path.segments.len() == 1 { None } else { Some(1) }; 175 let idx = if path.segments.len() == 1 { None } else { Some(1) };
176 return Some((TypeNs::SelfType(*impl_), idx)); 176 return Some((TypeNs::SelfType(*impl_), idx));
@@ -263,7 +263,7 @@ impl Resolver {
263 Scope::AdtScope(_) 263 Scope::AdtScope(_)
264 | Scope::ExprScope(_) 264 | Scope::ExprScope(_)
265 | Scope::GenericParams { .. } 265 | Scope::GenericParams { .. }
266 | Scope::ImplBlockScope(_) 266 | Scope::ImplDefScope(_)
267 | Scope::LocalItemsScope(_) 267 | Scope::LocalItemsScope(_)
268 if skip_to_mod => 268 if skip_to_mod =>
269 { 269 {
@@ -291,7 +291,7 @@ impl Resolver {
291 } 291 }
292 Scope::GenericParams { .. } => continue, 292 Scope::GenericParams { .. } => continue,
293 293
294 Scope::ImplBlockScope(impl_) if n_segments > 1 => { 294 Scope::ImplDefScope(impl_) if n_segments > 1 => {
295 if first_name == &name![Self] { 295 if first_name == &name![Self] {
296 let ty = TypeNs::SelfType(*impl_); 296 let ty = TypeNs::SelfType(*impl_);
297 return Some(ResolveValueResult::Partial(ty, 1)); 297 return Some(ResolveValueResult::Partial(ty, 1));
@@ -303,7 +303,7 @@ impl Resolver {
303 return Some(ResolveValueResult::Partial(ty, 1)); 303 return Some(ResolveValueResult::Partial(ty, 1));
304 } 304 }
305 } 305 }
306 Scope::ImplBlockScope(_) | Scope::AdtScope(_) => continue, 306 Scope::ImplDefScope(_) | Scope::AdtScope(_) => continue,
307 307
308 Scope::ModuleScope(m) => { 308 Scope::ModuleScope(m) => {
309 let (module_def, idx) = m.crate_def_map.resolve_path( 309 let (module_def, idx) = m.crate_def_map.resolve_path(
@@ -503,7 +503,7 @@ impl Scope {
503 } 503 }
504 } 504 }
505 } 505 }
506 Scope::ImplBlockScope(i) => { 506 Scope::ImplDefScope(i) => {
507 f(name![Self], ScopeDef::ImplSelfType(*i)); 507 f(name![Self], ScopeDef::ImplSelfType(*i));
508 } 508 }
509 Scope::AdtScope(i) => { 509 Scope::AdtScope(i) => {
@@ -550,8 +550,8 @@ impl Resolver {
550 self.push_scope(Scope::GenericParams { def, params }) 550 self.push_scope(Scope::GenericParams { def, params })
551 } 551 }
552 552
553 fn push_impl_block_scope(self, impl_block: ImplId) -> Resolver { 553 fn push_impl_def_scope(self, impl_def: ImplId) -> Resolver {
554 self.push_scope(Scope::ImplBlockScope(impl_block)) 554 self.push_scope(Scope::ImplDefScope(impl_def))
555 } 555 }
556 556
557 fn push_module_scope( 557 fn push_module_scope(
@@ -634,7 +634,7 @@ impl HasResolver for ImplId {
634 .container 634 .container
635 .resolver(db) 635 .resolver(db)
636 .push_generic_params_scope(db, self.into()) 636 .push_generic_params_scope(db, self.into())
637 .push_impl_block_scope(self) 637 .push_impl_def_scope(self)
638 } 638 }
639} 639}
640 640
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs
index e9bfcfa17..85d85182f 100644
--- a/crates/ra_hir_ty/src/db.rs
+++ b/crates/ra_hir_ty/src/db.rs
@@ -11,7 +11,7 @@ use ra_db::{impl_intern_key, salsa, CrateId};
11use ra_prof::profile; 11use ra_prof::profile;
12 12
13use crate::{ 13use crate::{
14 method_resolution::CrateImplBlocks, 14 method_resolution::CrateImplDefs,
15 traits::{chalk, AssocTyValue, Impl}, 15 traits::{chalk, AssocTyValue, Impl},
16 Binders, CallableDef, GenericPredicate, InferenceResult, PolyFnSig, Substs, TraitRef, Ty, 16 Binders, CallableDef, GenericPredicate, InferenceResult, PolyFnSig, Substs, TraitRef, Ty,
17 TyDefId, TypeCtor, ValueTyDefId, 17 TyDefId, TypeCtor, ValueTyDefId,
@@ -59,8 +59,8 @@ pub trait HirDatabase: DefDatabase {
59 #[salsa::invoke(crate::lower::generic_defaults_query)] 59 #[salsa::invoke(crate::lower::generic_defaults_query)]
60 fn generic_defaults(&self, def: GenericDefId) -> Substs; 60 fn generic_defaults(&self, def: GenericDefId) -> Substs;
61 61
62 #[salsa::invoke(crate::method_resolution::CrateImplBlocks::impls_in_crate_query)] 62 #[salsa::invoke(crate::method_resolution::CrateImplDefs::impls_in_crate_query)]
63 fn impls_in_crate(&self, krate: CrateId) -> Arc<CrateImplBlocks>; 63 fn impls_in_crate(&self, krate: CrateId) -> Arc<CrateImplDefs>;
64 64
65 #[salsa::invoke(crate::traits::impls_for_trait_query)] 65 #[salsa::invoke(crate::traits::impls_for_trait_query)]
66 fn impls_for_trait(&self, krate: CrateId, trait_: TraitId) -> Arc<[ImplId]>; 66 fn impls_for_trait(&self, krate: CrateId, trait_: TraitId) -> Arc<[ImplId]>;
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs
index 569d46cc3..377f44fa7 100644
--- a/crates/ra_hir_ty/src/infer.rs
+++ b/crates/ra_hir_ty/src/infer.rs
@@ -28,7 +28,7 @@ use hir_def::{
28 path::{path, Path}, 28 path::{path, Path},
29 resolver::{HasResolver, Resolver, TypeNs}, 29 resolver::{HasResolver, Resolver, TypeNs},
30 type_ref::{Mutability, TypeRef}, 30 type_ref::{Mutability, TypeRef},
31 AdtId, AssocItemId, DefWithBodyId, FunctionId, StructFieldId, TypeAliasId, VariantId, 31 AdtId, AssocItemId, DefWithBodyId, FunctionId, StructFieldId, TraitId, TypeAliasId, VariantId,
32}; 32};
33use hir_expand::{diagnostics::DiagnosticSink, name::name}; 33use hir_expand::{diagnostics::DiagnosticSink, name::name};
34use ra_arena::map::ArenaMap; 34use ra_arena::map::ArenaMap;
@@ -540,8 +540,12 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
540 Some(struct_.into()) 540 Some(struct_.into())
541 } 541 }
542 542
543 fn resolve_ops_index(&self) -> Option<TraitId> {
544 self.resolve_lang_item("index")?.as_trait()
545 }
546
543 fn resolve_ops_index_output(&self) -> Option<TypeAliasId> { 547 fn resolve_ops_index_output(&self) -> Option<TypeAliasId> {
544 let trait_ = self.resolve_lang_item("index")?.as_trait()?; 548 let trait_ = self.resolve_ops_index()?;
545 self.db.trait_data(trait_).associated_type_by_name(&name![Output]) 549 self.db.trait_data(trait_).associated_type_by_name(&name![Output])
546 } 550 }
547} 551}
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs
index 3db5b2b51..e89cc7298 100644
--- a/crates/ra_hir_ty/src/infer/expr.rs
+++ b/crates/ra_hir_ty/src/infer/expr.rs
@@ -429,11 +429,27 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
429 let base_ty = self.infer_expr_inner(*base, &Expectation::none()); 429 let base_ty = self.infer_expr_inner(*base, &Expectation::none());
430 let index_ty = self.infer_expr(*index, &Expectation::none()); 430 let index_ty = self.infer_expr(*index, &Expectation::none());
431 431
432 self.resolve_associated_type_with_params( 432 if let (Some(index_trait), Some(krate)) =
433 base_ty, 433 (self.resolve_ops_index(), self.resolver.krate())
434 self.resolve_ops_index_output(), 434 {
435 &[index_ty], 435 let canonicalized = self.canonicalizer().canonicalize_ty(base_ty);
436 ) 436 let self_ty = method_resolution::resolve_indexing_op(
437 self.db,
438 &canonicalized.value,
439 self.trait_env.clone(),
440 krate,
441 index_trait,
442 );
443 let self_ty =
444 self_ty.map_or(Ty::Unknown, |t| canonicalized.decanonicalize_ty(t.value));
445 self.resolve_associated_type_with_params(
446 self_ty,
447 self.resolve_ops_index_output(),
448 &[index_ty],
449 )
450 } else {
451 Ty::Unknown
452 }
437 } 453 }
438 Expr::Tuple { exprs } => { 454 Expr::Tuple { exprs } => {
439 let mut tys = match &expected.ty { 455 let mut tys = match &expected.ty {
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs
index 988d83af5..74b908c2e 100644
--- a/crates/ra_hir_ty/src/method_resolution.rs
+++ b/crates/ra_hir_ty/src/method_resolution.rs
@@ -20,7 +20,7 @@ use crate::{
20 db::HirDatabase, 20 db::HirDatabase,
21 primitive::{FloatBitness, Uncertain}, 21 primitive::{FloatBitness, Uncertain},
22 utils::all_super_traits, 22 utils::all_super_traits,
23 Canonical, InEnvironment, TraitEnvironment, TraitRef, Ty, TypeCtor, TypeWalk, 23 ApplicationTy, Canonical, InEnvironment, TraitEnvironment, TraitRef, Ty, TypeCtor, TypeWalk,
24}; 24};
25 25
26/// This is used as a key for indexing impls. 26/// This is used as a key for indexing impls.
@@ -42,19 +42,19 @@ impl TyFingerprint {
42} 42}
43 43
44#[derive(Debug, PartialEq, Eq)] 44#[derive(Debug, PartialEq, Eq)]
45pub struct CrateImplBlocks { 45pub struct CrateImplDefs {
46 impls: FxHashMap<TyFingerprint, Vec<ImplId>>, 46 impls: FxHashMap<TyFingerprint, Vec<ImplId>>,
47 impls_by_trait: FxHashMap<TraitId, Vec<ImplId>>, 47 impls_by_trait: FxHashMap<TraitId, Vec<ImplId>>,
48} 48}
49 49
50impl CrateImplBlocks { 50impl CrateImplDefs {
51 pub(crate) fn impls_in_crate_query( 51 pub(crate) fn impls_in_crate_query(
52 db: &impl HirDatabase, 52 db: &impl HirDatabase,
53 krate: CrateId, 53 krate: CrateId,
54 ) -> Arc<CrateImplBlocks> { 54 ) -> Arc<CrateImplDefs> {
55 let _p = profile("impls_in_crate_query"); 55 let _p = profile("impls_in_crate_query");
56 let mut res = 56 let mut res =
57 CrateImplBlocks { impls: FxHashMap::default(), impls_by_trait: FxHashMap::default() }; 57 CrateImplDefs { impls: FxHashMap::default(), impls_by_trait: FxHashMap::default() };
58 58
59 let crate_def_map = db.crate_def_map(krate); 59 let crate_def_map = db.crate_def_map(krate);
60 for (_module_id, module_data) in crate_def_map.modules.iter() { 60 for (_module_id, module_data) in crate_def_map.modules.iter() {
@@ -75,12 +75,12 @@ impl CrateImplBlocks {
75 75
76 Arc::new(res) 76 Arc::new(res)
77 } 77 }
78 pub fn lookup_impl_blocks(&self, ty: &Ty) -> impl Iterator<Item = ImplId> + '_ { 78 pub fn lookup_impl_defs(&self, ty: &Ty) -> impl Iterator<Item = ImplId> + '_ {
79 let fingerprint = TyFingerprint::for_impl(ty); 79 let fingerprint = TyFingerprint::for_impl(ty);
80 fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flatten().copied() 80 fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flatten().copied()
81 } 81 }
82 82
83 pub fn lookup_impl_blocks_for_trait(&self, tr: TraitId) -> impl Iterator<Item = ImplId> + '_ { 83 pub fn lookup_impl_defs_for_trait(&self, tr: TraitId) -> impl Iterator<Item = ImplId> + '_ {
84 self.impls_by_trait.get(&tr).into_iter().flatten().copied() 84 self.impls_by_trait.get(&tr).into_iter().flatten().copied()
85 } 85 }
86 86
@@ -131,7 +131,7 @@ impl Ty {
131 let res = lang_item_targets 131 let res = lang_item_targets
132 .into_iter() 132 .into_iter()
133 .filter_map(|it| match it { 133 .filter_map(|it| match it {
134 LangItemTarget::ImplBlockId(it) => Some(it), 134 LangItemTarget::ImplDefId(it) => Some(it),
135 _ => None, 135 _ => None,
136 }) 136 })
137 .map(|it| it.lookup(db).container.module(db).krate) 137 .map(|it| it.lookup(db).container.module(db).krate)
@@ -177,7 +177,7 @@ pub enum LookupMode {
177} 177}
178 178
179// This would be nicer if it just returned an iterator, but that runs into 179// This would be nicer if it just returned an iterator, but that runs into
180// lifetime problems, because we need to borrow temp `CrateImplBlocks`. 180// lifetime problems, because we need to borrow temp `CrateImplDefs`.
181// FIXME add a context type here? 181// FIXME add a context type here?
182pub fn iterate_method_candidates<T>( 182pub fn iterate_method_candidates<T>(
183 ty: &Canonical<Ty>, 183 ty: &Canonical<Ty>,
@@ -214,7 +214,7 @@ pub fn iterate_method_candidates<T>(
214 // the methods by autoderef order of *receiver types*, not *self 214 // the methods by autoderef order of *receiver types*, not *self
215 // types*. 215 // types*.
216 216
217 let deref_chain: Vec<_> = autoderef::autoderef(db, Some(krate), ty).collect(); 217 let deref_chain = autoderef_method_receiver(db, krate, ty);
218 for i in 0..deref_chain.len() { 218 for i in 0..deref_chain.len() {
219 if let Some(result) = iterate_method_candidates_with_autoref( 219 if let Some(result) = iterate_method_candidates_with_autoref(
220 &deref_chain[i..], 220 &deref_chain[i..],
@@ -425,8 +425,8 @@ fn iterate_inherent_methods<T>(
425 for krate in self_ty.value.def_crates(db, krate)? { 425 for krate in self_ty.value.def_crates(db, krate)? {
426 let impls = db.impls_in_crate(krate); 426 let impls = db.impls_in_crate(krate);
427 427
428 for impl_block in impls.lookup_impl_blocks(&self_ty.value) { 428 for impl_def in impls.lookup_impl_defs(&self_ty.value) {
429 for &item in db.impl_data(impl_block).items.iter() { 429 for &item in db.impl_data(impl_def).items.iter() {
430 if !is_valid_candidate(db, name, receiver_ty, item, self_ty) { 430 if !is_valid_candidate(db, name, receiver_ty, item, self_ty) {
431 continue; 431 continue;
432 } 432 }
@@ -434,8 +434,7 @@ fn iterate_inherent_methods<T>(
434 // that the impl is for. If we have a receiver type, this 434 // that the impl is for. If we have a receiver type, this
435 // already happens in `is_valid_candidate` above; if not, we 435 // already happens in `is_valid_candidate` above; if not, we
436 // check it here 436 // check it here
437 if receiver_ty.is_none() && inherent_impl_substs(db, impl_block, self_ty).is_none() 437 if receiver_ty.is_none() && inherent_impl_substs(db, impl_def, self_ty).is_none() {
438 {
439 test_utils::tested_by!(impl_self_type_match_without_receiver); 438 test_utils::tested_by!(impl_self_type_match_without_receiver);
440 continue; 439 continue;
441 } 440 }
@@ -448,6 +447,25 @@ fn iterate_inherent_methods<T>(
448 None 447 None
449} 448}
450 449
450/// Returns the self type for the index trait call.
451pub fn resolve_indexing_op(
452 db: &impl HirDatabase,
453 ty: &Canonical<Ty>,
454 env: Arc<TraitEnvironment>,
455 krate: CrateId,
456 index_trait: TraitId,
457) -> Option<Canonical<Ty>> {
458 let ty = InEnvironment { value: ty.clone(), environment: env.clone() };
459 let deref_chain = autoderef_method_receiver(db, krate, ty);
460 for ty in deref_chain {
461 let goal = generic_implements_goal(db, env.clone(), index_trait, ty.clone());
462 if db.trait_solve(krate, goal).is_some() {
463 return Some(ty);
464 }
465 }
466 None
467}
468
451fn is_valid_candidate( 469fn is_valid_candidate(
452 db: &impl HirDatabase, 470 db: &impl HirDatabase,
453 name: Option<&Name>, 471 name: Option<&Name>,
@@ -549,3 +567,20 @@ fn generic_implements_goal(
549 let obligation = super::Obligation::Trait(trait_ref); 567 let obligation = super::Obligation::Trait(trait_ref);
550 Canonical { num_vars, value: InEnvironment::new(env, obligation) } 568 Canonical { num_vars, value: InEnvironment::new(env, obligation) }
551} 569}
570
571fn autoderef_method_receiver(
572 db: &impl HirDatabase,
573 krate: CrateId,
574 ty: InEnvironment<Canonical<Ty>>,
575) -> Vec<Canonical<Ty>> {
576 let mut deref_chain: Vec<_> = autoderef::autoderef(db, Some(krate), ty).collect();
577 // As a last step, we can do array unsizing (that's the only unsizing that rustc does for method receivers!)
578 if let Some(Ty::Apply(ApplicationTy { ctor: TypeCtor::Array, parameters })) =
579 deref_chain.last().map(|ty| &ty.value)
580 {
581 let num_vars = deref_chain.last().unwrap().num_vars;
582 let unsized_ty = Ty::apply(TypeCtor::Slice, parameters.clone());
583 deref_chain.push(Canonical { value: unsized_ty, num_vars })
584 }
585 deref_chain
586}
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs
index 652420ea8..53cd81d46 100644
--- a/crates/ra_hir_ty/src/tests/macros.rs
+++ b/crates/ra_hir_ty/src/tests/macros.rs
@@ -4,7 +4,7 @@ use insta::assert_snapshot;
4use ra_db::fixture::WithFixture; 4use ra_db::fixture::WithFixture;
5 5
6#[test] 6#[test]
7fn cfg_impl_block() { 7fn cfg_impl_def() {
8 let (db, pos) = TestDB::with_position( 8 let (db, pos) = TestDB::with_position(
9 r#" 9 r#"
10//- /main.rs crate:main deps:foo cfg:test 10//- /main.rs crate:main deps:foo cfg:test
@@ -347,17 +347,17 @@ mod m {
347m::foo!(foo); 347m::foo!(foo);
348use foo as bar; 348use foo as bar;
349fn f() -> bar { 0 } 349fn f() -> bar { 0 }
350fn main() { 350fn main() {
351 let _a = f(); 351 let _a = f();
352} 352}
353"#), 353"#),
354 @r###" 354 @r###"
355 [159; 164) '{ 0 }': u64 355 [159; 164) '{ 0 }': u64
356 [161; 162) '0': u64 356 [161; 162) '0': u64
357 [175; 199) '{ ...f(); }': () 357 [175; 197) '{ ...f(); }': ()
358 [187; 189) '_a': u64 358 [185; 187) '_a': u64
359 [193; 194) 'f': fn f() -> u64 359 [191; 192) 'f': fn f() -> u64
360 [193; 196) 'f()': u64 360 [191; 194) 'f()': u64
361 "### 361 "###
362 ); 362 );
363} 363}
diff --git a/crates/ra_hir_ty/src/tests/method_resolution.rs b/crates/ra_hir_ty/src/tests/method_resolution.rs
index 644d59e17..f9b394f05 100644
--- a/crates/ra_hir_ty/src/tests/method_resolution.rs
+++ b/crates/ra_hir_ty/src/tests/method_resolution.rs
@@ -839,6 +839,24 @@ fn test() { (&S).foo()<|>; }
839} 839}
840 840
841#[test] 841#[test]
842fn method_resolution_unsize_array() {
843 let t = type_at(
844 r#"
845//- /main.rs
846#[lang = "slice"]
847impl<T> [T] {
848 fn len(&self) -> usize { loop {} }
849}
850fn test() {
851 let a = [1, 2, 3];
852 a.len()<|>;
853}
854"#,
855 );
856 assert_eq!(t, "usize");
857}
858
859#[test]
842fn method_resolution_trait_from_prelude() { 860fn method_resolution_trait_from_prelude() {
843 let (db, pos) = TestDB::with_position( 861 let (db, pos) = TestDB::with_position(
844 r#" 862 r#"
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs
index 7d796d0b9..547010b35 100644
--- a/crates/ra_hir_ty/src/tests/traits.rs
+++ b/crates/ra_hir_ty/src/tests/traits.rs
@@ -568,6 +568,34 @@ mod ops {
568} 568}
569 569
570#[test] 570#[test]
571fn infer_ops_index_autoderef() {
572 let (db, pos) = TestDB::with_position(
573 r#"
574//- /main.rs crate:main deps:std
575fn test() {
576 let a = &[1u32, 2, 3];
577 let b = a[1];
578 b<|>;
579}
580
581//- /std.rs crate:std
582impl<T> ops::Index<u32> for [T] {
583 type Output = T;
584}
585
586#[prelude_import] use ops::*;
587mod ops {
588 #[lang = "index"]
589 pub trait Index<Idx> {
590 type Output;
591 }
592}
593"#,
594 );
595 assert_eq!("u32", type_at_pos(&db, pos));
596}
597
598#[test]
571fn deref_trait() { 599fn deref_trait() {
572 let t = type_at( 600 let t = type_at(
573 r#" 601 r#"
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs
index 17aef9490..bc6ee2600 100644
--- a/crates/ra_hir_ty/src/traits.rs
+++ b/crates/ra_hir_ty/src/traits.rs
@@ -131,8 +131,8 @@ pub(crate) fn impls_for_trait_query(
131 for dep in db.crate_graph().dependencies(krate) { 131 for dep in db.crate_graph().dependencies(krate) {
132 impls.extend(db.impls_for_trait(dep.crate_id, trait_).iter()); 132 impls.extend(db.impls_for_trait(dep.crate_id, trait_).iter());
133 } 133 }
134 let crate_impl_blocks = db.impls_in_crate(krate); 134 let crate_impl_defs = db.impls_in_crate(krate);
135 impls.extend(crate_impl_blocks.lookup_impl_blocks_for_trait(trait_)); 135 impls.extend(crate_impl_defs.lookup_impl_defs_for_trait(trait_));
136 impls.into_iter().collect() 136 impls.into_iter().collect()
137} 137}
138 138
@@ -346,7 +346,7 @@ pub struct UnsizeToSuperTraitObjectData {
346#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 346#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
347pub enum Impl { 347pub enum Impl {
348 /// A normal impl from an impl block. 348 /// A normal impl from an impl block.
349 ImplBlock(ImplId), 349 ImplDef(ImplId),
350 /// Closure types implement the Fn traits synthetically. 350 /// Closure types implement the Fn traits synthetically.
351 ClosureFnTraitImpl(ClosureFnTraitImplData), 351 ClosureFnTraitImpl(ClosureFnTraitImplData),
352 /// [T; n]: Unsize<[T]> 352 /// [T; n]: Unsize<[T]>
diff --git a/crates/ra_hir_ty/src/traits/builtin.rs b/crates/ra_hir_ty/src/traits/builtin.rs
index cc0f3eeb4..03f9b4e27 100644
--- a/crates/ra_hir_ty/src/traits/builtin.rs
+++ b/crates/ra_hir_ty/src/traits/builtin.rs
@@ -96,7 +96,7 @@ fn get_builtin_unsize_impls(
96 96
97pub(super) fn impl_datum(db: &impl HirDatabase, krate: CrateId, impl_: Impl) -> BuiltinImplData { 97pub(super) fn impl_datum(db: &impl HirDatabase, krate: CrateId, impl_: Impl) -> BuiltinImplData {
98 match impl_ { 98 match impl_ {
99 Impl::ImplBlock(_) => unreachable!(), 99 Impl::ImplDef(_) => unreachable!(),
100 Impl::ClosureFnTraitImpl(data) => closure_fn_trait_impl_datum(db, krate, data), 100 Impl::ClosureFnTraitImpl(data) => closure_fn_trait_impl_datum(db, krate, data),
101 Impl::UnsizeArray => array_unsize_impl_datum(db, krate), 101 Impl::UnsizeArray => array_unsize_impl_datum(db, krate),
102 Impl::UnsizeToTraitObject(trait_) => trait_object_unsize_impl_datum(db, krate, trait_), 102 Impl::UnsizeToTraitObject(trait_) => trait_object_unsize_impl_datum(db, krate, trait_),
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 5b6c1a62e..4001aa941 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -576,7 +576,7 @@ where
576 .impls_for_trait(self.krate, trait_) 576 .impls_for_trait(self.krate, trait_)
577 .iter() 577 .iter()
578 .copied() 578 .copied()
579 .map(Impl::ImplBlock) 579 .map(Impl::ImplDef)
580 .map(|impl_| impl_.to_chalk(self.db)) 580 .map(|impl_| impl_.to_chalk(self.db))
581 .collect(); 581 .collect();
582 582
@@ -712,12 +712,12 @@ pub(crate) fn impl_datum_query(
712 debug!("impl_datum {:?}", impl_id); 712 debug!("impl_datum {:?}", impl_id);
713 let impl_: Impl = from_chalk(db, impl_id); 713 let impl_: Impl = from_chalk(db, impl_id);
714 match impl_ { 714 match impl_ {
715 Impl::ImplBlock(impl_block) => impl_block_datum(db, krate, impl_id, impl_block), 715 Impl::ImplDef(impl_def) => impl_def_datum(db, krate, impl_id, impl_def),
716 _ => Arc::new(builtin::impl_datum(db, krate, impl_).to_chalk(db)), 716 _ => Arc::new(builtin::impl_datum(db, krate, impl_).to_chalk(db)),
717 } 717 }
718} 718}
719 719
720fn impl_block_datum( 720fn impl_def_datum(
721 db: &impl HirDatabase, 721 db: &impl HirDatabase,
722 krate: CrateId, 722 krate: CrateId,
723 chalk_id: ImplId, 723 chalk_id: ImplId,
@@ -815,7 +815,7 @@ fn type_alias_associated_ty_value(
815 let ty = db.ty(type_alias.into()); 815 let ty = db.ty(type_alias.into());
816 let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) }; 816 let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) };
817 let value = chalk_rust_ir::AssociatedTyValue { 817 let value = chalk_rust_ir::AssociatedTyValue {
818 impl_id: Impl::ImplBlock(impl_id).to_chalk(db), 818 impl_id: Impl::ImplDef(impl_id).to_chalk(db),
819 associated_ty_id: assoc_ty.to_chalk(db), 819 associated_ty_id: assoc_ty.to_chalk(db),
820 value: make_binders(value_bound, ty.num_binders), 820 value: make_binders(value_bound, ty.num_binders),
821 }; 821 };
diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs
index 9a27c164b..18a1d2995 100644
--- a/crates/ra_ide/src/completion/complete_trait_impl.rs
+++ b/crates/ra_ide/src/completion/complete_trait_impl.rs
@@ -3,7 +3,7 @@
3//! This module adds the completion items related to implementing associated 3//! This module adds the completion items related to implementing associated
4//! items within a `impl Trait for Struct` block. The current context node 4//! items within a `impl Trait for Struct` block. The current context node
5//! must be within either a `FN_DEF`, `TYPE_ALIAS_DEF`, or `CONST_DEF` node 5//! must be within either a `FN_DEF`, `TYPE_ALIAS_DEF`, or `CONST_DEF` node
6//! and an direct child of an `IMPL_BLOCK`. 6//! and an direct child of an `IMPL_DEF`.
7//! 7//!
8//! # Examples 8//! # Examples
9//! 9//!
@@ -55,49 +55,43 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
55 _ => false, 55 _ => false,
56 }); 56 });
57 57
58 let impl_block = trigger 58 let impl_def = trigger
59 .as_ref() 59 .as_ref()
60 .and_then(|node| node.parent()) 60 .and_then(|node| node.parent())
61 .and_then(|node| node.parent()) 61 .and_then(|node| node.parent())
62 .and_then(ast::ImplBlock::cast); 62 .and_then(ast::ImplDef::cast);
63 63
64 if let (Some(trigger), Some(impl_block)) = (trigger, impl_block) { 64 if let (Some(trigger), Some(impl_def)) = (trigger, impl_def) {
65 match trigger.kind() { 65 match trigger.kind() {
66 SyntaxKind::FN_DEF => { 66 SyntaxKind::FN_DEF => {
67 for missing_fn in 67 for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map(
68 get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { 68 |item| match item {
69 match item { 69 hir::AssocItem::Function(fn_item) => Some(fn_item),
70 hir::AssocItem::Function(fn_item) => Some(fn_item), 70 _ => None,
71 _ => None, 71 },
72 } 72 ) {
73 })
74 {
75 add_function_impl(&trigger, acc, ctx, &missing_fn); 73 add_function_impl(&trigger, acc, ctx, &missing_fn);
76 } 74 }
77 } 75 }
78 76
79 SyntaxKind::TYPE_ALIAS_DEF => { 77 SyntaxKind::TYPE_ALIAS_DEF => {
80 for missing_fn in 78 for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map(
81 get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { 79 |item| match item {
82 match item { 80 hir::AssocItem::TypeAlias(type_item) => Some(type_item),
83 hir::AssocItem::TypeAlias(type_item) => Some(type_item), 81 _ => None,
84 _ => None, 82 },
85 } 83 ) {
86 })
87 {
88 add_type_alias_impl(&trigger, acc, ctx, &missing_fn); 84 add_type_alias_impl(&trigger, acc, ctx, &missing_fn);
89 } 85 }
90 } 86 }
91 87
92 SyntaxKind::CONST_DEF => { 88 SyntaxKind::CONST_DEF => {
93 for missing_fn in 89 for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map(
94 get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { 90 |item| match item {
95 match item { 91 hir::AssocItem::Const(const_item) => Some(const_item),
96 hir::AssocItem::Const(const_item) => Some(const_item), 92 _ => None,
97 _ => None, 93 },
98 } 94 ) {
99 })
100 {
101 add_const_impl(&trigger, acc, ctx, &missing_fn); 95 add_const_impl(&trigger, acc, ctx, &missing_fn);
102 } 96 }
103 } 97 }
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 81321a897..9aa5a705d 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -27,7 +27,7 @@ pub(crate) struct CompletionContext<'a> {
27 pub(super) use_item_syntax: Option<ast::UseItem>, 27 pub(super) use_item_syntax: Option<ast::UseItem>,
28 pub(super) record_lit_syntax: Option<ast::RecordLit>, 28 pub(super) record_lit_syntax: Option<ast::RecordLit>,
29 pub(super) record_lit_pat: Option<ast::RecordPat>, 29 pub(super) record_lit_pat: Option<ast::RecordPat>,
30 pub(super) impl_block: Option<ast::ImplBlock>, 30 pub(super) impl_def: Option<ast::ImplDef>,
31 pub(super) is_param: bool, 31 pub(super) is_param: bool,
32 /// If a name-binding or reference to a const in a pattern. 32 /// If a name-binding or reference to a const in a pattern.
33 /// Irrefutable patterns (like let) are excluded. 33 /// Irrefutable patterns (like let) are excluded.
@@ -81,7 +81,7 @@ impl<'a> CompletionContext<'a> {
81 use_item_syntax: None, 81 use_item_syntax: None,
82 record_lit_syntax: None, 82 record_lit_syntax: None,
83 record_lit_pat: None, 83 record_lit_pat: None,
84 impl_block: None, 84 impl_def: None,
85 is_param: false, 85 is_param: false,
86 is_pat_binding: false, 86 is_pat_binding: false,
87 is_trivial_path: false, 87 is_trivial_path: false,
@@ -161,12 +161,12 @@ impl<'a> CompletionContext<'a> {
161 self.record_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset); 161 self.record_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset);
162 } 162 }
163 163
164 self.impl_block = self 164 self.impl_def = self
165 .token 165 .token
166 .parent() 166 .parent()
167 .ancestors() 167 .ancestors()
168 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) 168 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE)
169 .find_map(ast::ImplBlock::cast); 169 .find_map(ast::ImplDef::cast);
170 170
171 let top_node = name_ref 171 let top_node = name_ref
172 .syntax() 172 .syntax()
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs
index 5afb23764..4d3dd477e 100644
--- a/crates/ra_ide/src/display/navigation_target.rs
+++ b/crates/ra_ide/src/display/navigation_target.rs
@@ -269,7 +269,7 @@ impl ToNav for hir::Module {
269 } 269 }
270} 270}
271 271
272impl ToNav for hir::ImplBlock { 272impl ToNav for hir::ImplDef {
273 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { 273 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
274 let src = self.source(db); 274 let src = self.source(db);
275 let frange = if let Some(item) = self.is_builtin_derive(db) { 275 let frange = if let Some(item) = self.is_builtin_derive(db) {
diff --git a/crates/ra_ide/src/display/structure.rs b/crates/ra_ide/src/display/structure.rs
index 944cc79df..5774e9a8b 100644
--- a/crates/ra_ide/src/display/structure.rs
+++ b/crates/ra_ide/src/display/structure.rs
@@ -129,7 +129,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
129 ast::RecordFieldDef(it) => { decl_with_ascription(it) }, 129 ast::RecordFieldDef(it) => { decl_with_ascription(it) },
130 ast::ConstDef(it) => { decl_with_ascription(it) }, 130 ast::ConstDef(it) => { decl_with_ascription(it) },
131 ast::StaticDef(it) => { decl_with_ascription(it) }, 131 ast::StaticDef(it) => { decl_with_ascription(it) },
132 ast::ImplBlock(it) => { 132 ast::ImplDef(it) => {
133 let target_type = it.target_type()?; 133 let target_type = it.target_type()?;
134 let target_trait = it.target_trait(); 134 let target_trait = it.target_trait();
135 let label = match target_trait { 135 let label = match target_trait {
@@ -360,7 +360,7 @@ fn very_obsolete() {}
360 label: "impl E", 360 label: "impl E",
361 navigation_range: [239; 240), 361 navigation_range: [239; 240),
362 node_range: [234; 243), 362 node_range: [234; 243),
363 kind: IMPL_BLOCK, 363 kind: IMPL_DEF,
364 detail: None, 364 detail: None,
365 deprecated: false, 365 deprecated: false,
366 }, 366 },
@@ -369,7 +369,7 @@ fn very_obsolete() {}
369 label: "impl fmt::Debug for E", 369 label: "impl fmt::Debug for E",
370 navigation_range: [265; 266), 370 navigation_range: [265; 266),
371 node_range: [245; 269), 371 node_range: [245; 269),
372 kind: IMPL_BLOCK, 372 kind: IMPL_DEF,
373 detail: None, 373 detail: None,
374 deprecated: false, 374 deprecated: false,
375 }, 375 },
diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs
index 5a079de27..f6667cb33 100644
--- a/crates/ra_ide/src/expand_macro.rs
+++ b/crates/ra_ide/src/expand_macro.rs
@@ -195,7 +195,7 @@ fn some_thing() -> u32 {
195 mat<|>ch_ast! { 195 mat<|>ch_ast! {
196 match container { 196 match container {
197 ast::TraitDef(it) => {}, 197 ast::TraitDef(it) => {},
198 ast::ImplBlock(it) => {}, 198 ast::ImplDef(it) => {},
199 _ => { continue }, 199 _ => { continue },
200 } 200 }
201 } 201 }
@@ -207,7 +207,7 @@ fn some_thing() -> u32 {
207 assert_snapshot!(res.expansion, @r###" 207 assert_snapshot!(res.expansion, @r###"
208{ 208{
209 if let Some(it) = ast::TraitDef::cast(container.clone()){} 209 if let Some(it) = ast::TraitDef::cast(container.clone()){}
210 else if let Some(it) = ast::ImplBlock::cast(container.clone()){} 210 else if let Some(it) = ast::ImplDef::cast(container.clone()){}
211 else { 211 else {
212 { 212 {
213 continue 213 continue
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index 621ab982c..e67585203 100644
--- a/crates/ra_ide/src/goto_definition.rs
+++ b/crates/ra_ide/src/goto_definition.rs
@@ -477,7 +477,7 @@ mod tests {
477 } 477 }
478 } 478 }
479 ", 479 ",
480 "impl IMPL_BLOCK FileId(1) [12; 73)", 480 "impl IMPL_DEF FileId(1) [12; 73)",
481 "impl Foo {...}", 481 "impl Foo {...}",
482 ); 482 );
483 483
@@ -491,7 +491,7 @@ mod tests {
491 } 491 }
492 } 492 }
493 ", 493 ",
494 "impl IMPL_BLOCK FileId(1) [12; 73)", 494 "impl IMPL_DEF FileId(1) [12; 73)",
495 "impl Foo {...}", 495 "impl Foo {...}",
496 ); 496 );
497 497
@@ -505,7 +505,7 @@ mod tests {
505 } 505 }
506 } 506 }
507 ", 507 ",
508 "impl IMPL_BLOCK FileId(1) [15; 75)", 508 "impl IMPL_DEF FileId(1) [15; 75)",
509 "impl Foo {...}", 509 "impl Foo {...}",
510 ); 510 );
511 511
@@ -518,7 +518,7 @@ mod tests {
518 } 518 }
519 } 519 }
520 ", 520 ",
521 "impl IMPL_BLOCK FileId(1) [15; 62)", 521 "impl IMPL_DEF FileId(1) [15; 62)",
522 "impl Foo {...}", 522 "impl Foo {...}",
523 ); 523 );
524 } 524 }
@@ -538,7 +538,7 @@ mod tests {
538 } 538 }
539 } 539 }
540 ", 540 ",
541 "impl IMPL_BLOCK FileId(1) [49; 115)", 541 "impl IMPL_DEF FileId(1) [49; 115)",
542 "impl Make for Foo {...}", 542 "impl Make for Foo {...}",
543 ); 543 );
544 544
@@ -555,7 +555,7 @@ mod tests {
555 } 555 }
556 } 556 }
557 ", 557 ",
558 "impl IMPL_BLOCK FileId(1) [49; 115)", 558 "impl IMPL_DEF FileId(1) [49; 115)",
559 "impl Make for Foo {...}", 559 "impl Make for Foo {...}",
560 ); 560 );
561 } 561 }
diff --git a/crates/ra_ide/src/impls.rs b/crates/ra_ide/src/impls.rs
index bf82b2a16..68529c8a5 100644
--- a/crates/ra_ide/src/impls.rs
+++ b/crates/ra_ide/src/impls.rs
@@ -1,6 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir::{Crate, ImplBlock, Semantics}; 3use hir::{Crate, ImplDef, Semantics};
4use ra_ide_db::RootDatabase; 4use ra_ide_db::RootDatabase;
5use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; 5use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
6 6
@@ -42,12 +42,12 @@ fn impls_for_def(
42 ast::NominalDef::UnionDef(def) => sema.to_def(def)?.ty(sema.db), 42 ast::NominalDef::UnionDef(def) => sema.to_def(def)?.ty(sema.db),
43 }; 43 };
44 44
45 let impls = ImplBlock::all_in_crate(sema.db, krate); 45 let impls = ImplDef::all_in_crate(sema.db, krate);
46 46
47 Some( 47 Some(
48 impls 48 impls
49 .into_iter() 49 .into_iter()
50 .filter(|impl_block| ty.is_equal_for_find_impls(&impl_block.target_ty(sema.db))) 50 .filter(|impl_def| ty.is_equal_for_find_impls(&impl_def.target_ty(sema.db)))
51 .map(|imp| imp.to_nav(sema.db)) 51 .map(|imp| imp.to_nav(sema.db))
52 .collect(), 52 .collect(),
53 ) 53 )
@@ -60,7 +60,7 @@ fn impls_for_trait(
60) -> Option<Vec<NavigationTarget>> { 60) -> Option<Vec<NavigationTarget>> {
61 let tr = sema.to_def(node)?; 61 let tr = sema.to_def(node)?;
62 62
63 let impls = ImplBlock::for_trait(sema.db, krate, tr); 63 let impls = ImplDef::for_trait(sema.db, krate, tr);
64 64
65 Some(impls.into_iter().map(|imp| imp.to_nav(sema.db)).collect()) 65 Some(impls.into_iter().map(|imp| imp.to_nav(sema.db)).collect())
66} 66}
@@ -86,7 +86,7 @@ mod tests {
86 struct Foo<|>; 86 struct Foo<|>;
87 impl Foo {} 87 impl Foo {}
88 ", 88 ",
89 &["impl IMPL_BLOCK FileId(1) [12; 23)"], 89 &["impl IMPL_DEF FileId(1) [12; 23)"],
90 ); 90 );
91 } 91 }
92 92
@@ -99,7 +99,7 @@ mod tests {
99 impl Foo {} 99 impl Foo {}
100 impl Foo {} 100 impl Foo {}
101 ", 101 ",
102 &["impl IMPL_BLOCK FileId(1) [12; 23)", "impl IMPL_BLOCK FileId(1) [24; 35)"], 102 &["impl IMPL_DEF FileId(1) [12; 23)", "impl IMPL_DEF FileId(1) [24; 35)"],
103 ); 103 );
104 } 104 }
105 105
@@ -116,7 +116,7 @@ mod tests {
116 impl super::Foo {} 116 impl super::Foo {}
117 } 117 }
118 ", 118 ",
119 &["impl IMPL_BLOCK FileId(1) [24; 42)", "impl IMPL_BLOCK FileId(1) [57; 75)"], 119 &["impl IMPL_DEF FileId(1) [24; 42)", "impl IMPL_DEF FileId(1) [57; 75)"],
120 ); 120 );
121 } 121 }
122 122
@@ -133,7 +133,7 @@ mod tests {
133 //- /b.rs 133 //- /b.rs
134 impl crate::Foo {} 134 impl crate::Foo {}
135 ", 135 ",
136 &["impl IMPL_BLOCK FileId(2) [0; 18)", "impl IMPL_BLOCK FileId(3) [0; 18)"], 136 &["impl IMPL_DEF FileId(2) [0; 18)", "impl IMPL_DEF FileId(3) [0; 18)"],
137 ); 137 );
138 } 138 }
139 139
@@ -146,7 +146,7 @@ mod tests {
146 struct Foo; 146 struct Foo;
147 impl T for Foo {} 147 impl T for Foo {}
148 ", 148 ",
149 &["impl IMPL_BLOCK FileId(1) [23; 40)"], 149 &["impl IMPL_DEF FileId(1) [23; 40)"],
150 ); 150 );
151 } 151 }
152 152
@@ -164,7 +164,7 @@ mod tests {
164 //- /b.rs 164 //- /b.rs
165 impl crate::T for crate::Foo {} 165 impl crate::T for crate::Foo {}
166 ", 166 ",
167 &["impl IMPL_BLOCK FileId(2) [0; 31)", "impl IMPL_BLOCK FileId(3) [0; 31)"], 167 &["impl IMPL_DEF FileId(2) [0; 31)", "impl IMPL_DEF FileId(3) [0; 31)"],
168 ); 168 );
169 } 169 }
170 170
@@ -180,9 +180,9 @@ mod tests {
180 impl T for &Foo {} 180 impl T for &Foo {}
181 ", 181 ",
182 &[ 182 &[
183 "impl IMPL_BLOCK FileId(1) [23; 34)", 183 "impl IMPL_DEF FileId(1) [23; 34)",
184 "impl IMPL_BLOCK FileId(1) [35; 52)", 184 "impl IMPL_DEF FileId(1) [35; 52)",
185 "impl IMPL_BLOCK FileId(1) [53; 71)", 185 "impl IMPL_DEF FileId(1) [53; 71)",
186 ], 186 ],
187 ); 187 );
188 } 188 }
@@ -195,7 +195,7 @@ mod tests {
195 #[derive(Copy)] 195 #[derive(Copy)]
196 struct Foo<|>; 196 struct Foo<|>;
197 ", 197 ",
198 &["impl IMPL_BLOCK FileId(1) [0; 15)"], 198 &["impl IMPL_DEF FileId(1) [0; 15)"],
199 ); 199 );
200 } 200 }
201} 201}
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 35e3f782d..69098a630 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -5,7 +5,7 @@ use ra_ide_db::RootDatabase;
5use ra_prof::profile; 5use ra_prof::profile;
6use ra_syntax::{ 6use ra_syntax::{
7 ast::{self, ArgListOwner, AstNode, TypeAscriptionOwner}, 7 ast::{self, ArgListOwner, AstNode, TypeAscriptionOwner},
8 match_ast, SmolStr, SyntaxNode, TextRange, 8 match_ast, SmolStr, TextRange,
9}; 9};
10 10
11use crate::{FileId, FunctionSignature}; 11use crate::{FileId, FunctionSignature};
@@ -28,50 +28,76 @@ pub(crate) fn inlay_hints(
28 file_id: FileId, 28 file_id: FileId,
29 max_inlay_hint_length: Option<usize>, 29 max_inlay_hint_length: Option<usize>,
30) -> Vec<InlayHint> { 30) -> Vec<InlayHint> {
31 let _p = profile("inlay_hints");
31 let sema = Semantics::new(db); 32 let sema = Semantics::new(db);
32 let file = sema.parse(file_id); 33 let file = sema.parse(file_id);
34
33 let mut res = Vec::new(); 35 let mut res = Vec::new();
34 for node in file.syntax().descendants() { 36 for node in file.syntax().descendants() {
35 get_inlay_hints(&mut res, &sema, &node, max_inlay_hint_length); 37 match_ast! {
38 match node {
39 ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, ast::Expr::from(it)); },
40 ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, ast::Expr::from(it)); },
41 ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, max_inlay_hint_length, it); },
42 _ => (),
43 }
44 }
36 } 45 }
37 res 46 res
38} 47}
39 48
40fn get_inlay_hints( 49fn get_param_name_hints(
50 acc: &mut Vec<InlayHint>,
51 sema: &Semantics<RootDatabase>,
52 expr: ast::Expr,
53) -> Option<()> {
54 let args = match &expr {
55 ast::Expr::CallExpr(expr) => expr.arg_list()?.args(),
56 ast::Expr::MethodCallExpr(expr) => expr.arg_list()?.args(),
57 _ => return None,
58 };
59 let args_count = args.clone().count();
60
61 let fn_signature = get_fn_signature(sema, &expr)?;
62 let n_params_to_skip =
63 if fn_signature.has_self_param && fn_signature.parameter_names.len() > args_count {
64 1
65 } else {
66 0
67 };
68 let hints = fn_signature
69 .parameter_names
70 .iter()
71 .skip(n_params_to_skip)
72 .zip(args)
73 .filter(|(param, arg)| should_show_param_hint(&fn_signature, param, &arg))
74 .map(|(param_name, arg)| InlayHint {
75 range: arg.syntax().text_range(),
76 kind: InlayKind::ParameterHint,
77 label: param_name.into(),
78 });
79
80 acc.extend(hints);
81 Some(())
82}
83
84fn get_bind_pat_hints(
41 acc: &mut Vec<InlayHint>, 85 acc: &mut Vec<InlayHint>,
42 sema: &Semantics<RootDatabase>, 86 sema: &Semantics<RootDatabase>,
43 node: &SyntaxNode,
44 max_inlay_hint_length: Option<usize>, 87 max_inlay_hint_length: Option<usize>,
88 pat: ast::BindPat,
45) -> Option<()> { 89) -> Option<()> {
46 let _p = profile("get_inlay_hints"); 90 let ty = sema.type_of_pat(&pat.clone().into())?;
47 let db = sema.db;
48 match_ast! {
49 match node {
50 ast::CallExpr(it) => {
51 get_param_name_hints(acc, sema, ast::Expr::from(it));
52 },
53 ast::MethodCallExpr(it) => {
54 get_param_name_hints(acc, sema, ast::Expr::from(it));
55 },
56 ast::BindPat(it) => {
57 let pat = ast::Pat::from(it.clone());
58 let ty = sema.type_of_pat(&pat)?;
59
60 if should_not_display_type_hint(db, &it, &ty) {
61 return None;
62 }
63 91
64 acc.push( 92 if should_not_display_type_hint(sema.db, &pat, &ty) {
65 InlayHint { 93 return None;
66 range: pat.syntax().text_range(), 94 }
67 kind: InlayKind::TypeHint, 95
68 label: ty.display_truncated(db, max_inlay_hint_length).to_string().into(), 96 acc.push(InlayHint {
69 } 97 range: pat.syntax().text_range(),
70 ); 98 kind: InlayKind::TypeHint,
71 }, 99 label: ty.display_truncated(sema.db, max_inlay_hint_length).to_string().into(),
72 _ => (), 100 });
73 }
74 };
75 Some(()) 101 Some(())
76} 102}
77 103
@@ -120,43 +146,6 @@ fn should_not_display_type_hint(db: &RootDatabase, bind_pat: &ast::BindPat, pat_
120 false 146 false
121} 147}
122 148
123fn get_param_name_hints(
124 acc: &mut Vec<InlayHint>,
125 sema: &Semantics<RootDatabase>,
126 expr: ast::Expr,
127) -> Option<()> {
128 let args = match &expr {
129 ast::Expr::CallExpr(expr) => expr.arg_list()?.args(),
130 ast::Expr::MethodCallExpr(expr) => expr.arg_list()?.args(),
131 _ => return None,
132 }
133 .into_iter()
134 // we need args len to determine whether to skip or not the &self parameter
135 .collect::<Vec<_>>();
136
137 let fn_signature = get_fn_signature(sema, &expr)?;
138 let n_params_to_skip =
139 if fn_signature.has_self_param && fn_signature.parameter_names.len() > args.len() {
140 1
141 } else {
142 0
143 };
144 let hints = fn_signature
145 .parameter_names
146 .iter()
147 .skip(n_params_to_skip)
148 .zip(args)
149 .filter(|(param, arg)| should_show_param_hint(&fn_signature, param, &arg))
150 .map(|(param_name, arg)| InlayHint {
151 range: arg.syntax().text_range(),
152 kind: InlayKind::ParameterHint,
153 label: param_name.into(),
154 });
155
156 acc.extend(hints);
157 Some(())
158}
159
160fn should_show_param_hint( 149fn should_show_param_hint(
161 fn_signature: &FunctionSignature, 150 fn_signature: &FunctionSignature,
162 param_name: &str, 151 param_name: &str,
diff --git a/crates/ra_ide/src/references/classify.rs b/crates/ra_ide/src/references/classify.rs
index 91b21429a..fdd07d8d1 100644
--- a/crates/ra_ide/src/references/classify.rs
+++ b/crates/ra_ide/src/references/classify.rs
@@ -61,7 +61,7 @@ pub(crate) fn classify_name_ref(
61 PathResolution::Local(local) => NameDefinition::Local(local), 61 PathResolution::Local(local) => NameDefinition::Local(local),
62 PathResolution::TypeParam(par) => NameDefinition::TypeParam(par), 62 PathResolution::TypeParam(par) => NameDefinition::TypeParam(par),
63 PathResolution::Macro(def) => NameDefinition::Macro(def), 63 PathResolution::Macro(def) => NameDefinition::Macro(def),
64 PathResolution::SelfType(impl_block) => NameDefinition::SelfType(impl_block), 64 PathResolution::SelfType(impl_def) => NameDefinition::SelfType(impl_def),
65 }; 65 };
66 Some(res) 66 Some(res)
67} 67}
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index b94b6a022..28117b4d8 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -120,7 +120,6 @@ pub(crate) fn highlight(
120 if let Some(token) = element.as_token().cloned().and_then(ast::RawString::cast) { 120 if let Some(token) = element.as_token().cloned().and_then(ast::RawString::cast) {
121 let expanded = element_to_highlight.as_token().unwrap().clone(); 121 let expanded = element_to_highlight.as_token().unwrap().clone();
122 if highlight_injection(&mut res, &sema, token, expanded).is_some() { 122 if highlight_injection(&mut res, &sema, token, expanded).is_some() {
123 eprintln!("res = {:?}", res);
124 continue; 123 continue;
125 } 124 }
126 } 125 }
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs
index 93f32ba85..ad4638906 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ra_ide_db/src/defs.rs
@@ -6,7 +6,7 @@
6// FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). 6// FIXME: this badly needs rename/rewrite (matklad, 2020-02-06).
7 7
8use hir::{ 8use hir::{
9 Adt, FieldSource, HasSource, ImplBlock, Local, MacroDef, Module, ModuleDef, Semantics, 9 Adt, FieldSource, HasSource, ImplDef, Local, MacroDef, Module, ModuleDef, Semantics,
10 StructField, TypeParam, 10 StructField, TypeParam,
11}; 11};
12use ra_prof::profile; 12use ra_prof::profile;
@@ -22,7 +22,7 @@ pub enum NameDefinition {
22 Macro(MacroDef), 22 Macro(MacroDef),
23 StructField(StructField), 23 StructField(StructField),
24 ModuleDef(ModuleDef), 24 ModuleDef(ModuleDef),
25 SelfType(ImplBlock), 25 SelfType(ImplDef),
26 Local(Local), 26 Local(Local),
27 TypeParam(TypeParam), 27 TypeParam(TypeParam),
28} 28}
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs
index a46e11e1d..58098e810 100644
--- a/crates/ra_parser/src/grammar.rs
+++ b/crates/ra_parser/src/grammar.rs
@@ -152,7 +152,7 @@ pub(crate) fn reparser(
152 EXTERN_ITEM_LIST => items::extern_item_list, 152 EXTERN_ITEM_LIST => items::extern_item_list,
153 TOKEN_TREE if first_child? == T!['{'] => items::token_tree, 153 TOKEN_TREE if first_child? == T!['{'] => items::token_tree,
154 ITEM_LIST => match parent? { 154 ITEM_LIST => match parent? {
155 IMPL_BLOCK => items::impl_item_list, 155 IMPL_DEF => items::impl_item_list,
156 TRAIT_DEF => items::trait_item_list, 156 TRAIT_DEF => items::trait_item_list,
157 MODULE => items::mod_item_list, 157 MODULE => items::mod_item_list,
158 _ => return None, 158 _ => return None,
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index f8b43866c..433ed6812 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -202,8 +202,8 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
202 // test unsafe_default_impl 202 // test unsafe_default_impl
203 // unsafe default impl Foo {} 203 // unsafe default impl Foo {}
204 T![impl] => { 204 T![impl] => {
205 traits::impl_block(p); 205 traits::impl_def(p);
206 m.complete(p, IMPL_BLOCK); 206 m.complete(p, IMPL_DEF);
207 } 207 }
208 208
209 // test existential_type 209 // test existential_type
diff --git a/crates/ra_parser/src/grammar/items/traits.rs b/crates/ra_parser/src/grammar/items/traits.rs
index 03dae3cdb..c819e33be 100644
--- a/crates/ra_parser/src/grammar/items/traits.rs
+++ b/crates/ra_parser/src/grammar/items/traits.rs
@@ -53,9 +53,9 @@ pub(crate) fn trait_item_list(p: &mut Parser) {
53 m.complete(p, ITEM_LIST); 53 m.complete(p, ITEM_LIST);
54} 54}
55 55
56// test impl_block 56// test impl_def
57// impl Foo {} 57// impl Foo {}
58pub(super) fn impl_block(p: &mut Parser) { 58pub(super) fn impl_def(p: &mut Parser) {
59 assert!(p.at(T![impl])); 59 assert!(p.at(T![impl]));
60 p.bump(T![impl]); 60 p.bump(T![impl]);
61 if choose_type_params_over_qpath(p) { 61 if choose_type_params_over_qpath(p) {
@@ -65,7 +65,7 @@ pub(super) fn impl_block(p: &mut Parser) {
65 // FIXME: never type 65 // FIXME: never type
66 // impl ! {} 66 // impl ! {}
67 67
68 // test impl_block_neg 68 // test impl_def_neg
69 // impl !Send for X {} 69 // impl !Send for X {}
70 p.eat(T![!]); 70 p.eat(T![!]);
71 impl_type(p); 71 impl_type(p);
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index 1068da0a0..dfc30d727 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -133,7 +133,7 @@ pub enum SyntaxKind {
133 STATIC_DEF, 133 STATIC_DEF,
134 CONST_DEF, 134 CONST_DEF,
135 TRAIT_DEF, 135 TRAIT_DEF,
136 IMPL_BLOCK, 136 IMPL_DEF,
137 TYPE_ALIAS_DEF, 137 TYPE_ALIAS_DEF,
138 MACRO_CALL, 138 MACRO_CALL,
139 TOKEN_TREE, 139 TOKEN_TREE,
diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs
index db779a2d2..c51957c1f 100644
--- a/crates/ra_project_model/src/sysroot.rs
+++ b/crates/ra_project_model/src/sysroot.rs
@@ -66,7 +66,7 @@ impl Sysroot {
66 } 66 }
67 } 67 }
68 } 68 }
69 if let Some(alloc) = sysroot.by_name("alloc") { 69 if let Some(alloc) = sysroot.alloc() {
70 if let Some(core) = sysroot.core() { 70 if let Some(core) = sysroot.core() {
71 sysroot.crates[alloc].deps.push(core); 71 sysroot.crates[alloc].deps.push(core);
72 } 72 }
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 9cc7930f7..4a70c712f 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -59,7 +59,7 @@ pub trait AstToken {
59} 59}
60 60
61/// An iterator over `SyntaxNode` children of a particular AST type. 61/// An iterator over `SyntaxNode` children of a particular AST type.
62#[derive(Debug)] 62#[derive(Debug, Clone)]
63pub struct AstChildren<N> { 63pub struct AstChildren<N> {
64 inner: SyntaxNodeChildren, 64 inner: SyntaxNodeChildren,
65 ph: PhantomData<N>, 65 ph: PhantomData<N>,
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index 44de4af89..d5986e8b4 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -169,7 +169,7 @@ impl ast::UseTreeList {
169 } 169 }
170} 170}
171 171
172impl ast::ImplBlock { 172impl ast::ImplDef {
173 pub fn target_type(&self) -> Option<ast::TypeRef> { 173 pub fn target_type(&self) -> Option<ast::TypeRef> {
174 match self.target() { 174 match self.target() {
175 (Some(t), None) | (_, Some(t)) => Some(t), 175 (Some(t), None) | (_, Some(t)) => Some(t),
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 8eb240801..150893e39 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -552,13 +552,13 @@ impl TypeAliasDef {
552 } 552 }
553} 553}
554#[derive(Debug, Clone, PartialEq, Eq, Hash)] 554#[derive(Debug, Clone, PartialEq, Eq, Hash)]
555pub struct ImplBlock { 555pub struct ImplDef {
556 pub(crate) syntax: SyntaxNode, 556 pub(crate) syntax: SyntaxNode,
557} 557}
558impl AstNode for ImplBlock { 558impl AstNode for ImplDef {
559 fn can_cast(kind: SyntaxKind) -> bool { 559 fn can_cast(kind: SyntaxKind) -> bool {
560 match kind { 560 match kind {
561 IMPL_BLOCK => true, 561 IMPL_DEF => true,
562 _ => false, 562 _ => false,
563 } 563 }
564 } 564 }
@@ -573,9 +573,9 @@ impl AstNode for ImplBlock {
573 &self.syntax 573 &self.syntax
574 } 574 }
575} 575}
576impl ast::TypeParamsOwner for ImplBlock {} 576impl ast::TypeParamsOwner for ImplDef {}
577impl ast::AttrsOwner for ImplBlock {} 577impl ast::AttrsOwner for ImplDef {}
578impl ImplBlock { 578impl ImplDef {
579 pub fn item_list(&self) -> Option<ItemList> { 579 pub fn item_list(&self) -> Option<ItemList> {
580 AstChildren::new(&self.syntax).next() 580 AstChildren::new(&self.syntax).next()
581 } 581 }
@@ -3524,7 +3524,7 @@ pub enum ModuleItem {
3524 FnDef(FnDef), 3524 FnDef(FnDef),
3525 TraitDef(TraitDef), 3525 TraitDef(TraitDef),
3526 TypeAliasDef(TypeAliasDef), 3526 TypeAliasDef(TypeAliasDef),
3527 ImplBlock(ImplBlock), 3527 ImplDef(ImplDef),
3528 UseItem(UseItem), 3528 UseItem(UseItem),
3529 ExternCrateItem(ExternCrateItem), 3529 ExternCrateItem(ExternCrateItem),
3530 ConstDef(ConstDef), 3530 ConstDef(ConstDef),
@@ -3561,9 +3561,9 @@ impl From<TypeAliasDef> for ModuleItem {
3561 ModuleItem::TypeAliasDef(node) 3561 ModuleItem::TypeAliasDef(node)
3562 } 3562 }
3563} 3563}
3564impl From<ImplBlock> for ModuleItem { 3564impl From<ImplDef> for ModuleItem {
3565 fn from(node: ImplBlock) -> ModuleItem { 3565 fn from(node: ImplDef) -> ModuleItem {
3566 ModuleItem::ImplBlock(node) 3566 ModuleItem::ImplDef(node)
3567 } 3567 }
3568} 3568}
3569impl From<UseItem> for ModuleItem { 3569impl From<UseItem> for ModuleItem {
@@ -3594,8 +3594,8 @@ impl From<Module> for ModuleItem {
3594impl AstNode for ModuleItem { 3594impl AstNode for ModuleItem {
3595 fn can_cast(kind: SyntaxKind) -> bool { 3595 fn can_cast(kind: SyntaxKind) -> bool {
3596 match kind { 3596 match kind {
3597 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF 3597 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
3598 | IMPL_BLOCK | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true, 3598 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
3599 _ => false, 3599 _ => false,
3600 } 3600 }
3601 } 3601 }
@@ -3607,7 +3607,7 @@ impl AstNode for ModuleItem {
3607 FN_DEF => ModuleItem::FnDef(FnDef { syntax }), 3607 FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
3608 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }), 3608 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
3609 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }), 3609 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
3610 IMPL_BLOCK => ModuleItem::ImplBlock(ImplBlock { syntax }), 3610 IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
3611 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }), 3611 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
3612 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }), 3612 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
3613 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }), 3613 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
@@ -3625,7 +3625,7 @@ impl AstNode for ModuleItem {
3625 ModuleItem::FnDef(it) => &it.syntax, 3625 ModuleItem::FnDef(it) => &it.syntax,
3626 ModuleItem::TraitDef(it) => &it.syntax, 3626 ModuleItem::TraitDef(it) => &it.syntax,
3627 ModuleItem::TypeAliasDef(it) => &it.syntax, 3627 ModuleItem::TypeAliasDef(it) => &it.syntax,
3628 ModuleItem::ImplBlock(it) => &it.syntax, 3628 ModuleItem::ImplDef(it) => &it.syntax,
3629 ModuleItem::UseItem(it) => &it.syntax, 3629 ModuleItem::UseItem(it) => &it.syntax,
3630 ModuleItem::ExternCrateItem(it) => &it.syntax, 3630 ModuleItem::ExternCrateItem(it) => &it.syntax,
3631 ModuleItem::ConstDef(it) => &it.syntax, 3631 ModuleItem::ConstDef(it) => &it.syntax,
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs
index 863859dca..7915cf8cb 100644
--- a/crates/ra_syntax/src/validation.rs
+++ b/crates/ra_syntax/src/validation.rs
@@ -203,12 +203,11 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) {
203 _ => return, 203 _ => return,
204 } 204 }
205 205
206 let impl_block = match parent.parent().and_then(|it| it.parent()).and_then(ast::ImplBlock::cast) 206 let impl_def = match parent.parent().and_then(|it| it.parent()).and_then(ast::ImplDef::cast) {
207 {
208 Some(it) => it, 207 Some(it) => it,
209 None => return, 208 None => return,
210 }; 209 };
211 if impl_block.target_trait().is_some() { 210 if impl_def.target_trait().is_some() {
212 errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range())); 211 errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range()));
213 } 212 }
214} 213}
diff --git a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt
index b9e60f6c1..4b13a7236 100644
--- a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt
+++ b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 183) 1SOURCE_FILE@[0; 183)
2 IMPL_BLOCK@[0; 182) 2 IMPL_DEF@[0; 182)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
5 PATH_TYPE@[5; 13) 5 PATH_TYPE@[5; 13)
diff --git a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt
index bb87022b0..9f50c85e5 100644
--- a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt
+++ b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt
@@ -77,7 +77,7 @@ SOURCE_FILE@[0; 112)
77 ERROR@[54; 55) 77 ERROR@[54; 55)
78 COMMA@[54; 55) "," 78 COMMA@[54; 55) ","
79 WHITESPACE@[55; 56) " " 79 WHITESPACE@[55; 56) " "
80 IMPL_BLOCK@[56; 60) 80 IMPL_DEF@[56; 60)
81 IMPL_KW@[56; 60) "impl" 81 IMPL_KW@[56; 60) "impl"
82 EXPR_STMT@[60; 61) 82 EXPR_STMT@[60; 61)
83 ERROR@[60; 61) 83 ERROR@[60; 61)
diff --git a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt b/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt
index 3942e0904..f239b7b1e 100644
--- a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt
+++ b/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 38) 1SOURCE_FILE@[0; 38)
2 IMPL_BLOCK@[0; 14) 2 IMPL_DEF@[0; 14)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 TYPE_PARAM_LIST@[4; 14) 4 TYPE_PARAM_LIST@[4; 14)
5 L_ANGLE@[4; 5) "<" 5 L_ANGLE@[4; 5) "<"
@@ -17,7 +17,7 @@ SOURCE_FILE@[0; 38)
17 IDENT@[8; 13) "Clone" 17 IDENT@[8; 13) "Clone"
18 R_ANGLE@[13; 14) ">" 18 R_ANGLE@[13; 14) ">"
19 WHITESPACE@[14; 15) "\n" 19 WHITESPACE@[14; 15) "\n"
20 IMPL_BLOCK@[15; 37) 20 IMPL_DEF@[15; 37)
21 IMPL_KW@[15; 19) "impl" 21 IMPL_KW@[15; 19) "impl"
22 TYPE_PARAM_LIST@[19; 22) 22 TYPE_PARAM_LIST@[19; 22)
23 L_ANGLE@[19; 20) "<" 23 L_ANGLE@[19; 20) "<"
diff --git a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt
index d0a128a5f..d8622d45f 100644
--- a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt
+++ b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 118) 1SOURCE_FILE@[0; 118)
2 IMPL_BLOCK@[0; 117) 2 IMPL_DEF@[0; 117)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
5 PATH_TYPE@[5; 6) 5 PATH_TYPE@[5; 6)
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt b/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt
index 0187d872d..01a853d63 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt
+++ b/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt
@@ -18,7 +18,7 @@ SOURCE_FILE@[0; 30)
18 LIFETIME@[16; 21) "\'loop" 18 LIFETIME@[16; 21) "\'loop"
19 COLON@[21; 22) ":" 19 COLON@[21; 22) ":"
20 WHITESPACE@[22; 23) " " 20 WHITESPACE@[22; 23) " "
21 IMPL_BLOCK@[23; 27) 21 IMPL_DEF@[23; 27)
22 IMPL_KW@[23; 27) "impl" 22 IMPL_KW@[23; 27) "impl"
23 WHITESPACE@[27; 28) "\n" 23 WHITESPACE@[27; 28) "\n"
24 R_CURLY@[28; 29) "}" 24 R_CURLY@[28; 29) "}"
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt b/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt
index d5aea05c2..124f0a891 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt
+++ b/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 87) 1SOURCE_FILE@[0; 87)
2 IMPL_BLOCK@[0; 12) 2 IMPL_DEF@[0; 12)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
5 PATH_TYPE@[5; 9) 5 PATH_TYPE@[5; 9)
@@ -12,7 +12,7 @@ SOURCE_FILE@[0; 87)
12 L_CURLY@[10; 11) "{" 12 L_CURLY@[10; 11) "{"
13 R_CURLY@[11; 12) "}" 13 R_CURLY@[11; 12) "}"
14 WHITESPACE@[12; 13) "\n" 14 WHITESPACE@[12; 13) "\n"
15 IMPL_BLOCK@[13; 33) 15 IMPL_DEF@[13; 33)
16 IMPL_KW@[13; 17) "impl" 16 IMPL_KW@[13; 17) "impl"
17 WHITESPACE@[17; 18) " " 17 WHITESPACE@[17; 18) " "
18 PATH_TYPE@[18; 24) 18 PATH_TYPE@[18; 24)
@@ -33,10 +33,10 @@ SOURCE_FILE@[0; 87)
33 L_CURLY@[31; 32) "{" 33 L_CURLY@[31; 32) "{"
34 R_CURLY@[32; 33) "}" 34 R_CURLY@[32; 33) "}"
35 WHITESPACE@[33; 34) "\n" 35 WHITESPACE@[33; 34) "\n"
36 IMPL_BLOCK@[34; 38) 36 IMPL_DEF@[34; 38)
37 IMPL_KW@[34; 38) "impl" 37 IMPL_KW@[34; 38) "impl"
38 WHITESPACE@[38; 39) " " 38 WHITESPACE@[38; 39) " "
39 IMPL_BLOCK@[39; 54) 39 IMPL_DEF@[39; 54)
40 IMPL_KW@[39; 43) "impl" 40 IMPL_KW@[39; 43) "impl"
41 WHITESPACE@[43; 44) " " 41 WHITESPACE@[43; 44) " "
42 PATH_TYPE@[44; 51) 42 PATH_TYPE@[44; 51)
@@ -49,7 +49,7 @@ SOURCE_FILE@[0; 87)
49 L_CURLY@[52; 53) "{" 49 L_CURLY@[52; 53) "{"
50 R_CURLY@[53; 54) "}" 50 R_CURLY@[53; 54) "}"
51 WHITESPACE@[54; 55) "\n" 51 WHITESPACE@[54; 55) "\n"
52 IMPL_BLOCK@[55; 70) 52 IMPL_DEF@[55; 70)
53 IMPL_KW@[55; 59) "impl" 53 IMPL_KW@[55; 59) "impl"
54 WHITESPACE@[59; 60) " " 54 WHITESPACE@[59; 60) " "
55 PATH_TYPE@[60; 66) 55 PATH_TYPE@[60; 66)
@@ -60,7 +60,7 @@ SOURCE_FILE@[0; 87)
60 WHITESPACE@[66; 67) " " 60 WHITESPACE@[66; 67) " "
61 FOR_KW@[67; 70) "for" 61 FOR_KW@[67; 70) "for"
62 WHITESPACE@[70; 71) " " 62 WHITESPACE@[70; 71) " "
63 IMPL_BLOCK@[71; 86) 63 IMPL_DEF@[71; 86)
64 IMPL_KW@[71; 75) "impl" 64 IMPL_KW@[71; 75) "impl"
65 WHITESPACE@[75; 76) " " 65 WHITESPACE@[75; 76) " "
66 PATH_TYPE@[76; 83) 66 PATH_TYPE@[76; 83)
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt
index d4e710dd4..ad9f0965e 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 83) 1SOURCE_FILE@[0; 83)
2 IMPL_BLOCK@[0; 82) 2 IMPL_DEF@[0; 82)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
5 PATH_TYPE@[5; 6) 5 PATH_TYPE@[5; 6)
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt b/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt
index 0ccd12b0a..757ac092a 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 128) 1SOURCE_FILE@[0; 128)
2 IMPL_BLOCK@[0; 127) 2 IMPL_DEF@[0; 127)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
5 PATH_TYPE@[5; 6) 5 PATH_TYPE@[5; 6)
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt b/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt
index d0beeb81e..89caee543 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 69) 1SOURCE_FILE@[0; 69)
2 IMPL_BLOCK@[0; 68) 2 IMPL_DEF@[0; 68)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
5 PATH_TYPE@[5; 6) 5 PATH_TYPE@[5; 6)
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt
index 0768f0518..b1af67976 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 89) 1SOURCE_FILE@[0; 89)
2 IMPL_BLOCK@[0; 88) 2 IMPL_DEF@[0; 88)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
5 PATH_TYPE@[5; 6) 5 PATH_TYPE@[5; 6)
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt
index 8f3dcaf88..0a768a8e3 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 27) 1SOURCE_FILE@[0; 27)
2 IMPL_BLOCK@[0; 26) 2 IMPL_DEF@[0; 26)
3 UNSAFE_KW@[0; 6) "unsafe" 3 UNSAFE_KW@[0; 6) "unsafe"
4 WHITESPACE@[6; 7) " " 4 WHITESPACE@[6; 7) " "
5 DEFAULT_KW@[7; 14) "default" 5 DEFAULT_KW@[7; 14) "default"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.rs b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rs
index b7527c870..b7527c870 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.rs
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rs
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.txt
index dfff947fe..0cc3ac085 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_block_neg.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 20) 1SOURCE_FILE@[0; 20)
2 IMPL_BLOCK@[0; 19) 2 IMPL_DEF@[0; 19)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
5 EXCL@[5; 6) "!" 5 EXCL@[5; 6) "!"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.rs b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rs
index d6337f6b3..d6337f6b3 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.rs
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rs
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.txt
index bda3435e8..4c2863ba7 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_block.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 12) 1SOURCE_FILE@[0; 12)
2 IMPL_BLOCK@[0; 11) 2 IMPL_DEF@[0; 11)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
5 PATH_TYPE@[5; 8) 5 PATH_TYPE@[5; 8)
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt
index 590e2a88f..e614acc6f 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 19) 1SOURCE_FILE@[0; 19)
2 IMPL_BLOCK@[0; 18) 2 IMPL_DEF@[0; 18)
3 UNSAFE_KW@[0; 6) "unsafe" 3 UNSAFE_KW@[0; 6) "unsafe"
4 WHITESPACE@[6; 7) " " 4 WHITESPACE@[6; 7) " "
5 IMPL_KW@[7; 11) "impl" 5 IMPL_KW@[7; 11) "impl"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt
index ada94a824..af9077270 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 20) 1SOURCE_FILE@[0; 20)
2 IMPL_BLOCK@[0; 19) 2 IMPL_DEF@[0; 19)
3 DEFAULT_KW@[0; 7) "default" 3 DEFAULT_KW@[0; 7) "default"
4 WHITESPACE@[7; 8) " " 4 WHITESPACE@[7; 8) " "
5 IMPL_KW@[8; 12) "impl" 5 IMPL_KW@[8; 12) "impl"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt
index 0e9e9b95b..5053ebde7 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt
@@ -8,7 +8,7 @@ SOURCE_FILE@[0; 94)
8 L_CURLY@[6; 7) "{" 8 L_CURLY@[6; 7) "{"
9 R_CURLY@[7; 8) "}" 9 R_CURLY@[7; 8) "}"
10 WHITESPACE@[8; 9) "\n" 10 WHITESPACE@[8; 9) "\n"
11 IMPL_BLOCK@[9; 93) 11 IMPL_DEF@[9; 93)
12 IMPL_KW@[9; 13) "impl" 12 IMPL_KW@[9; 13) "impl"
13 WHITESPACE@[13; 14) " " 13 WHITESPACE@[13; 14) " "
14 PATH_TYPE@[14; 15) 14 PATH_TYPE@[14; 15)
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt
index 022070b0c..e1734224b 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 69) 1SOURCE_FILE@[0; 69)
2 IMPL_BLOCK@[0; 68) 2 IMPL_DEF@[0; 68)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
5 PATH_TYPE@[5; 6) 5 PATH_TYPE@[5; 6)
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt b/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt
index 47fadef85..2d46eebb3 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 29) 1SOURCE_FILE@[0; 29)
2 IMPL_BLOCK@[0; 28) 2 IMPL_DEF@[0; 28)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 TYPE_PARAM_LIST@[4; 18) 4 TYPE_PARAM_LIST@[4; 18)
5 L_ANGLE@[4; 5) "<" 5 L_ANGLE@[4; 5) "<"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.txt b/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.txt
index 933f5b7bd..b30030de3 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 137) 1SOURCE_FILE@[0; 137)
2 IMPL_BLOCK@[0; 136) 2 IMPL_DEF@[0; 136)
3 IMPL_KW@[0; 4) "impl" 3 IMPL_KW@[0; 4) "impl"
4 WHITESPACE@[4; 5) " " 4 WHITESPACE@[4; 5) " "
5 PATH_TYPE@[5; 6) 5 PATH_TYPE@[5; 6)
diff --git a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt b/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt
index 72f053dfc..341e02704 100644
--- a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt
+++ b/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt
@@ -8,7 +8,7 @@ SOURCE_FILE@[0; 199)
8 IDENT@[69; 72) "Foo" 8 IDENT@[69; 72) "Foo"
9 SEMI@[72; 73) ";" 9 SEMI@[72; 73) ";"
10 WHITESPACE@[73; 75) "\n\n" 10 WHITESPACE@[73; 75) "\n\n"
11 IMPL_BLOCK@[75; 141) 11 IMPL_DEF@[75; 141)
12 IMPL_KW@[75; 79) "impl" 12 IMPL_KW@[75; 79) "impl"
13 WHITESPACE@[79; 80) " " 13 WHITESPACE@[79; 80) " "
14 PATH_TYPE@[80; 83) 14 PATH_TYPE@[80; 83)
diff --git a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt b/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt
index 3d9aab500..e15447ca7 100644
--- a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt
+++ b/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt
@@ -92,7 +92,7 @@ SOURCE_FILE@[0; 686)
92 WHITESPACE@[461; 463) "\n\n" 92 WHITESPACE@[461; 463) "\n\n"
93 COMMENT@[463; 523) "// https://github.com ..." 93 COMMENT@[463; 523) "// https://github.com ..."
94 WHITESPACE@[523; 524) "\n" 94 WHITESPACE@[523; 524) "\n"
95 IMPL_BLOCK@[524; 685) 95 IMPL_DEF@[524; 685)
96 IMPL_KW@[524; 528) "impl" 96 IMPL_KW@[524; 528) "impl"
97 WHITESPACE@[528; 529) " " 97 WHITESPACE@[528; 529) " "
98 PATH_TYPE@[529; 537) 98 PATH_TYPE@[529; 537)
diff --git a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt
index bfd47d2e1..719c99c17 100644
--- a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt
+++ b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt
@@ -253,7 +253,7 @@ SOURCE_FILE@[0; 519)
253 WHITESPACE@[234; 235) "\n" 253 WHITESPACE@[234; 235) "\n"
254 R_CURLY@[235; 236) "}" 254 R_CURLY@[235; 236) "}"
255 WHITESPACE@[236; 238) "\n\n" 255 WHITESPACE@[236; 238) "\n\n"
256 IMPL_BLOCK@[238; 519) 256 IMPL_DEF@[238; 519)
257 IMPL_KW@[238; 242) "impl" 257 IMPL_KW@[238; 242) "impl"
258 WHITESPACE@[242; 243) " " 258 WHITESPACE@[242; 243) " "
259 PATH_TYPE@[243; 244) 259 PATH_TYPE@[243; 244)
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index d70d34bdc..6bf0be565 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -76,8 +76,8 @@ pub fn analysis_stats(
76 } 76 }
77 } 77 }
78 78
79 for impl_block in module.impl_blocks(db) { 79 for impl_def in module.impl_defs(db) {
80 for item in impl_block.items(db) { 80 for item in impl_def.items(db) {
81 num_decls += 1; 81 num_decls += 1;
82 if let AssocItem::Function(f) = item { 82 if let AssocItem::Function(f) = item {
83 funcs.push(f); 83 funcs.push(f);
diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs
index ff156307a..eeeb33e8f 100644
--- a/crates/rust-analyzer/src/conv.rs
+++ b/crates/rust-analyzer/src/conv.rs
@@ -57,7 +57,7 @@ impl Conv for SyntaxKind {
57 SyntaxKind::RECORD_FIELD_DEF => SymbolKind::Field, 57 SyntaxKind::RECORD_FIELD_DEF => SymbolKind::Field,
58 SyntaxKind::STATIC_DEF => SymbolKind::Constant, 58 SyntaxKind::STATIC_DEF => SymbolKind::Constant,
59 SyntaxKind::CONST_DEF => SymbolKind::Constant, 59 SyntaxKind::CONST_DEF => SymbolKind::Constant,
60 SyntaxKind::IMPL_BLOCK => SymbolKind::Object, 60 SyntaxKind::IMPL_DEF => SymbolKind::Object,
61 _ => SymbolKind::Variable, 61 _ => SymbolKind::Variable,
62 } 62 }
63 } 63 }