aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/call_hierarchy.rs54
-rw-r--r--crates/ra_ide/src/completion/complete_attribute.rs10
-rw-r--r--crates/ra_ide/src/completion/complete_fn_param.rs10
-rw-r--r--crates/ra_ide/src/completion/complete_keyword.rs2
-rw-r--r--crates/ra_ide/src/completion/complete_trait_impl.rs25
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs16
-rw-r--r--crates/ra_ide/src/completion/patterns.rs10
-rw-r--r--crates/ra_ide/src/diagnostics.rs22
-rw-r--r--crates/ra_ide/src/display.rs12
-rw-r--r--crates/ra_ide/src/display/navigation_target.rs40
-rw-r--r--crates/ra_ide/src/display/short_label.rs34
-rw-r--r--crates/ra_ide/src/extend_selection.rs8
-rw-r--r--crates/ra_ide/src/file_structure.rs74
-rw-r--r--crates/ra_ide/src/folding_ranges.rs6
-rw-r--r--crates/ra_ide/src/goto_implementation.rs10
-rw-r--r--crates/ra_ide/src/hover.rs68
-rw-r--r--crates/ra_ide/src/inlay_hints.rs8
-rw-r--r--crates/ra_ide/src/references.rs34
-rw-r--r--crates/ra_ide/src/references/rename.rs14
-rw-r--r--crates/ra_ide/src/runnables.rs40
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs24
-rw-r--r--crates/ra_ide/src/syntax_tree.rs14
22 files changed, 261 insertions, 274 deletions
diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs
index c28af8ab3..1fcaf4a32 100644
--- a/crates/ra_ide/src/call_hierarchy.rs
+++ b/crates/ra_ide/src/call_hierarchy.rs
@@ -59,7 +59,7 @@ pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Optio
59 if let Some(nav) = syntax.ancestors().find_map(|node| { 59 if let Some(nav) = syntax.ancestors().find_map(|node| {
60 match_ast! { 60 match_ast! {
61 match node { 61 match node {
62 ast::FnDef(it) => { 62 ast::Fn(it) => {
63 let def = sema.to_def(&it)?; 63 let def = sema.to_def(&it)?;
64 Some(def.to_nav(sema.db)) 64 Some(def.to_nav(sema.db))
65 }, 65 },
@@ -181,8 +181,8 @@ fn caller() {
181 call<|>ee(); 181 call<|>ee();
182} 182}
183"#, 183"#,
184 "callee FN_DEF FileId(1) 0..14 3..9", 184 "callee FN FileId(1) 0..14 3..9",
185 &["caller FN_DEF FileId(1) 15..44 18..24 : [33..39]"], 185 &["caller FN FileId(1) 15..44 18..24 : [33..39]"],
186 &[], 186 &[],
187 ); 187 );
188 } 188 }
@@ -197,8 +197,8 @@ fn caller() {
197 callee(); 197 callee();
198} 198}
199"#, 199"#,
200 "callee FN_DEF FileId(1) 0..14 3..9", 200 "callee FN FileId(1) 0..14 3..9",
201 &["caller FN_DEF FileId(1) 15..44 18..24 : [33..39]"], 201 &["caller FN FileId(1) 15..44 18..24 : [33..39]"],
202 &[], 202 &[],
203 ); 203 );
204 } 204 }
@@ -214,8 +214,8 @@ fn caller() {
214 callee(); 214 callee();
215} 215}
216"#, 216"#,
217 "callee FN_DEF FileId(1) 0..14 3..9", 217 "callee FN FileId(1) 0..14 3..9",
218 &["caller FN_DEF FileId(1) 15..58 18..24 : [33..39, 47..53]"], 218 &["caller FN FileId(1) 15..58 18..24 : [33..39, 47..53]"],
219 &[], 219 &[],
220 ); 220 );
221 } 221 }
@@ -234,10 +234,10 @@ fn caller2() {
234 callee(); 234 callee();
235} 235}
236"#, 236"#,
237 "callee FN_DEF FileId(1) 0..14 3..9", 237 "callee FN FileId(1) 0..14 3..9",
238 &[ 238 &[
239 "caller1 FN_DEF FileId(1) 15..45 18..25 : [34..40]", 239 "caller1 FN FileId(1) 15..45 18..25 : [34..40]",
240 "caller2 FN_DEF FileId(1) 47..77 50..57 : [66..72]", 240 "caller2 FN FileId(1) 47..77 50..57 : [66..72]",
241 ], 241 ],
242 &[], 242 &[],
243 ); 243 );
@@ -263,10 +263,10 @@ mod tests {
263 } 263 }
264} 264}
265"#, 265"#,
266 "callee FN_DEF FileId(1) 0..14 3..9", 266 "callee FN FileId(1) 0..14 3..9",
267 &[ 267 &[
268 "caller1 FN_DEF FileId(1) 15..45 18..25 : [34..40]", 268 "caller1 FN FileId(1) 15..45 18..25 : [34..40]",
269 "test_caller FN_DEF FileId(1) 95..149 110..121 : [134..140]", 269 "test_caller FN FileId(1) 95..149 110..121 : [134..140]",
270 ], 270 ],
271 &[], 271 &[],
272 ); 272 );
@@ -287,8 +287,8 @@ fn caller() {
287//- /foo/mod.rs 287//- /foo/mod.rs
288pub fn callee() {} 288pub fn callee() {}
289"#, 289"#,
290 "callee FN_DEF FileId(2) 0..18 7..13", 290 "callee FN FileId(2) 0..18 7..13",
291 &["caller FN_DEF FileId(1) 27..56 30..36 : [45..51]"], 291 &["caller FN FileId(1) 27..56 30..36 : [45..51]"],
292 &[], 292 &[],
293 ); 293 );
294 } 294 }
@@ -304,9 +304,9 @@ fn call<|>er() {
304 callee(); 304 callee();
305} 305}
306"#, 306"#,
307 "caller FN_DEF FileId(1) 15..58 18..24", 307 "caller FN FileId(1) 15..58 18..24",
308 &[], 308 &[],
309 &["callee FN_DEF FileId(1) 0..14 3..9 : [33..39, 47..53]"], 309 &["callee FN FileId(1) 0..14 3..9 : [33..39, 47..53]"],
310 ); 310 );
311 } 311 }
312 312
@@ -325,9 +325,9 @@ fn call<|>er() {
325//- /foo/mod.rs 325//- /foo/mod.rs
326pub fn callee() {} 326pub fn callee() {}
327"#, 327"#,
328 "caller FN_DEF FileId(1) 27..56 30..36", 328 "caller FN FileId(1) 27..56 30..36",
329 &[], 329 &[],
330 &["callee FN_DEF FileId(2) 0..18 7..13 : [45..51]"], 330 &["callee FN FileId(2) 0..18 7..13 : [45..51]"],
331 ); 331 );
332 } 332 }
333 333
@@ -348,9 +348,9 @@ fn caller3() {
348 348
349} 349}
350"#, 350"#,
351 "caller2 FN_DEF FileId(1) 33..64 36..43", 351 "caller2 FN FileId(1) 33..64 36..43",
352 &["caller1 FN_DEF FileId(1) 0..31 3..10 : [19..26]"], 352 &["caller1 FN FileId(1) 0..31 3..10 : [19..26]"],
353 &["caller3 FN_DEF FileId(1) 66..83 69..76 : [52..59]"], 353 &["caller3 FN FileId(1) 66..83 69..76 : [52..59]"],
354 ); 354 );
355 } 355 }
356 356
@@ -368,9 +368,9 @@ fn main() {
368 a<|>() 368 a<|>()
369} 369}
370"#, 370"#,
371 "a FN_DEF FileId(1) 0..18 3..4", 371 "a FN FileId(1) 0..18 3..4",
372 &["main FN_DEF FileId(1) 31..52 34..38 : [47..48]"], 372 &["main FN FileId(1) 31..52 34..38 : [47..48]"],
373 &["b FN_DEF FileId(1) 20..29 23..24 : [13..14]"], 373 &["b FN FileId(1) 20..29 23..24 : [13..14]"],
374 ); 374 );
375 375
376 check_hierarchy( 376 check_hierarchy(
@@ -385,8 +385,8 @@ fn main() {
385 a() 385 a()
386} 386}
387"#, 387"#,
388 "b FN_DEF FileId(1) 20..29 23..24", 388 "b FN FileId(1) 20..29 23..24",
389 &["a FN_DEF FileId(1) 0..18 3..4 : [13..14]"], 389 &["a FN FileId(1) 0..18 3..4 : [13..14]"],
390 &[], 390 &[],
391 ); 391 );
392 } 392 }
diff --git a/crates/ra_ide/src/completion/complete_attribute.rs b/crates/ra_ide/src/completion/complete_attribute.rs
index 109c5e9a8..2faaae974 100644
--- a/crates/ra_ide/src/completion/complete_attribute.rs
+++ b/crates/ra_ide/src/completion/complete_attribute.rs
@@ -13,20 +13,18 @@ use crate::completion::{
13 13
14pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { 14pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
15 let attribute = ctx.attribute_under_caret.as_ref()?; 15 let attribute = ctx.attribute_under_caret.as_ref()?;
16 match (attribute.path(), attribute.input()) { 16 match (attribute.path(), attribute.token_tree()) {
17 (Some(path), Some(ast::AttrInput::TokenTree(token_tree))) 17 (Some(path), Some(token_tree)) if path.to_string() == "derive" => {
18 if path.to_string() == "derive" =>
19 {
20 complete_derive(acc, ctx, token_tree) 18 complete_derive(acc, ctx, token_tree)
21 } 19 }
22 (Some(path), Some(ast::AttrInput::TokenTree(token_tree))) 20 (Some(path), Some(token_tree))
23 if ["allow", "warn", "deny", "forbid"] 21 if ["allow", "warn", "deny", "forbid"]
24 .iter() 22 .iter()
25 .any(|lint_level| lint_level == &path.to_string()) => 23 .any(|lint_level| lint_level == &path.to_string()) =>
26 { 24 {
27 complete_lint(acc, ctx, token_tree) 25 complete_lint(acc, ctx, token_tree)
28 } 26 }
29 (_, Some(ast::AttrInput::TokenTree(_token_tree))) => {} 27 (_, Some(_token_tree)) => {}
30 _ => complete_attribute_start(acc, ctx, attribute), 28 _ => complete_attribute_start(acc, ctx, attribute),
31 } 29 }
32 Some(()) 30 Some(())
diff --git a/crates/ra_ide/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs
index d4b6112a5..406334257 100644
--- a/crates/ra_ide/src/completion/complete_fn_param.rs
+++ b/crates/ra_ide/src/completion/complete_fn_param.rs
@@ -19,8 +19,8 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
19 19
20 let mut params = FxHashMap::default(); 20 let mut params = FxHashMap::default();
21 21
22 let me = ctx.token.ancestors().find_map(ast::FnDef::cast); 22 let me = ctx.token.ancestors().find_map(ast::Fn::cast);
23 let mut process_fn = |func: ast::FnDef| { 23 let mut process_fn = |func: ast::Fn| {
24 if Some(&func) == me.as_ref() { 24 if Some(&func) == me.as_ref() {
25 return; 25 return;
26 } 26 }
@@ -34,15 +34,15 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
34 match_ast! { 34 match_ast! {
35 match node { 35 match node {
36 ast::SourceFile(it) => it.items().filter_map(|item| match item { 36 ast::SourceFile(it) => it.items().filter_map(|item| match item {
37 ast::Item::FnDef(it) => Some(it), 37 ast::Item::Fn(it) => Some(it),
38 _ => None, 38 _ => None,
39 }).for_each(&mut process_fn), 39 }).for_each(&mut process_fn),
40 ast::ItemList(it) => it.items().filter_map(|item| match item { 40 ast::ItemList(it) => it.items().filter_map(|item| match item {
41 ast::Item::FnDef(it) => Some(it), 41 ast::Item::Fn(it) => Some(it),
42 _ => None, 42 _ => None,
43 }).for_each(&mut process_fn), 43 }).for_each(&mut process_fn),
44 ast::AssocItemList(it) => it.assoc_items().filter_map(|item| match item { 44 ast::AssocItemList(it) => it.assoc_items().filter_map(|item| match item {
45 ast::AssocItem::FnDef(it) => Some(it), 45 ast::AssocItem::Fn(it) => Some(it),
46 _ => None, 46 _ => None,
47 }).for_each(&mut process_fn), 47 }).for_each(&mut process_fn),
48 _ => continue, 48 _ => continue,
diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs
index 1581b2d5d..b62064797 100644
--- a/crates/ra_ide/src/completion/complete_keyword.rs
+++ b/crates/ra_ide/src/completion/complete_keyword.rs
@@ -169,7 +169,7 @@ fn add_keyword(ctx: &CompletionContext, acc: &mut Completions, kw: &str, snippet
169 169
170fn complete_return( 170fn complete_return(
171 ctx: &CompletionContext, 171 ctx: &CompletionContext,
172 fn_def: &ast::FnDef, 172 fn_def: &ast::Fn,
173 can_be_stmt: bool, 173 can_be_stmt: bool,
174) -> Option<CompletionItem> { 174) -> Option<CompletionItem> {
175 let snip = match (can_be_stmt, fn_def.ret_type().is_some()) { 175 let snip = match (can_be_stmt, fn_def.ret_type().is_some()) {
diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs
index cf716540f..d9a0ef167 100644
--- a/crates/ra_ide/src/completion/complete_trait_impl.rs
+++ b/crates/ra_ide/src/completion/complete_trait_impl.rs
@@ -2,8 +2,8 @@
2//! 2//!
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`, `TYPE_ALIAS`, or `CONST` node
6//! and an direct child of an `IMPL_DEF`. 6//! and an direct child of an `IMPL`.
7//! 7//!
8//! # Examples 8//! # Examples
9//! 9//!
@@ -34,7 +34,7 @@
34use hir::{self, Docs, HasSource}; 34use hir::{self, Docs, HasSource};
35use ra_assists::utils::get_missing_assoc_items; 35use ra_assists::utils::get_missing_assoc_items;
36use ra_syntax::{ 36use ra_syntax::{
37 ast::{self, edit, ImplDef}, 37 ast::{self, edit, Impl},
38 AstNode, SyntaxKind, SyntaxNode, TextRange, T, 38 AstNode, SyntaxKind, SyntaxNode, TextRange, T,
39}; 39};
40use ra_text_edit::TextEdit; 40use ra_text_edit::TextEdit;
@@ -63,7 +63,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
63 } 63 }
64 }), 64 }),
65 65
66 SyntaxKind::FN_DEF => { 66 SyntaxKind::FN => {
67 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) 67 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def)
68 .into_iter() 68 .into_iter()
69 .filter_map(|item| match item { 69 .filter_map(|item| match item {
@@ -75,7 +75,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
75 } 75 }
76 } 76 }
77 77
78 SyntaxKind::TYPE_ALIAS_DEF => { 78 SyntaxKind::TYPE_ALIAS => {
79 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) 79 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def)
80 .into_iter() 80 .into_iter()
81 .filter_map(|item| match item { 81 .filter_map(|item| match item {
@@ -87,7 +87,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
87 } 87 }
88 } 88 }
89 89
90 SyntaxKind::CONST_DEF => { 90 SyntaxKind::CONST => {
91 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) 91 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def)
92 .into_iter() 92 .into_iter()
93 .filter_map(|item| match item { 93 .filter_map(|item| match item {
@@ -104,18 +104,17 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
104 } 104 }
105} 105}
106 106
107fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, ImplDef)> { 107fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, Impl)> {
108 let (trigger, impl_def_offset) = ctx.token.ancestors().find_map(|p| match p.kind() { 108 let (trigger, impl_def_offset) = ctx.token.ancestors().find_map(|p| match p.kind() {
109 SyntaxKind::FN_DEF 109 SyntaxKind::FN | SyntaxKind::TYPE_ALIAS | SyntaxKind::CONST | SyntaxKind::BLOCK_EXPR => {
110 | SyntaxKind::TYPE_ALIAS_DEF 110 Some((p, 2))
111 | SyntaxKind::CONST_DEF 111 }
112 | SyntaxKind::BLOCK_EXPR => Some((p, 2)),
113 SyntaxKind::NAME_REF => Some((p, 5)), 112 SyntaxKind::NAME_REF => Some((p, 5)),
114 _ => None, 113 _ => None,
115 })?; 114 })?;
116 let impl_def = (0..impl_def_offset - 1) 115 let impl_def = (0..impl_def_offset - 1)
117 .try_fold(trigger.parent()?, |t, _| t.parent()) 116 .try_fold(trigger.parent()?, |t, _| t.parent())
118 .and_then(ast::ImplDef::cast)?; 117 .and_then(ast::Impl::cast)?;
119 Some((trigger, impl_def)) 118 Some((trigger, impl_def))
120} 119}
121 120
@@ -201,7 +200,7 @@ fn add_const_impl(
201 } 200 }
202} 201}
203 202
204fn make_const_compl_syntax(const_: &ast::ConstDef) -> String { 203fn make_const_compl_syntax(const_: &ast::Const) -> String {
205 let const_ = edit::remove_attrs_and_docs(const_); 204 let const_ = edit::remove_attrs_and_docs(const_);
206 205
207 let const_start = const_.syntax().text_range().start(); 206 let const_start = const_.syntax().text_range().start();
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index cc55f6dd6..2113abbb2 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -35,12 +35,12 @@ pub(crate) struct CompletionContext<'a> {
35 pub(super) krate: Option<hir::Crate>, 35 pub(super) krate: Option<hir::Crate>,
36 pub(super) expected_type: Option<Type>, 36 pub(super) expected_type: Option<Type>,
37 pub(super) name_ref_syntax: Option<ast::NameRef>, 37 pub(super) name_ref_syntax: Option<ast::NameRef>,
38 pub(super) function_syntax: Option<ast::FnDef>, 38 pub(super) function_syntax: Option<ast::Fn>,
39 pub(super) use_item_syntax: Option<ast::Use>, 39 pub(super) use_item_syntax: Option<ast::Use>,
40 pub(super) record_lit_syntax: Option<ast::RecordLit>, 40 pub(super) record_lit_syntax: Option<ast::RecordExpr>,
41 pub(super) record_pat_syntax: Option<ast::RecordPat>, 41 pub(super) record_pat_syntax: Option<ast::RecordPat>,
42 pub(super) record_field_syntax: Option<ast::RecordField>, 42 pub(super) record_field_syntax: Option<ast::RecordExprField>,
43 pub(super) impl_def: Option<ast::ImplDef>, 43 pub(super) impl_def: Option<ast::Impl>,
44 /// FIXME: `ActiveParameter` is string-based, which is very very wrong 44 /// FIXME: `ActiveParameter` is string-based, which is very very wrong
45 pub(super) active_parameter: Option<ActiveParameter>, 45 pub(super) active_parameter: Option<ActiveParameter>,
46 pub(super) is_param: bool, 46 pub(super) is_param: bool,
@@ -316,7 +316,7 @@ impl<'a> CompletionContext<'a> {
316 self.name_ref_syntax = 316 self.name_ref_syntax =
317 find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); 317 find_node_at_offset(&original_file, name_ref.syntax().text_range().start());
318 let name_range = name_ref.syntax().text_range(); 318 let name_range = name_ref.syntax().text_range();
319 if ast::RecordField::for_field_name(&name_ref).is_some() { 319 if ast::RecordExprField::for_field_name(&name_ref).is_some() {
320 self.record_lit_syntax = 320 self.record_lit_syntax =
321 self.sema.find_node_at_offset_with_macros(&original_file, offset); 321 self.sema.find_node_at_offset_with_macros(&original_file, offset);
322 } 322 }
@@ -325,7 +325,7 @@ impl<'a> CompletionContext<'a> {
325 .sema 325 .sema
326 .ancestors_with_macros(self.token.parent()) 326 .ancestors_with_macros(self.token.parent())
327 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) 327 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE)
328 .find_map(ast::ImplDef::cast); 328 .find_map(ast::Impl::cast);
329 329
330 let top_node = name_ref 330 let top_node = name_ref
331 .syntax() 331 .syntax()
@@ -349,7 +349,7 @@ impl<'a> CompletionContext<'a> {
349 .sema 349 .sema
350 .ancestors_with_macros(self.token.parent()) 350 .ancestors_with_macros(self.token.parent())
351 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) 351 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE)
352 .find_map(ast::FnDef::cast); 352 .find_map(ast::Fn::cast);
353 353
354 self.record_field_syntax = self 354 self.record_field_syntax = self
355 .sema 355 .sema
@@ -357,7 +357,7 @@ impl<'a> CompletionContext<'a> {
357 .take_while(|it| { 357 .take_while(|it| {
358 it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR 358 it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR
359 }) 359 })
360 .find_map(ast::RecordField::cast); 360 .find_map(ast::RecordExprField::cast);
361 361
362 let parent = match name_ref.syntax().parent() { 362 let parent = match name_ref.syntax().parent() {
363 Some(it) => it, 363 Some(it) => it,
diff --git a/crates/ra_ide/src/completion/patterns.rs b/crates/ra_ide/src/completion/patterns.rs
index 175209d8a..a68861e1c 100644
--- a/crates/ra_ide/src/completion/patterns.rs
+++ b/crates/ra_ide/src/completion/patterns.rs
@@ -15,7 +15,7 @@ pub(crate) fn has_trait_parent(element: SyntaxElement) -> bool {
15 not_same_range_ancestor(element) 15 not_same_range_ancestor(element)
16 .filter(|it| it.kind() == ASSOC_ITEM_LIST) 16 .filter(|it| it.kind() == ASSOC_ITEM_LIST)
17 .and_then(|it| it.parent()) 17 .and_then(|it| it.parent())
18 .filter(|it| it.kind() == TRAIT_DEF) 18 .filter(|it| it.kind() == TRAIT)
19 .is_some() 19 .is_some()
20} 20}
21#[test] 21#[test]
@@ -27,7 +27,7 @@ pub(crate) fn has_impl_parent(element: SyntaxElement) -> bool {
27 not_same_range_ancestor(element) 27 not_same_range_ancestor(element)
28 .filter(|it| it.kind() == ASSOC_ITEM_LIST) 28 .filter(|it| it.kind() == ASSOC_ITEM_LIST)
29 .and_then(|it| it.parent()) 29 .and_then(|it| it.parent())
30 .filter(|it| it.kind() == IMPL_DEF) 30 .filter(|it| it.kind() == IMPL)
31 .is_some() 31 .is_some()
32} 32}
33#[test] 33#[test]
@@ -113,7 +113,7 @@ fn test_if_is_prev() {
113} 113}
114 114
115pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool { 115pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool {
116 previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == TRAIT_DEF).is_some() 116 previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == TRAIT).is_some()
117} 117}
118#[test] 118#[test]
119fn test_has_trait_as_prev_sibling() { 119fn test_has_trait_as_prev_sibling() {
@@ -121,7 +121,7 @@ fn test_has_trait_as_prev_sibling() {
121} 121}
122 122
123pub(crate) fn has_impl_as_prev_sibling(element: SyntaxElement) -> bool { 123pub(crate) fn has_impl_as_prev_sibling(element: SyntaxElement) -> bool {
124 previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == IMPL_DEF).is_some() 124 previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == IMPL).is_some()
125} 125}
126#[test] 126#[test]
127fn test_has_impl_as_prev_sibling() { 127fn test_has_impl_as_prev_sibling() {
@@ -134,7 +134,7 @@ pub(crate) fn is_in_loop_body(element: SyntaxElement) -> bool {
134 NodeOrToken::Token(token) => token.parent(), 134 NodeOrToken::Token(token) => token.parent(),
135 }; 135 };
136 for node in leaf.ancestors() { 136 for node in leaf.ancestors() {
137 if node.kind() == FN_DEF || node.kind() == LAMBDA_EXPR { 137 if node.kind() == FN || node.kind() == LAMBDA_EXPR {
138 break; 138 break;
139 } 139 }
140 let loop_body = match_ast! { 140 let loop_body = match_ast! {
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index 897177d05..dd8a7ffd9 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -146,7 +146,7 @@ fn missing_struct_field_fix(
146) -> Option<Fix> { 146) -> Option<Fix> {
147 let record_expr = sema.ast(d); 147 let record_expr = sema.ast(d);
148 148
149 let record_lit = ast::RecordLit::cast(record_expr.syntax().parent()?.parent()?)?; 149 let record_lit = ast::RecordExpr::cast(record_expr.syntax().parent()?.parent()?)?;
150 let def_id = sema.resolve_variant(record_lit)?; 150 let def_id = sema.resolve_variant(record_lit)?;
151 let module; 151 let module;
152 let def_file_id; 152 let def_file_id;
@@ -155,21 +155,21 @@ fn missing_struct_field_fix(
155 module = s.module(sema.db); 155 module = s.module(sema.db);
156 let source = s.source(sema.db); 156 let source = s.source(sema.db);
157 def_file_id = source.file_id; 157 def_file_id = source.file_id;
158 let fields = source.value.field_def_list()?; 158 let fields = source.value.field_list()?;
159 record_field_def_list(fields)? 159 record_field_list(fields)?
160 } 160 }
161 VariantDef::Union(u) => { 161 VariantDef::Union(u) => {
162 module = u.module(sema.db); 162 module = u.module(sema.db);
163 let source = u.source(sema.db); 163 let source = u.source(sema.db);
164 def_file_id = source.file_id; 164 def_file_id = source.file_id;
165 source.value.record_field_def_list()? 165 source.value.record_field_list()?
166 } 166 }
167 VariantDef::EnumVariant(e) => { 167 VariantDef::EnumVariant(e) => {
168 module = e.module(sema.db); 168 module = e.module(sema.db);
169 let source = e.source(sema.db); 169 let source = e.source(sema.db);
170 def_file_id = source.file_id; 170 def_file_id = source.file_id;
171 let fields = source.value.field_def_list()?; 171 let fields = source.value.field_list()?;
172 record_field_def_list(fields)? 172 record_field_list(fields)?
173 } 173 }
174 }; 174 };
175 let def_file_id = def_file_id.original_file(sema.db); 175 let def_file_id = def_file_id.original_file(sema.db);
@@ -205,10 +205,10 @@ fn missing_struct_field_fix(
205 let fix = Fix::new("Create field", source_change.into()); 205 let fix = Fix::new("Create field", source_change.into());
206 return Some(fix); 206 return Some(fix);
207 207
208 fn record_field_def_list(field_def_list: ast::FieldDefList) -> Option<ast::RecordFieldDefList> { 208 fn record_field_list(field_def_list: ast::FieldList) -> Option<ast::RecordFieldList> {
209 match field_def_list { 209 match field_def_list {
210 ast::FieldDefList::RecordFieldDefList(it) => Some(it), 210 ast::FieldList::RecordFieldList(it) => Some(it),
211 ast::FieldDefList::TupleFieldDefList(_) => None, 211 ast::FieldList::TupleFieldList(_) => None,
212 } 212 }
213 } 213 }
214} 214}
@@ -263,8 +263,8 @@ fn check_struct_shorthand_initialization(
263 file_id: FileId, 263 file_id: FileId,
264 node: &SyntaxNode, 264 node: &SyntaxNode,
265) -> Option<()> { 265) -> Option<()> {
266 let record_lit = ast::RecordLit::cast(node.clone())?; 266 let record_lit = ast::RecordExpr::cast(node.clone())?;
267 let record_field_list = record_lit.record_field_list()?; 267 let record_field_list = record_lit.record_expr_field_list()?;
268 for record_field in record_field_list.fields() { 268 for record_field in record_field_list.fields() {
269 if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) { 269 if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) {
270 let field_name = name_ref.syntax().text().to_string(); 270 let field_name = name_ref.syntax().text().to_string();
diff --git a/crates/ra_ide/src/display.rs b/crates/ra_ide/src/display.rs
index 6d4151dd8..fd42aa435 100644
--- a/crates/ra_ide/src/display.rs
+++ b/crates/ra_ide/src/display.rs
@@ -5,7 +5,7 @@ mod navigation_target;
5mod short_label; 5mod short_label;
6 6
7use ra_syntax::{ 7use ra_syntax::{
8 ast::{self, AstNode, AttrsOwner, NameOwner, TypeParamsOwner}, 8 ast::{self, AstNode, AttrsOwner, GenericParamsOwner, NameOwner},
9 SyntaxKind::{ATTR, COMMENT}, 9 SyntaxKind::{ATTR, COMMENT},
10}; 10};
11 11
@@ -16,7 +16,7 @@ pub use navigation_target::NavigationTarget;
16pub(crate) use navigation_target::{ToNav, TryToNav}; 16pub(crate) use navigation_target::{ToNav, TryToNav};
17pub(crate) use short_label::ShortLabel; 17pub(crate) use short_label::ShortLabel;
18 18
19pub(crate) fn function_declaration(node: &ast::FnDef) -> String { 19pub(crate) fn function_declaration(node: &ast::Fn) -> String {
20 let mut buf = String::new(); 20 let mut buf = String::new();
21 if let Some(vis) = node.visibility() { 21 if let Some(vis) = node.visibility() {
22 format_to!(buf, "{} ", vis); 22 format_to!(buf, "{} ", vis);
@@ -37,14 +37,14 @@ pub(crate) fn function_declaration(node: &ast::FnDef) -> String {
37 if let Some(name) = node.name() { 37 if let Some(name) = node.name() {
38 format_to!(buf, "fn {}", name) 38 format_to!(buf, "fn {}", name)
39 } 39 }
40 if let Some(type_params) = node.type_param_list() { 40 if let Some(type_params) = node.generic_param_list() {
41 format_to!(buf, "{}", type_params); 41 format_to!(buf, "{}", type_params);
42 } 42 }
43 if let Some(param_list) = node.param_list() { 43 if let Some(param_list) = node.param_list() {
44 format_to!(buf, "{}", param_list); 44 format_to!(buf, "{}", param_list);
45 } 45 }
46 if let Some(ret_type) = node.ret_type() { 46 if let Some(ret_type) = node.ret_type() {
47 if ret_type.type_ref().is_some() { 47 if ret_type.ty().is_some() {
48 format_to!(buf, " {}", ret_type); 48 format_to!(buf, " {}", ret_type);
49 } 49 }
50 } 50 }
@@ -54,7 +54,7 @@ pub(crate) fn function_declaration(node: &ast::FnDef) -> String {
54 buf 54 buf
55} 55}
56 56
57pub(crate) fn const_label(node: &ast::ConstDef) -> String { 57pub(crate) fn const_label(node: &ast::Const) -> String {
58 let label: String = node 58 let label: String = node
59 .syntax() 59 .syntax()
60 .children_with_tokens() 60 .children_with_tokens()
@@ -65,7 +65,7 @@ pub(crate) fn const_label(node: &ast::ConstDef) -> String {
65 label.trim().to_owned() 65 label.trim().to_owned()
66} 66}
67 67
68pub(crate) fn type_label(node: &ast::TypeAliasDef) -> String { 68pub(crate) fn type_label(node: &ast::TypeAlias) -> String {
69 let label: String = node 69 let label: String = node
70 .syntax() 70 .syntax()
71 .children_with_tokens() 71 .children_with_tokens()
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs
index fd245705c..45fbc86ef 100644
--- a/crates/ra_ide/src/display/navigation_target.rs
+++ b/crates/ra_ide/src/display/navigation_target.rs
@@ -379,16 +379,16 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option
379 379
380 match_ast! { 380 match_ast! {
381 match node { 381 match node {
382 ast::FnDef(it) => it.doc_comment_text(), 382 ast::Fn(it) => it.doc_comment_text(),
383 ast::StructDef(it) => it.doc_comment_text(), 383 ast::Struct(it) => it.doc_comment_text(),
384 ast::EnumDef(it) => it.doc_comment_text(), 384 ast::Enum(it) => it.doc_comment_text(),
385 ast::TraitDef(it) => it.doc_comment_text(), 385 ast::Trait(it) => it.doc_comment_text(),
386 ast::Module(it) => it.doc_comment_text(), 386 ast::Module(it) => it.doc_comment_text(),
387 ast::TypeAliasDef(it) => it.doc_comment_text(), 387 ast::TypeAlias(it) => it.doc_comment_text(),
388 ast::ConstDef(it) => it.doc_comment_text(), 388 ast::Const(it) => it.doc_comment_text(),
389 ast::StaticDef(it) => it.doc_comment_text(), 389 ast::Static(it) => it.doc_comment_text(),
390 ast::RecordFieldDef(it) => it.doc_comment_text(), 390 ast::RecordField(it) => it.doc_comment_text(),
391 ast::EnumVariant(it) => it.doc_comment_text(), 391 ast::Variant(it) => it.doc_comment_text(),
392 ast::MacroCall(it) => it.doc_comment_text(), 392 ast::MacroCall(it) => it.doc_comment_text(),
393 _ => None, 393 _ => None,
394 } 394 }
@@ -404,16 +404,16 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) ->
404 404
405 match_ast! { 405 match_ast! {
406 match node { 406 match node {
407 ast::FnDef(it) => it.short_label(), 407 ast::Fn(it) => it.short_label(),
408 ast::StructDef(it) => it.short_label(), 408 ast::Struct(it) => it.short_label(),
409 ast::EnumDef(it) => it.short_label(), 409 ast::Enum(it) => it.short_label(),
410 ast::TraitDef(it) => it.short_label(), 410 ast::Trait(it) => it.short_label(),
411 ast::Module(it) => it.short_label(), 411 ast::Module(it) => it.short_label(),
412 ast::TypeAliasDef(it) => it.short_label(), 412 ast::TypeAlias(it) => it.short_label(),
413 ast::ConstDef(it) => it.short_label(), 413 ast::Const(it) => it.short_label(),
414 ast::StaticDef(it) => it.short_label(), 414 ast::Static(it) => it.short_label(),
415 ast::RecordFieldDef(it) => it.short_label(), 415 ast::RecordField(it) => it.short_label(),
416 ast::EnumVariant(it) => it.short_label(), 416 ast::Variant(it) => it.short_label(),
417 _ => None, 417 _ => None,
418 } 418 }
419 } 419 }
@@ -446,7 +446,7 @@ fn foo() { enum FooInner { } }
446 5..13, 446 5..13,
447 ), 447 ),
448 name: "FooInner", 448 name: "FooInner",
449 kind: ENUM_DEF, 449 kind: ENUM,
450 container_name: None, 450 container_name: None,
451 description: Some( 451 description: Some(
452 "enum FooInner", 452 "enum FooInner",
@@ -462,7 +462,7 @@ fn foo() { enum FooInner { } }
462 34..42, 462 34..42,
463 ), 463 ),
464 name: "FooInner", 464 name: "FooInner",
465 kind: ENUM_DEF, 465 kind: ENUM,
466 container_name: Some( 466 container_name: Some(
467 "foo", 467 "foo",
468 ), 468 ),
diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs
index 5588130a1..bddf1bd47 100644
--- a/crates/ra_ide/src/display/short_label.rs
+++ b/crates/ra_ide/src/display/short_label.rs
@@ -1,37 +1,37 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner}; 3use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
4use stdx::format_to; 4use stdx::format_to;
5 5
6pub(crate) trait ShortLabel { 6pub(crate) trait ShortLabel {
7 fn short_label(&self) -> Option<String>; 7 fn short_label(&self) -> Option<String>;
8} 8}
9 9
10impl ShortLabel for ast::FnDef { 10impl ShortLabel for ast::Fn {
11 fn short_label(&self) -> Option<String> { 11 fn short_label(&self) -> Option<String> {
12 Some(crate::display::function_declaration(self)) 12 Some(crate::display::function_declaration(self))
13 } 13 }
14} 14}
15 15
16impl ShortLabel for ast::StructDef { 16impl ShortLabel for ast::Struct {
17 fn short_label(&self) -> Option<String> { 17 fn short_label(&self) -> Option<String> {
18 short_label_from_node(self, "struct ") 18 short_label_from_node(self, "struct ")
19 } 19 }
20} 20}
21 21
22impl ShortLabel for ast::UnionDef { 22impl ShortLabel for ast::Union {
23 fn short_label(&self) -> Option<String> { 23 fn short_label(&self) -> Option<String> {
24 short_label_from_node(self, "union ") 24 short_label_from_node(self, "union ")
25 } 25 }
26} 26}
27 27
28impl ShortLabel for ast::EnumDef { 28impl ShortLabel for ast::Enum {
29 fn short_label(&self) -> Option<String> { 29 fn short_label(&self) -> Option<String> {
30 short_label_from_node(self, "enum ") 30 short_label_from_node(self, "enum ")
31 } 31 }
32} 32}
33 33
34impl ShortLabel for ast::TraitDef { 34impl ShortLabel for ast::Trait {
35 fn short_label(&self) -> Option<String> { 35 fn short_label(&self) -> Option<String> {
36 if self.unsafe_token().is_some() { 36 if self.unsafe_token().is_some() {
37 short_label_from_node(self, "unsafe trait ") 37 short_label_from_node(self, "unsafe trait ")
@@ -47,43 +47,43 @@ impl ShortLabel for ast::Module {
47 } 47 }
48} 48}
49 49
50impl ShortLabel for ast::TypeAliasDef { 50impl ShortLabel for ast::TypeAlias {
51 fn short_label(&self) -> Option<String> { 51 fn short_label(&self) -> Option<String> {
52 short_label_from_node(self, "type ") 52 short_label_from_node(self, "type ")
53 } 53 }
54} 54}
55 55
56impl ShortLabel for ast::ConstDef { 56impl ShortLabel for ast::Const {
57 fn short_label(&self) -> Option<String> { 57 fn short_label(&self) -> Option<String> {
58 short_label_from_ascribed_node(self, "const ") 58 short_label_from_ty(self, self.ty(), "const ")
59 } 59 }
60} 60}
61 61
62impl ShortLabel for ast::StaticDef { 62impl ShortLabel for ast::Static {
63 fn short_label(&self) -> Option<String> { 63 fn short_label(&self) -> Option<String> {
64 short_label_from_ascribed_node(self, "static ") 64 short_label_from_ty(self, self.ty(), "static ")
65 } 65 }
66} 66}
67 67
68impl ShortLabel for ast::RecordFieldDef { 68impl ShortLabel for ast::RecordField {
69 fn short_label(&self) -> Option<String> { 69 fn short_label(&self) -> Option<String> {
70 short_label_from_ascribed_node(self, "") 70 short_label_from_ty(self, self.ty(), "")
71 } 71 }
72} 72}
73 73
74impl ShortLabel for ast::EnumVariant { 74impl ShortLabel for ast::Variant {
75 fn short_label(&self) -> Option<String> { 75 fn short_label(&self) -> Option<String> {
76 Some(self.name()?.text().to_string()) 76 Some(self.name()?.text().to_string())
77 } 77 }
78} 78}
79 79
80fn short_label_from_ascribed_node<T>(node: &T, prefix: &str) -> Option<String> 80fn short_label_from_ty<T>(node: &T, ty: Option<ast::TypeRef>, prefix: &str) -> Option<String>
81where 81where
82 T: NameOwner + VisibilityOwner + TypeAscriptionOwner, 82 T: NameOwner + VisibilityOwner,
83{ 83{
84 let mut buf = short_label_from_node(node, prefix)?; 84 let mut buf = short_label_from_node(node, prefix)?;
85 85
86 if let Some(type_ref) = node.ascribed_type() { 86 if let Some(type_ref) = ty {
87 format_to!(buf, ": {}", type_ref.syntax()); 87 format_to!(buf, ": {}", type_ref.syntax());
88 } 88 }
89 89
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs
index 8a6b3ea99..fc81b48cc 100644
--- a/crates/ra_ide/src/extend_selection.rs
+++ b/crates/ra_ide/src/extend_selection.rs
@@ -39,12 +39,12 @@ fn try_extend_selection(
39 let list_kinds = [ 39 let list_kinds = [
40 RECORD_FIELD_PAT_LIST, 40 RECORD_FIELD_PAT_LIST,
41 MATCH_ARM_LIST, 41 MATCH_ARM_LIST,
42 RECORD_FIELD_DEF_LIST,
43 TUPLE_FIELD_DEF_LIST,
44 RECORD_FIELD_LIST, 42 RECORD_FIELD_LIST,
45 ENUM_VARIANT_LIST, 43 TUPLE_FIELD_LIST,
44 RECORD_EXPR_FIELD_LIST,
45 VARIANT_LIST,
46 USE_TREE_LIST, 46 USE_TREE_LIST,
47 TYPE_PARAM_LIST, 47 GENERIC_PARAM_LIST,
48 TYPE_ARG_LIST, 48 TYPE_ARG_LIST,
49 TYPE_BOUND_LIST, 49 TYPE_BOUND_LIST,
50 PARAM_LIST, 50 PARAM_LIST,
diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs
index 1f6a3febf..91765140a 100644
--- a/crates/ra_ide/src/file_structure.rs
+++ b/crates/ra_ide/src/file_structure.rs
@@ -1,5 +1,5 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, 2 ast::{self, AttrsOwner, GenericParamsOwner, NameOwner},
3 match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, WalkEvent, 3 match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, WalkEvent,
4}; 4};
5 5
@@ -52,18 +52,11 @@ pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
52 52
53fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { 53fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
54 fn decl<N: NameOwner + AttrsOwner>(node: N) -> Option<StructureNode> { 54 fn decl<N: NameOwner + AttrsOwner>(node: N) -> Option<StructureNode> {
55 decl_with_detail(node, None) 55 decl_with_detail(&node, None)
56 }
57
58 fn decl_with_ascription<N: NameOwner + AttrsOwner + TypeAscriptionOwner>(
59 node: N,
60 ) -> Option<StructureNode> {
61 let ty = node.ascribed_type();
62 decl_with_type_ref(node, ty)
63 } 56 }
64 57
65 fn decl_with_type_ref<N: NameOwner + AttrsOwner>( 58 fn decl_with_type_ref<N: NameOwner + AttrsOwner>(
66 node: N, 59 node: &N,
67 type_ref: Option<ast::TypeRef>, 60 type_ref: Option<ast::TypeRef>,
68 ) -> Option<StructureNode> { 61 ) -> Option<StructureNode> {
69 let detail = type_ref.map(|type_ref| { 62 let detail = type_ref.map(|type_ref| {
@@ -75,7 +68,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
75 } 68 }
76 69
77 fn decl_with_detail<N: NameOwner + AttrsOwner>( 70 fn decl_with_detail<N: NameOwner + AttrsOwner>(
78 node: N, 71 node: &N,
79 detail: Option<String>, 72 detail: Option<String>,
80 ) -> Option<StructureNode> { 73 ) -> Option<StructureNode> {
81 let name = node.name()?; 74 let name = node.name()?;
@@ -111,9 +104,9 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
111 104
112 match_ast! { 105 match_ast! {
113 match node { 106 match node {
114 ast::FnDef(it) => { 107 ast::Fn(it) => {
115 let mut detail = String::from("fn"); 108 let mut detail = String::from("fn");
116 if let Some(type_param_list) = it.type_param_list() { 109 if let Some(type_param_list) = it.generic_param_list() {
117 collapse_ws(type_param_list.syntax(), &mut detail); 110 collapse_ws(type_param_list.syntax(), &mut detail);
118 } 111 }
119 if let Some(param_list) = it.param_list() { 112 if let Some(param_list) = it.param_list() {
@@ -124,22 +117,19 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
124 collapse_ws(ret_type.syntax(), &mut detail); 117 collapse_ws(ret_type.syntax(), &mut detail);
125 } 118 }
126 119
127 decl_with_detail(it, Some(detail)) 120 decl_with_detail(&it, Some(detail))
128 }, 121 },
129 ast::StructDef(it) => decl(it), 122 ast::Struct(it) => decl(it),
130 ast::UnionDef(it) => decl(it), 123 ast::Union(it) => decl(it),
131 ast::EnumDef(it) => decl(it), 124 ast::Enum(it) => decl(it),
132 ast::EnumVariant(it) => decl(it), 125 ast::Variant(it) => decl(it),
133 ast::TraitDef(it) => decl(it), 126 ast::Trait(it) => decl(it),
134 ast::Module(it) => decl(it), 127 ast::Module(it) => decl(it),
135 ast::TypeAliasDef(it) => { 128 ast::TypeAlias(it) => decl_with_type_ref(&it, it.ty()),
136 let ty = it.type_ref(); 129 ast::RecordField(it) => decl_with_type_ref(&it, it.ty()),
137 decl_with_type_ref(it, ty) 130 ast::Const(it) => decl_with_type_ref(&it, it.ty()),
138 }, 131 ast::Static(it) => decl_with_type_ref(&it, it.ty()),
139 ast::RecordFieldDef(it) => decl_with_ascription(it), 132 ast::Impl(it) => {
140 ast::ConstDef(it) => decl_with_ascription(it),
141 ast::StaticDef(it) => decl_with_ascription(it),
142 ast::ImplDef(it) => {
143 let target_type = it.target_type()?; 133 let target_type = it.target_type()?;
144 let target_trait = it.target_trait(); 134 let target_trait = it.target_trait();
145 let label = match target_trait { 135 let label = match target_trait {
@@ -238,7 +228,7 @@ fn very_obsolete() {}
238 label: "Foo", 228 label: "Foo",
239 navigation_range: 8..11, 229 navigation_range: 8..11,
240 node_range: 1..26, 230 node_range: 1..26,
241 kind: STRUCT_DEF, 231 kind: STRUCT,
242 detail: None, 232 detail: None,
243 deprecated: false, 233 deprecated: false,
244 }, 234 },
@@ -249,7 +239,7 @@ fn very_obsolete() {}
249 label: "x", 239 label: "x",
250 navigation_range: 18..19, 240 navigation_range: 18..19,
251 node_range: 18..24, 241 node_range: 18..24,
252 kind: RECORD_FIELD_DEF, 242 kind: RECORD_FIELD,
253 detail: Some( 243 detail: Some(
254 "i32", 244 "i32",
255 ), 245 ),
@@ -271,7 +261,7 @@ fn very_obsolete() {}
271 label: "bar1", 261 label: "bar1",
272 navigation_range: 43..47, 262 navigation_range: 43..47,
273 node_range: 40..52, 263 node_range: 40..52,
274 kind: FN_DEF, 264 kind: FN,
275 detail: Some( 265 detail: Some(
276 "fn()", 266 "fn()",
277 ), 267 ),
@@ -284,7 +274,7 @@ fn very_obsolete() {}
284 label: "bar2", 274 label: "bar2",
285 navigation_range: 60..64, 275 navigation_range: 60..64,
286 node_range: 57..81, 276 node_range: 57..81,
287 kind: FN_DEF, 277 kind: FN,
288 detail: Some( 278 detail: Some(
289 "fn<T>(t: T) -> T", 279 "fn<T>(t: T) -> T",
290 ), 280 ),
@@ -297,7 +287,7 @@ fn very_obsolete() {}
297 label: "bar3", 287 label: "bar3",
298 navigation_range: 89..93, 288 navigation_range: 89..93,
299 node_range: 86..156, 289 node_range: 86..156,
300 kind: FN_DEF, 290 kind: FN,
301 detail: Some( 291 detail: Some(
302 "fn<A, B>(a: A, b: B) -> Vec< u32 >", 292 "fn<A, B>(a: A, b: B) -> Vec< u32 >",
303 ), 293 ),
@@ -308,7 +298,7 @@ fn very_obsolete() {}
308 label: "E", 298 label: "E",
309 navigation_range: 165..166, 299 navigation_range: 165..166,
310 node_range: 160..180, 300 node_range: 160..180,
311 kind: ENUM_DEF, 301 kind: ENUM,
312 detail: None, 302 detail: None,
313 deprecated: false, 303 deprecated: false,
314 }, 304 },
@@ -319,7 +309,7 @@ fn very_obsolete() {}
319 label: "X", 309 label: "X",
320 navigation_range: 169..170, 310 navigation_range: 169..170,
321 node_range: 169..170, 311 node_range: 169..170,
322 kind: ENUM_VARIANT, 312 kind: VARIANT,
323 detail: None, 313 detail: None,
324 deprecated: false, 314 deprecated: false,
325 }, 315 },
@@ -330,7 +320,7 @@ fn very_obsolete() {}
330 label: "Y", 320 label: "Y",
331 navigation_range: 172..173, 321 navigation_range: 172..173,
332 node_range: 172..178, 322 node_range: 172..178,
333 kind: ENUM_VARIANT, 323 kind: VARIANT,
334 detail: None, 324 detail: None,
335 deprecated: false, 325 deprecated: false,
336 }, 326 },
@@ -339,7 +329,7 @@ fn very_obsolete() {}
339 label: "T", 329 label: "T",
340 navigation_range: 186..187, 330 navigation_range: 186..187,
341 node_range: 181..193, 331 node_range: 181..193,
342 kind: TYPE_ALIAS_DEF, 332 kind: TYPE_ALIAS,
343 detail: Some( 333 detail: Some(
344 "()", 334 "()",
345 ), 335 ),
@@ -350,7 +340,7 @@ fn very_obsolete() {}
350 label: "S", 340 label: "S",
351 navigation_range: 201..202, 341 navigation_range: 201..202,
352 node_range: 194..213, 342 node_range: 194..213,
353 kind: STATIC_DEF, 343 kind: STATIC,
354 detail: Some( 344 detail: Some(
355 "i32", 345 "i32",
356 ), 346 ),
@@ -361,7 +351,7 @@ fn very_obsolete() {}
361 label: "C", 351 label: "C",
362 navigation_range: 220..221, 352 navigation_range: 220..221,
363 node_range: 214..232, 353 node_range: 214..232,
364 kind: CONST_DEF, 354 kind: CONST,
365 detail: Some( 355 detail: Some(
366 "i32", 356 "i32",
367 ), 357 ),
@@ -372,7 +362,7 @@ fn very_obsolete() {}
372 label: "impl E", 362 label: "impl E",
373 navigation_range: 239..240, 363 navigation_range: 239..240,
374 node_range: 234..243, 364 node_range: 234..243,
375 kind: IMPL_DEF, 365 kind: IMPL,
376 detail: None, 366 detail: None,
377 deprecated: false, 367 deprecated: false,
378 }, 368 },
@@ -381,7 +371,7 @@ fn very_obsolete() {}
381 label: "impl fmt::Debug for E", 371 label: "impl fmt::Debug for E",
382 navigation_range: 265..266, 372 navigation_range: 265..266,
383 node_range: 245..269, 373 node_range: 245..269,
384 kind: IMPL_DEF, 374 kind: IMPL,
385 detail: None, 375 detail: None,
386 deprecated: false, 376 deprecated: false,
387 }, 377 },
@@ -417,7 +407,7 @@ fn very_obsolete() {}
417 label: "obsolete", 407 label: "obsolete",
418 navigation_range: 428..436, 408 navigation_range: 428..436,
419 node_range: 411..441, 409 node_range: 411..441,
420 kind: FN_DEF, 410 kind: FN,
421 detail: Some( 411 detail: Some(
422 "fn()", 412 "fn()",
423 ), 413 ),
@@ -428,7 +418,7 @@ fn very_obsolete() {}
428 label: "very_obsolete", 418 label: "very_obsolete",
429 navigation_range: 481..494, 419 navigation_range: 481..494,
430 node_range: 443..499, 420 node_range: 443..499,
431 kind: FN_DEF, 421 kind: FN,
432 detail: Some( 422 detail: Some(
433 "fn()", 423 "fn()",
434 ), 424 ),
diff --git a/crates/ra_ide/src/folding_ranges.rs b/crates/ra_ide/src/folding_ranges.rs
index bad079146..5a6e17936 100644
--- a/crates/ra_ide/src/folding_ranges.rs
+++ b/crates/ra_ide/src/folding_ranges.rs
@@ -85,15 +85,15 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
85 COMMENT => Some(FoldKind::Comment), 85 COMMENT => Some(FoldKind::Comment),
86 USE => Some(FoldKind::Imports), 86 USE => Some(FoldKind::Imports),
87 ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), 87 ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
88 RECORD_FIELD_DEF_LIST 88 RECORD_FIELD_LIST
89 | RECORD_FIELD_PAT_LIST 89 | RECORD_FIELD_PAT_LIST
90 | RECORD_FIELD_LIST 90 | RECORD_EXPR_FIELD_LIST
91 | ITEM_LIST 91 | ITEM_LIST
92 | EXTERN_ITEM_LIST 92 | EXTERN_ITEM_LIST
93 | USE_TREE_LIST 93 | USE_TREE_LIST
94 | BLOCK_EXPR 94 | BLOCK_EXPR
95 | MATCH_ARM_LIST 95 | MATCH_ARM_LIST
96 | ENUM_VARIANT_LIST 96 | VARIANT_LIST
97 | TOKEN_TREE => Some(FoldKind::Block), 97 | TOKEN_TREE => Some(FoldKind::Block),
98 _ => None, 98 _ => None,
99 } 99 }
diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs
index 16a61d071..9912b7142 100644
--- a/crates/ra_ide/src/goto_implementation.rs
+++ b/crates/ra_ide/src/goto_implementation.rs
@@ -28,7 +28,7 @@ pub(crate) fn goto_implementation(
28 nominal_def.syntax().text_range(), 28 nominal_def.syntax().text_range(),
29 impls_for_def(&sema, &nominal_def, krate)?, 29 impls_for_def(&sema, &nominal_def, krate)?,
30 )); 30 ));
31 } else if let Some(trait_def) = find_node_at_offset::<ast::TraitDef>(&syntax, position.offset) { 31 } else if let Some(trait_def) = find_node_at_offset::<ast::Trait>(&syntax, position.offset) {
32 return Some(RangeInfo::new( 32 return Some(RangeInfo::new(
33 trait_def.syntax().text_range(), 33 trait_def.syntax().text_range(),
34 impls_for_trait(&sema, &trait_def, krate)?, 34 impls_for_trait(&sema, &trait_def, krate)?,
@@ -44,9 +44,9 @@ fn impls_for_def(
44 krate: Crate, 44 krate: Crate,
45) -> Option<Vec<NavigationTarget>> { 45) -> Option<Vec<NavigationTarget>> {
46 let ty = match node { 46 let ty = match node {
47 ast::AdtDef::StructDef(def) => sema.to_def(def)?.ty(sema.db), 47 ast::AdtDef::Struct(def) => sema.to_def(def)?.ty(sema.db),
48 ast::AdtDef::EnumDef(def) => sema.to_def(def)?.ty(sema.db), 48 ast::AdtDef::Enum(def) => sema.to_def(def)?.ty(sema.db),
49 ast::AdtDef::UnionDef(def) => sema.to_def(def)?.ty(sema.db), 49 ast::AdtDef::Union(def) => sema.to_def(def)?.ty(sema.db),
50 }; 50 };
51 51
52 let impls = ImplDef::all_in_crate(sema.db, krate); 52 let impls = ImplDef::all_in_crate(sema.db, krate);
@@ -62,7 +62,7 @@ fn impls_for_def(
62 62
63fn impls_for_trait( 63fn impls_for_trait(
64 sema: &Semantics<RootDatabase>, 64 sema: &Semantics<RootDatabase>,
65 node: &ast::TraitDef, 65 node: &ast::Trait,
66 krate: Crate, 66 krate: Crate,
67) -> Option<Vec<NavigationTarget>> { 67) -> Option<Vec<NavigationTarget>> {
68 let tr = sema.to_def(node)?; 68 let tr = sema.to_def(node)?;
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index d067c339d..aa48cb412 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -1361,7 +1361,7 @@ fn foo_<|>test() {}
1361 11..19, 1361 11..19,
1362 ), 1362 ),
1363 name: "foo_test", 1363 name: "foo_test",
1364 kind: FN_DEF, 1364 kind: FN,
1365 container_name: None, 1365 container_name: None,
1366 description: None, 1366 description: None,
1367 docs: None, 1367 docs: None,
@@ -1443,7 +1443,7 @@ fn main() { let s<|>t = S{ f1:0 }; }
1443 7..8, 1443 7..8,
1444 ), 1444 ),
1445 name: "S", 1445 name: "S",
1446 kind: STRUCT_DEF, 1446 kind: STRUCT,
1447 container_name: None, 1447 container_name: None,
1448 description: Some( 1448 description: Some(
1449 "struct S", 1449 "struct S",
@@ -1482,7 +1482,7 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; }
1482 24..25, 1482 24..25,
1483 ), 1483 ),
1484 name: "S", 1484 name: "S",
1485 kind: STRUCT_DEF, 1485 kind: STRUCT,
1486 container_name: None, 1486 container_name: None,
1487 description: Some( 1487 description: Some(
1488 "struct S", 1488 "struct S",
@@ -1501,7 +1501,7 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; }
1501 7..10, 1501 7..10,
1502 ), 1502 ),
1503 name: "Arg", 1503 name: "Arg",
1504 kind: STRUCT_DEF, 1504 kind: STRUCT,
1505 container_name: None, 1505 container_name: None,
1506 description: Some( 1506 description: Some(
1507 "struct Arg", 1507 "struct Arg",
@@ -1540,7 +1540,7 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; }
1540 24..25, 1540 24..25,
1541 ), 1541 ),
1542 name: "S", 1542 name: "S",
1543 kind: STRUCT_DEF, 1543 kind: STRUCT,
1544 container_name: None, 1544 container_name: None,
1545 description: Some( 1545 description: Some(
1546 "struct S", 1546 "struct S",
@@ -1559,7 +1559,7 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; }
1559 7..10, 1559 7..10,
1560 ), 1560 ),
1561 name: "Arg", 1561 name: "Arg",
1562 kind: STRUCT_DEF, 1562 kind: STRUCT,
1563 container_name: None, 1563 container_name: None,
1564 description: Some( 1564 description: Some(
1565 "struct Arg", 1565 "struct Arg",
@@ -1601,7 +1601,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
1601 7..8, 1601 7..8,
1602 ), 1602 ),
1603 name: "A", 1603 name: "A",
1604 kind: STRUCT_DEF, 1604 kind: STRUCT,
1605 container_name: None, 1605 container_name: None,
1606 description: Some( 1606 description: Some(
1607 "struct A", 1607 "struct A",
@@ -1620,7 +1620,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
1620 22..23, 1620 22..23,
1621 ), 1621 ),
1622 name: "B", 1622 name: "B",
1623 kind: STRUCT_DEF, 1623 kind: STRUCT,
1624 container_name: None, 1624 container_name: None,
1625 description: Some( 1625 description: Some(
1626 "struct B", 1626 "struct B",
@@ -1639,7 +1639,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
1639 53..54, 1639 53..54,
1640 ), 1640 ),
1641 name: "C", 1641 name: "C",
1642 kind: STRUCT_DEF, 1642 kind: STRUCT,
1643 container_name: None, 1643 container_name: None,
1644 description: Some( 1644 description: Some(
1645 "pub struct C", 1645 "pub struct C",
@@ -1678,7 +1678,7 @@ fn main() { let s<|>t = foo(); }
1678 6..9, 1678 6..9,
1679 ), 1679 ),
1680 name: "Foo", 1680 name: "Foo",
1681 kind: TRAIT_DEF, 1681 kind: TRAIT,
1682 container_name: None, 1682 container_name: None,
1683 description: Some( 1683 description: Some(
1684 "trait Foo", 1684 "trait Foo",
@@ -1718,7 +1718,7 @@ fn main() { let s<|>t = foo(); }
1718 6..9, 1718 6..9,
1719 ), 1719 ),
1720 name: "Foo", 1720 name: "Foo",
1721 kind: TRAIT_DEF, 1721 kind: TRAIT,
1722 container_name: None, 1722 container_name: None,
1723 description: Some( 1723 description: Some(
1724 "trait Foo", 1724 "trait Foo",
@@ -1737,7 +1737,7 @@ fn main() { let s<|>t = foo(); }
1737 23..24, 1737 23..24,
1738 ), 1738 ),
1739 name: "S", 1739 name: "S",
1740 kind: STRUCT_DEF, 1740 kind: STRUCT,
1741 container_name: None, 1741 container_name: None,
1742 description: Some( 1742 description: Some(
1743 "struct S", 1743 "struct S",
@@ -1777,7 +1777,7 @@ fn main() { let s<|>t = foo(); }
1777 6..9, 1777 6..9,
1778 ), 1778 ),
1779 name: "Foo", 1779 name: "Foo",
1780 kind: TRAIT_DEF, 1780 kind: TRAIT,
1781 container_name: None, 1781 container_name: None,
1782 description: Some( 1782 description: Some(
1783 "trait Foo", 1783 "trait Foo",
@@ -1796,7 +1796,7 @@ fn main() { let s<|>t = foo(); }
1796 19..22, 1796 19..22,
1797 ), 1797 ),
1798 name: "Bar", 1798 name: "Bar",
1799 kind: TRAIT_DEF, 1799 kind: TRAIT,
1800 container_name: None, 1800 container_name: None,
1801 description: Some( 1801 description: Some(
1802 "trait Bar", 1802 "trait Bar",
@@ -1839,7 +1839,7 @@ fn main() { let s<|>t = foo(); }
1839 6..9, 1839 6..9,
1840 ), 1840 ),
1841 name: "Foo", 1841 name: "Foo",
1842 kind: TRAIT_DEF, 1842 kind: TRAIT,
1843 container_name: None, 1843 container_name: None,
1844 description: Some( 1844 description: Some(
1845 "trait Foo", 1845 "trait Foo",
@@ -1858,7 +1858,7 @@ fn main() { let s<|>t = foo(); }
1858 22..25, 1858 22..25,
1859 ), 1859 ),
1860 name: "Bar", 1860 name: "Bar",
1861 kind: TRAIT_DEF, 1861 kind: TRAIT,
1862 container_name: None, 1862 container_name: None,
1863 description: Some( 1863 description: Some(
1864 "trait Bar", 1864 "trait Bar",
@@ -1877,7 +1877,7 @@ fn main() { let s<|>t = foo(); }
1877 39..41, 1877 39..41,
1878 ), 1878 ),
1879 name: "S1", 1879 name: "S1",
1880 kind: STRUCT_DEF, 1880 kind: STRUCT,
1881 container_name: None, 1881 container_name: None,
1882 description: Some( 1882 description: Some(
1883 "struct S1", 1883 "struct S1",
@@ -1896,7 +1896,7 @@ fn main() { let s<|>t = foo(); }
1896 52..54, 1896 52..54,
1897 ), 1897 ),
1898 name: "S2", 1898 name: "S2",
1899 kind: STRUCT_DEF, 1899 kind: STRUCT,
1900 container_name: None, 1900 container_name: None,
1901 description: Some( 1901 description: Some(
1902 "struct S2", 1902 "struct S2",
@@ -1933,7 +1933,7 @@ fn foo(ar<|>g: &impl Foo) {}
1933 6..9, 1933 6..9,
1934 ), 1934 ),
1935 name: "Foo", 1935 name: "Foo",
1936 kind: TRAIT_DEF, 1936 kind: TRAIT,
1937 container_name: None, 1937 container_name: None,
1938 description: Some( 1938 description: Some(
1939 "trait Foo", 1939 "trait Foo",
@@ -1973,7 +1973,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
1973 6..9, 1973 6..9,
1974 ), 1974 ),
1975 name: "Foo", 1975 name: "Foo",
1976 kind: TRAIT_DEF, 1976 kind: TRAIT,
1977 container_name: None, 1977 container_name: None,
1978 description: Some( 1978 description: Some(
1979 "trait Foo", 1979 "trait Foo",
@@ -1992,7 +1992,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
1992 19..22, 1992 19..22,
1993 ), 1993 ),
1994 name: "Bar", 1994 name: "Bar",
1995 kind: TRAIT_DEF, 1995 kind: TRAIT,
1996 container_name: None, 1996 container_name: None,
1997 description: Some( 1997 description: Some(
1998 "trait Bar", 1998 "trait Bar",
@@ -2011,7 +2011,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
2011 36..37, 2011 36..37,
2012 ), 2012 ),
2013 name: "S", 2013 name: "S",
2014 kind: STRUCT_DEF, 2014 kind: STRUCT,
2015 container_name: None, 2015 container_name: None,
2016 description: Some( 2016 description: Some(
2017 "struct S", 2017 "struct S",
@@ -2049,7 +2049,7 @@ fn foo(ar<|>g: &impl Foo<S>) {}
2049 6..9, 2049 6..9,
2050 ), 2050 ),
2051 name: "Foo", 2051 name: "Foo",
2052 kind: TRAIT_DEF, 2052 kind: TRAIT,
2053 container_name: None, 2053 container_name: None,
2054 description: Some( 2054 description: Some(
2055 "trait Foo", 2055 "trait Foo",
@@ -2068,7 +2068,7 @@ fn foo(ar<|>g: &impl Foo<S>) {}
2068 23..24, 2068 23..24,
2069 ), 2069 ),
2070 name: "S", 2070 name: "S",
2071 kind: STRUCT_DEF, 2071 kind: STRUCT,
2072 container_name: None, 2072 container_name: None,
2073 description: Some( 2073 description: Some(
2074 "struct S", 2074 "struct S",
@@ -2111,7 +2111,7 @@ fn main() { let s<|>t = foo(); }
2111 49..50, 2111 49..50,
2112 ), 2112 ),
2113 name: "B", 2113 name: "B",
2114 kind: STRUCT_DEF, 2114 kind: STRUCT,
2115 container_name: None, 2115 container_name: None,
2116 description: Some( 2116 description: Some(
2117 "struct B", 2117 "struct B",
@@ -2130,7 +2130,7 @@ fn main() { let s<|>t = foo(); }
2130 6..9, 2130 6..9,
2131 ), 2131 ),
2132 name: "Foo", 2132 name: "Foo",
2133 kind: TRAIT_DEF, 2133 kind: TRAIT,
2134 container_name: None, 2134 container_name: None,
2135 description: Some( 2135 description: Some(
2136 "trait Foo", 2136 "trait Foo",
@@ -2167,7 +2167,7 @@ fn foo(ar<|>g: &dyn Foo) {}
2167 6..9, 2167 6..9,
2168 ), 2168 ),
2169 name: "Foo", 2169 name: "Foo",
2170 kind: TRAIT_DEF, 2170 kind: TRAIT,
2171 container_name: None, 2171 container_name: None,
2172 description: Some( 2172 description: Some(
2173 "trait Foo", 2173 "trait Foo",
@@ -2205,7 +2205,7 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
2205 6..9, 2205 6..9,
2206 ), 2206 ),
2207 name: "Foo", 2207 name: "Foo",
2208 kind: TRAIT_DEF, 2208 kind: TRAIT,
2209 container_name: None, 2209 container_name: None,
2210 description: Some( 2210 description: Some(
2211 "trait Foo", 2211 "trait Foo",
@@ -2224,7 +2224,7 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
2224 23..24, 2224 23..24,
2225 ), 2225 ),
2226 name: "S", 2226 name: "S",
2227 kind: STRUCT_DEF, 2227 kind: STRUCT,
2228 container_name: None, 2228 container_name: None,
2229 description: Some( 2229 description: Some(
2230 "struct S", 2230 "struct S",
@@ -2265,7 +2265,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
2265 6..15, 2265 6..15,
2266 ), 2266 ),
2267 name: "ImplTrait", 2267 name: "ImplTrait",
2268 kind: TRAIT_DEF, 2268 kind: TRAIT,
2269 container_name: None, 2269 container_name: None,
2270 description: Some( 2270 description: Some(
2271 "trait ImplTrait", 2271 "trait ImplTrait",
@@ -2284,7 +2284,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
2284 50..51, 2284 50..51,
2285 ), 2285 ),
2286 name: "B", 2286 name: "B",
2287 kind: STRUCT_DEF, 2287 kind: STRUCT,
2288 container_name: None, 2288 container_name: None,
2289 description: Some( 2289 description: Some(
2290 "struct B", 2290 "struct B",
@@ -2303,7 +2303,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
2303 28..36, 2303 28..36,
2304 ), 2304 ),
2305 name: "DynTrait", 2305 name: "DynTrait",
2306 kind: TRAIT_DEF, 2306 kind: TRAIT,
2307 container_name: None, 2307 container_name: None,
2308 description: Some( 2308 description: Some(
2309 "trait DynTrait", 2309 "trait DynTrait",
@@ -2322,7 +2322,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
2322 65..66, 2322 65..66,
2323 ), 2323 ),
2324 name: "S", 2324 name: "S",
2325 kind: STRUCT_DEF, 2325 kind: STRUCT,
2326 container_name: None, 2326 container_name: None,
2327 description: Some( 2327 description: Some(
2328 "struct S", 2328 "struct S",
@@ -2370,7 +2370,7 @@ fn main() { let s<|>t = test().get(); }
2370 6..9, 2370 6..9,
2371 ), 2371 ),
2372 name: "Foo", 2372 name: "Foo",
2373 kind: TRAIT_DEF, 2373 kind: TRAIT,
2374 container_name: None, 2374 container_name: None,
2375 description: Some( 2375 description: Some(
2376 "trait Foo", 2376 "trait Foo",
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index f2e4f7ee5..4bbbcd258 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -2,7 +2,7 @@ use hir::{Adt, Callable, HirDisplay, Semantics, Type};
2use ra_ide_db::RootDatabase; 2use ra_ide_db::RootDatabase;
3use ra_prof::profile; 3use ra_prof::profile;
4use ra_syntax::{ 4use ra_syntax::{
5 ast::{self, ArgListOwner, AstNode, TypeAscriptionOwner}, 5 ast::{self, ArgListOwner, AstNode},
6 match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T, 6 match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T,
7}; 7};
8use stdx::to_lower_snake_case; 8use stdx::to_lower_snake_case;
@@ -96,7 +96,7 @@ fn get_chaining_hints(
96 return None; 96 return None;
97 } 97 }
98 98
99 if matches!(expr, ast::Expr::RecordLit(_)) { 99 if matches!(expr, ast::Expr::RecordExpr(_)) {
100 return None; 100 return None;
101 } 101 }
102 102
@@ -230,10 +230,10 @@ fn should_not_display_type_hint(db: &RootDatabase, bind_pat: &ast::BindPat, pat_
230 match_ast! { 230 match_ast! {
231 match node { 231 match node {
232 ast::LetStmt(it) => { 232 ast::LetStmt(it) => {
233 return it.ascribed_type().is_some() 233 return it.ty().is_some()
234 }, 234 },
235 ast::Param(it) => { 235 ast::Param(it) => {
236 return it.ascribed_type().is_some() 236 return it.ty().is_some()
237 }, 237 },
238 ast::MatchArm(_it) => { 238 ast::MatchArm(_it) => {
239 return pat_is_enum_variant(db, bind_pat, pat_ty); 239 return pat_is_enum_variant(db, bind_pat, pat_ty);
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs
index fe1c074d1..519e4bf1a 100644
--- a/crates/ra_ide/src/references.rs
+++ b/crates/ra_ide/src/references.rs
@@ -172,16 +172,16 @@ fn get_struct_def_name_for_struct_literal_search(
172 if let Some(name) = 172 if let Some(name) =
173 sema.find_node_at_offset_with_descend::<ast::Name>(&syntax, left.text_range().start()) 173 sema.find_node_at_offset_with_descend::<ast::Name>(&syntax, left.text_range().start())
174 { 174 {
175 return name.syntax().ancestors().find_map(ast::StructDef::cast).and_then(|l| l.name()); 175 return name.syntax().ancestors().find_map(ast::Struct::cast).and_then(|l| l.name());
176 } 176 }
177 if sema 177 if sema
178 .find_node_at_offset_with_descend::<ast::TypeParamList>( 178 .find_node_at_offset_with_descend::<ast::GenericParamList>(
179 &syntax, 179 &syntax,
180 left.text_range().start(), 180 left.text_range().start(),
181 ) 181 )
182 .is_some() 182 .is_some()
183 { 183 {
184 return left.ancestors().find_map(ast::StructDef::cast).and_then(|l| l.name()); 184 return left.ancestors().find_map(ast::Struct::cast).and_then(|l| l.name());
185 } 185 }
186 } 186 }
187 None 187 None
@@ -212,7 +212,7 @@ fn main() {
212 ); 212 );
213 check_result( 213 check_result(
214 refs, 214 refs,
215 "Foo STRUCT_DEF FileId(1) 0..26 7..10 Other", 215 "Foo STRUCT FileId(1) 0..26 7..10 Other",
216 &["FileId(1) 101..104 StructLiteral"], 216 &["FileId(1) 101..104 StructLiteral"],
217 ); 217 );
218 } 218 }
@@ -230,7 +230,7 @@ struct Foo<|> {}
230 ); 230 );
231 check_result( 231 check_result(
232 refs, 232 refs,
233 "Foo STRUCT_DEF FileId(1) 0..13 7..10 Other", 233 "Foo STRUCT FileId(1) 0..13 7..10 Other",
234 &["FileId(1) 41..44 Other", "FileId(1) 54..57 StructLiteral"], 234 &["FileId(1) 41..44 Other", "FileId(1) 54..57 StructLiteral"],
235 ); 235 );
236 } 236 }
@@ -248,7 +248,7 @@ struct Foo<T> <|>{}
248 ); 248 );
249 check_result( 249 check_result(
250 refs, 250 refs,
251 "Foo STRUCT_DEF FileId(1) 0..16 7..10 Other", 251 "Foo STRUCT FileId(1) 0..16 7..10 Other",
252 &["FileId(1) 64..67 StructLiteral"], 252 &["FileId(1) 64..67 StructLiteral"],
253 ); 253 );
254 } 254 }
@@ -267,7 +267,7 @@ fn main() {
267 ); 267 );
268 check_result( 268 check_result(
269 refs, 269 refs,
270 "Foo STRUCT_DEF FileId(1) 0..16 7..10 Other", 270 "Foo STRUCT FileId(1) 0..16 7..10 Other",
271 &["FileId(1) 54..57 StructLiteral"], 271 &["FileId(1) 54..57 StructLiteral"],
272 ); 272 );
273 } 273 }
@@ -361,7 +361,7 @@ fn main(s: Foo) {
361 ); 361 );
362 check_result( 362 check_result(
363 refs, 363 refs,
364 "spam RECORD_FIELD_DEF FileId(1) 17..30 21..25 Other", 364 "spam RECORD_FIELD FileId(1) 17..30 21..25 Other",
365 &["FileId(1) 67..71 Other Read"], 365 &["FileId(1) 67..71 Other Read"],
366 ); 366 );
367 } 367 }
@@ -376,7 +376,7 @@ impl Foo {
376} 376}
377"#, 377"#,
378 ); 378 );
379 check_result(refs, "f FN_DEF FileId(1) 27..43 30..31 Other", &[]); 379 check_result(refs, "f FN FileId(1) 27..43 30..31 Other", &[]);
380 } 380 }
381 381
382 #[test] 382 #[test]
@@ -390,7 +390,7 @@ enum Foo {
390} 390}
391"#, 391"#,
392 ); 392 );
393 check_result(refs, "B ENUM_VARIANT FileId(1) 22..23 22..23 Other", &[]); 393 check_result(refs, "B VARIANT FileId(1) 22..23 22..23 Other", &[]);
394 } 394 }
395 395
396 #[test] 396 #[test]
@@ -431,7 +431,7 @@ fn f() {
431 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 431 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
432 check_result( 432 check_result(
433 refs, 433 refs,
434 "Foo STRUCT_DEF FileId(2) 17..51 28..31 Other", 434 "Foo STRUCT FileId(2) 17..51 28..31 Other",
435 &["FileId(1) 53..56 StructLiteral", "FileId(3) 79..82 StructLiteral"], 435 &["FileId(1) 53..56 StructLiteral", "FileId(3) 79..82 StructLiteral"],
436 ); 436 );
437 } 437 }
@@ -486,7 +486,7 @@ pub(super) struct Foo<|> {
486 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 486 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
487 check_result( 487 check_result(
488 refs, 488 refs,
489 "Foo STRUCT_DEF FileId(3) 0..41 18..21 Other", 489 "Foo STRUCT FileId(3) 0..41 18..21 Other",
490 &["FileId(2) 20..23 Other", "FileId(2) 47..50 StructLiteral"], 490 &["FileId(2) 20..23 Other", "FileId(2) 47..50 StructLiteral"],
491 ); 491 );
492 } 492 }
@@ -514,7 +514,7 @@ pub(super) struct Foo<|> {
514 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 514 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
515 check_result( 515 check_result(
516 refs, 516 refs,
517 "quux FN_DEF FileId(1) 19..35 26..30 Other", 517 "quux FN FileId(1) 19..35 26..30 Other",
518 &["FileId(2) 16..20 StructLiteral", "FileId(3) 16..20 StructLiteral"], 518 &["FileId(2) 16..20 StructLiteral", "FileId(3) 16..20 StructLiteral"],
519 ); 519 );
520 520
@@ -522,7 +522,7 @@ pub(super) struct Foo<|> {
522 analysis.find_all_refs(pos, Some(SearchScope::single_file(bar))).unwrap().unwrap(); 522 analysis.find_all_refs(pos, Some(SearchScope::single_file(bar))).unwrap().unwrap();
523 check_result( 523 check_result(
524 refs, 524 refs,
525 "quux FN_DEF FileId(1) 19..35 26..30 Other", 525 "quux FN FileId(1) 19..35 26..30 Other",
526 &["FileId(3) 16..20 StructLiteral"], 526 &["FileId(3) 16..20 StructLiteral"],
527 ); 527 );
528 } 528 }
@@ -580,7 +580,7 @@ fn foo() {
580 ); 580 );
581 check_result( 581 check_result(
582 refs, 582 refs,
583 "f RECORD_FIELD_DEF FileId(1) 15..21 15..16 Other", 583 "f RECORD_FIELD FileId(1) 15..21 15..16 Other",
584 &["FileId(1) 55..56 Other Read", "FileId(1) 68..69 Other Write"], 584 &["FileId(1) 55..56 Other Read", "FileId(1) 68..69 Other Write"],
585 ); 585 );
586 } 586 }
@@ -619,7 +619,7 @@ fn main() {
619 ); 619 );
620 check_result( 620 check_result(
621 refs, 621 refs,
622 "new FN_DEF FileId(1) 54..101 61..64 Other", 622 "new FN FileId(1) 54..101 61..64 Other",
623 &["FileId(1) 146..149 StructLiteral"], 623 &["FileId(1) 146..149 StructLiteral"],
624 ); 624 );
625 } 625 }
@@ -646,7 +646,7 @@ fn main() {
646 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 646 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
647 check_result( 647 check_result(
648 refs, 648 refs,
649 "f FN_DEF FileId(1) 26..35 29..30 Other", 649 "f FN FileId(1) 26..35 29..30 Other",
650 &["FileId(2) 11..12 Other", "FileId(2) 28..29 StructLiteral"], 650 &["FileId(2) 11..12 Other", "FileId(2) 28..29 StructLiteral"],
651 ); 651 );
652 } 652 }
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index 8735ec53c..31654bf79 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -7,7 +7,8 @@ use ra_ide_db::{
7 RootDatabase, 7 RootDatabase,
8}; 8};
9use ra_syntax::{ 9use ra_syntax::{
10 algo::find_node_at_offset, ast, ast::NameOwner, ast::TypeAscriptionOwner, 10 algo::find_node_at_offset,
11 ast::{self, NameOwner},
11 lex_single_valid_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, SyntaxToken, 12 lex_single_valid_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, SyntaxToken,
12}; 13};
13use ra_text_edit::TextEdit; 14use ra_text_edit::TextEdit;
@@ -149,13 +150,13 @@ fn rename_to_self(
149 let source_file = sema.parse(position.file_id); 150 let source_file = sema.parse(position.file_id);
150 let syn = source_file.syntax(); 151 let syn = source_file.syntax();
151 152
152 let fn_def = find_node_at_offset::<ast::FnDef>(syn, position.offset)?; 153 let fn_def = find_node_at_offset::<ast::Fn>(syn, position.offset)?;
153 let params = fn_def.param_list()?; 154 let params = fn_def.param_list()?;
154 if params.self_param().is_some() { 155 if params.self_param().is_some() {
155 return None; // method already has self param 156 return None; // method already has self param
156 } 157 }
157 let first_param = params.params().next()?; 158 let first_param = params.params().next()?;
158 let mutable = match first_param.ascribed_type() { 159 let mutable = match first_param.ty() {
159 Some(ast::TypeRef::ReferenceType(rt)) => rt.mut_token().is_some(), 160 Some(ast::TypeRef::ReferenceType(rt)) => rt.mut_token().is_some(),
160 _ => return None, // not renaming other types 161 _ => return None, // not renaming other types
161 }; 162 };
@@ -192,15 +193,14 @@ fn text_edit_from_self_param(
192 self_param: &ast::SelfParam, 193 self_param: &ast::SelfParam,
193 new_name: &str, 194 new_name: &str,
194) -> Option<TextEdit> { 195) -> Option<TextEdit> {
195 fn target_type_name(impl_def: &ast::ImplDef) -> Option<String> { 196 fn target_type_name(impl_def: &ast::Impl) -> Option<String> {
196 if let Some(ast::TypeRef::PathType(p)) = impl_def.target_type() { 197 if let Some(ast::TypeRef::PathType(p)) = impl_def.target_type() {
197 return Some(p.path()?.segment()?.name_ref()?.text().to_string()); 198 return Some(p.path()?.segment()?.name_ref()?.text().to_string());
198 } 199 }
199 None 200 None
200 } 201 }
201 202
202 let impl_def = 203 let impl_def = find_node_at_offset::<ast::Impl>(syn, self_param.syntax().text_range().start())?;
203 find_node_at_offset::<ast::ImplDef>(syn, self_param.syntax().text_range().start())?;
204 let type_name = target_type_name(&impl_def)?; 204 let type_name = target_type_name(&impl_def)?;
205 205
206 let mut replacement_text = String::from(new_name); 206 let mut replacement_text = String::from(new_name);
@@ -221,7 +221,7 @@ fn rename_self_to_param(
221 let syn = source_file.syntax(); 221 let syn = source_file.syntax();
222 222
223 let text = sema.db.file_text(position.file_id); 223 let text = sema.db.file_text(position.file_id);
224 let fn_def = find_node_at_offset::<ast::FnDef>(syn, position.offset)?; 224 let fn_def = find_node_at_offset::<ast::Fn>(syn, position.offset)?;
225 let search_range = fn_def.syntax().text_range(); 225 let search_range = fn_def.syntax().text_range();
226 226
227 let mut edits: Vec<SourceFileEdit> = vec![]; 227 let mut edits: Vec<SourceFileEdit> = vec![];
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs
index f612835c2..3b7162b84 100644
--- a/crates/ra_ide/src/runnables.rs
+++ b/crates/ra_ide/src/runnables.rs
@@ -102,7 +102,7 @@ pub(crate) fn runnable(
102) -> Option<Runnable> { 102) -> Option<Runnable> {
103 match_ast! { 103 match_ast! {
104 match item { 104 match item {
105 ast::FnDef(it) => runnable_fn(sema, it, file_id), 105 ast::Fn(it) => runnable_fn(sema, it, file_id),
106 ast::Module(it) => runnable_mod(sema, it, file_id), 106 ast::Module(it) => runnable_mod(sema, it, file_id),
107 _ => None, 107 _ => None,
108 } 108 }
@@ -111,7 +111,7 @@ pub(crate) fn runnable(
111 111
112fn runnable_fn( 112fn runnable_fn(
113 sema: &Semantics<RootDatabase>, 113 sema: &Semantics<RootDatabase>,
114 fn_def: ast::FnDef, 114 fn_def: ast::Fn,
115 file_id: FileId, 115 file_id: FileId,
116) -> Option<Runnable> { 116) -> Option<Runnable> {
117 let name_string = fn_def.name()?.text().to_string(); 117 let name_string = fn_def.name()?.text().to_string();
@@ -188,7 +188,7 @@ pub struct TestAttr {
188} 188}
189 189
190impl TestAttr { 190impl TestAttr {
191 fn from_fn(fn_def: &ast::FnDef) -> TestAttr { 191 fn from_fn(fn_def: &ast::Fn) -> TestAttr {
192 let ignore = fn_def 192 let ignore = fn_def
193 .attrs() 193 .attrs()
194 .filter_map(|attr| attr.simple_name()) 194 .filter_map(|attr| attr.simple_name())
@@ -203,7 +203,7 @@ impl TestAttr {
203/// 203///
204/// It may produce false positives, for example, `#[wasm_bindgen_test]` requires a different command to run the test, 204/// It may produce false positives, for example, `#[wasm_bindgen_test]` requires a different command to run the test,
205/// but it's better than not to have the runnables for the tests at all. 205/// but it's better than not to have the runnables for the tests at all.
206fn has_test_related_attribute(fn_def: &ast::FnDef) -> bool { 206fn has_test_related_attribute(fn_def: &ast::Fn) -> bool {
207 fn_def 207 fn_def
208 .attrs() 208 .attrs()
209 .filter_map(|attr| attr.path()) 209 .filter_map(|attr| attr.path())
@@ -211,7 +211,7 @@ fn has_test_related_attribute(fn_def: &ast::FnDef) -> bool {
211 .any(|attribute_text| attribute_text.contains("test")) 211 .any(|attribute_text| attribute_text.contains("test"))
212} 212}
213 213
214fn has_doc_test(fn_def: &ast::FnDef) -> bool { 214fn has_doc_test(fn_def: &ast::Fn) -> bool {
215 fn_def.doc_comment_text().map_or(false, |comment| comment.contains("```")) 215 fn_def.doc_comment_text().map_or(false, |comment| comment.contains("```"))
216} 216}
217 217
@@ -246,7 +246,7 @@ fn has_test_function_or_multiple_test_submodules(module: &ast::Module) -> bool {
246 246
247 for item in item_list.items() { 247 for item in item_list.items() {
248 match item { 248 match item {
249 ast::Item::FnDef(f) => { 249 ast::Item::Fn(f) => {
250 if has_test_related_attribute(&f) { 250 if has_test_related_attribute(&f) {
251 return true; 251 return true;
252 } 252 }
@@ -320,7 +320,7 @@ fn bench() {}
320 4..8, 320 4..8,
321 ), 321 ),
322 name: "main", 322 name: "main",
323 kind: FN_DEF, 323 kind: FN,
324 container_name: None, 324 container_name: None,
325 description: None, 325 description: None,
326 docs: None, 326 docs: None,
@@ -338,7 +338,7 @@ fn bench() {}
338 26..34, 338 26..34,
339 ), 339 ),
340 name: "test_foo", 340 name: "test_foo",
341 kind: FN_DEF, 341 kind: FN,
342 container_name: None, 342 container_name: None,
343 description: None, 343 description: None,
344 docs: None, 344 docs: None,
@@ -363,7 +363,7 @@ fn bench() {}
363 62..70, 363 62..70,
364 ), 364 ),
365 name: "test_foo", 365 name: "test_foo",
366 kind: FN_DEF, 366 kind: FN,
367 container_name: None, 367 container_name: None,
368 description: None, 368 description: None,
369 docs: None, 369 docs: None,
@@ -388,7 +388,7 @@ fn bench() {}
388 89..94, 388 89..94,
389 ), 389 ),
390 name: "bench", 390 name: "bench",
391 kind: FN_DEF, 391 kind: FN,
392 container_name: None, 392 container_name: None,
393 description: None, 393 description: None,
394 docs: None, 394 docs: None,
@@ -431,7 +431,7 @@ fn foo() {}
431 4..8, 431 4..8,
432 ), 432 ),
433 name: "main", 433 name: "main",
434 kind: FN_DEF, 434 kind: FN,
435 container_name: None, 435 container_name: None,
436 description: None, 436 description: None,
437 docs: None, 437 docs: None,
@@ -447,7 +447,7 @@ fn foo() {}
447 full_range: 15..57, 447 full_range: 15..57,
448 focus_range: None, 448 focus_range: None,
449 name: "foo", 449 name: "foo",
450 kind: FN_DEF, 450 kind: FN,
451 container_name: None, 451 container_name: None,
452 description: None, 452 description: None,
453 docs: None, 453 docs: None,
@@ -493,7 +493,7 @@ impl Data {
493 4..8, 493 4..8,
494 ), 494 ),
495 name: "main", 495 name: "main",
496 kind: FN_DEF, 496 kind: FN,
497 container_name: None, 497 container_name: None,
498 description: None, 498 description: None,
499 docs: None, 499 docs: None,
@@ -509,7 +509,7 @@ impl Data {
509 full_range: 44..98, 509 full_range: 44..98,
510 focus_range: None, 510 focus_range: None,
511 name: "foo", 511 name: "foo",
512 kind: FN_DEF, 512 kind: FN,
513 container_name: None, 513 container_name: None,
514 description: None, 514 description: None,
515 docs: None, 515 docs: None,
@@ -570,7 +570,7 @@ mod test_mod {
570 35..44, 570 35..44,
571 ), 571 ),
572 name: "test_foo1", 572 name: "test_foo1",
573 kind: FN_DEF, 573 kind: FN,
574 container_name: None, 574 container_name: None,
575 description: None, 575 description: None,
576 docs: None, 576 docs: None,
@@ -670,7 +670,7 @@ mod root_tests {
670 107..121, 670 107..121,
671 ), 671 ),
672 name: "nested_test_11", 672 name: "nested_test_11",
673 kind: FN_DEF, 673 kind: FN,
674 container_name: None, 674 container_name: None,
675 description: None, 675 description: None,
676 docs: None, 676 docs: None,
@@ -695,7 +695,7 @@ mod root_tests {
695 163..177, 695 163..177,
696 ), 696 ),
697 name: "nested_test_12", 697 name: "nested_test_12",
698 kind: FN_DEF, 698 kind: FN,
699 container_name: None, 699 container_name: None,
700 description: None, 700 description: None,
701 docs: None, 701 docs: None,
@@ -740,7 +740,7 @@ mod root_tests {
740 258..271, 740 258..271,
741 ), 741 ),
742 name: "nested_test_2", 742 name: "nested_test_2",
743 kind: FN_DEF, 743 kind: FN,
744 container_name: None, 744 container_name: None,
745 description: None, 745 description: None,
746 docs: None, 746 docs: None,
@@ -783,7 +783,7 @@ fn test_foo1() {}
783 36..45, 783 36..45,
784 ), 784 ),
785 name: "test_foo1", 785 name: "test_foo1",
786 kind: FN_DEF, 786 kind: FN,
787 container_name: None, 787 container_name: None,
788 description: None, 788 description: None,
789 docs: None, 789 docs: None,
@@ -831,7 +831,7 @@ fn test_foo1() {}
831 58..67, 831 58..67,
832 ), 832 ),
833 name: "test_foo1", 833 name: "test_foo1",
834 kind: FN_DEF, 834 kind: FN,
835 container_name: None, 835 container_name: None,
836 description: None, 836 description: None,
837 docs: None, 837 docs: None,
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index d456d5d36..e3a96f9d5 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -464,7 +464,7 @@ fn highlight_element(
464 let db = sema.db; 464 let db = sema.db;
465 let mut binding_hash = None; 465 let mut binding_hash = None;
466 let highlight: Highlight = match element.kind() { 466 let highlight: Highlight = match element.kind() {
467 FN_DEF => { 467 FN => {
468 bindings_shadow_count.clear(); 468 bindings_shadow_count.clear();
469 return None; 469 return None;
470 } 470 }
@@ -647,7 +647,7 @@ fn highlight_element(
647 647
648fn is_child_of_impl(element: &SyntaxElement) -> bool { 648fn is_child_of_impl(element: &SyntaxElement) -> bool {
649 match element.parent() { 649 match element.parent() {
650 Some(e) => e.kind() == IMPL_DEF, 650 Some(e) => e.kind() == IMPL,
651 _ => false, 651 _ => false,
652 } 652 }
653} 653}
@@ -705,18 +705,18 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight {
705 }; 705 };
706 706
707 let tag = match parent.kind() { 707 let tag = match parent.kind() {
708 STRUCT_DEF => HighlightTag::Struct, 708 STRUCT => HighlightTag::Struct,
709 ENUM_DEF => HighlightTag::Enum, 709 ENUM => HighlightTag::Enum,
710 UNION_DEF => HighlightTag::Union, 710 UNION => HighlightTag::Union,
711 TRAIT_DEF => HighlightTag::Trait, 711 TRAIT => HighlightTag::Trait,
712 TYPE_ALIAS_DEF => HighlightTag::TypeAlias, 712 TYPE_ALIAS => HighlightTag::TypeAlias,
713 TYPE_PARAM => HighlightTag::TypeParam, 713 TYPE_PARAM => HighlightTag::TypeParam,
714 RECORD_FIELD_DEF => HighlightTag::Field, 714 RECORD_FIELD => HighlightTag::Field,
715 MODULE => HighlightTag::Module, 715 MODULE => HighlightTag::Module,
716 FN_DEF => HighlightTag::Function, 716 FN => HighlightTag::Function,
717 CONST_DEF => HighlightTag::Constant, 717 CONST => HighlightTag::Constant,
718 STATIC_DEF => HighlightTag::Static, 718 STATIC => HighlightTag::Static,
719 ENUM_VARIANT => HighlightTag::EnumVariant, 719 VARIANT => HighlightTag::EnumVariant,
720 BIND_PAT => HighlightTag::Local, 720 BIND_PAT => HighlightTag::Local,
721 _ => default, 721 _ => default,
722 }; 722 };
diff --git a/crates/ra_ide/src/syntax_tree.rs b/crates/ra_ide/src/syntax_tree.rs
index f716a3861..07217e808 100644
--- a/crates/ra_ide/src/syntax_tree.rs
+++ b/crates/ra_ide/src/syntax_tree.rs
@@ -116,7 +116,7 @@ mod tests {
116 syn.trim(), 116 syn.trim(),
117 r#" 117 r#"
118[email protected] 118[email protected]
119 FN_DEF@0..11 119 [email protected]
120 [email protected] "fn" 120 [email protected] "fn"
121 [email protected] " " 121 [email protected] " "
122 [email protected] 122 [email protected]
@@ -148,7 +148,7 @@ fn test() {
148 syn.trim(), 148 syn.trim(),
149 r#" 149 r#"
150[email protected] 150[email protected]
151 FN_DEF@0..60 151 [email protected]
152 [email protected] "fn" 152 [email protected] "fn"
153 [email protected] " " 153 [email protected] " "
154 [email protected] 154 [email protected]
@@ -190,7 +190,7 @@ [email protected]
190 assert_eq_text!( 190 assert_eq_text!(
191 syn.trim(), 191 syn.trim(),
192 r#" 192 r#"
193FN_DEF@0..11 193[email protected]
194 [email protected] "fn" 194 [email protected] "fn"
195 [email protected] " " 195 [email protected] " "
196 [email protected] 196 [email protected]
@@ -258,7 +258,7 @@ fn bar() {
258 syn.trim(), 258 syn.trim(),
259 r#" 259 r#"
260[email protected] 260[email protected]
261 FN_DEF@0..12 261 [email protected]
262 [email protected] "fn" 262 [email protected] "fn"
263 [email protected] " " 263 [email protected] " "
264 [email protected] 264 [email protected]
@@ -292,7 +292,7 @@ fn bar() {
292 syn.trim(), 292 syn.trim(),
293 r#" 293 r#"
294[email protected] 294[email protected]
295 FN_DEF@0..12 295 [email protected]
296 [email protected] "fn" 296 [email protected] "fn"
297 [email protected] " " 297 [email protected] " "
298 [email protected] 298 [email protected]
@@ -325,7 +325,7 @@ fn bar() {
325 syn.trim(), 325 syn.trim(),
326 r#" 326 r#"
327[email protected] 327[email protected]
328 FN_DEF@0..12 328 [email protected]
329 [email protected] "fn" 329 [email protected] "fn"
330 [email protected] " " 330 [email protected] " "
331 [email protected] 331 [email protected]
@@ -339,7 +339,7 @@ [email protected]
339 [email protected] "\n" 339 [email protected] "\n"
340 [email protected] "}" 340 [email protected] "}"
341 [email protected] "\n" 341 [email protected] "\n"
342 FN_DEF@13..25 342 [email protected]
343 [email protected] "fn" 343 [email protected] "fn"
344 [email protected] " " 344 [email protected] " "
345 [email protected] 345 [email protected]