aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/ast_transform.rs4
-rw-r--r--crates/ra_assists/src/handlers/add_custom_impl.rs4
-rw-r--r--crates/ra_assists/src/handlers/add_explicit_type.rs16
-rw-r--r--crates/ra_assists/src/handlers/add_missing_impl_members.rs26
-rw-r--r--crates/ra_assists/src/handlers/change_return_type_to_result.rs6
-rw-r--r--crates/ra_assists/src/handlers/change_visibility.rs10
-rw-r--r--crates/ra_assists/src/handlers/early_return.rs4
-rw-r--r--crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs2
-rw-r--r--crates/ra_assists/src/handlers/extract_variable.rs2
-rw-r--r--crates/ra_assists/src/handlers/fix_visibility.rs2
-rw-r--r--crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs6
-rw-r--r--crates/ra_assists/src/handlers/generate_function.rs6
-rw-r--r--crates/ra_assists/src/handlers/generate_impl.rs4
-rw-r--r--crates/ra_assists/src/handlers/generate_new.rs22
-rw-r--r--crates/ra_assists/src/handlers/introduce_named_lifetime.rs22
-rw-r--r--crates/ra_assists/src/handlers/move_bounds.rs14
-rw-r--r--crates/ra_assists/src/handlers/reorder_fields.rs6
-rw-r--r--crates/ra_assists/src/utils.rs10
18 files changed, 79 insertions, 87 deletions
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs
index 01adb834c..5ea4f9f5b 100644
--- a/crates/ra_assists/src/ast_transform.rs
+++ b/crates/ra_assists/src/ast_transform.rs
@@ -41,7 +41,7 @@ impl<'a> SubstituteTypeParams<'a> {
41 source_scope: &'a SemanticsScope<'a>, 41 source_scope: &'a SemanticsScope<'a>,
42 // FIXME: there's implicit invariant that `trait_` and `source_scope` match... 42 // FIXME: there's implicit invariant that `trait_` and `source_scope` match...
43 trait_: hir::Trait, 43 trait_: hir::Trait,
44 impl_def: ast::ImplDef, 44 impl_def: ast::Impl,
45 ) -> SubstituteTypeParams<'a> { 45 ) -> SubstituteTypeParams<'a> {
46 let substs = get_syntactic_substs(impl_def).unwrap_or_default(); 46 let substs = get_syntactic_substs(impl_def).unwrap_or_default();
47 let generic_def: hir::GenericDef = trait_.into(); 47 let generic_def: hir::GenericDef = trait_.into();
@@ -80,7 +80,7 @@ impl<'a> SubstituteTypeParams<'a> {
80 80
81 // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the 81 // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the
82 // trait ref, and then go from the types in the substs back to the syntax) 82 // trait ref, and then go from the types in the substs back to the syntax)
83 fn get_syntactic_substs(impl_def: ast::ImplDef) -> Option<Vec<ast::TypeRef>> { 83 fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::TypeRef>> {
84 let target_trait = impl_def.target_trait()?; 84 let target_trait = impl_def.target_trait()?;
85 let path_type = match target_trait { 85 let path_type = match target_trait {
86 ast::TypeRef::PathType(path) => path, 86 ast::TypeRef::PathType(path) => path,
diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs
index acb07e36a..b67438b6b 100644
--- a/crates/ra_assists/src/handlers/add_custom_impl.rs
+++ b/crates/ra_assists/src/handlers/add_custom_impl.rs
@@ -29,8 +29,8 @@ use crate::{
29// } 29// }
30// ``` 30// ```
31pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 31pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
32 let input = ctx.find_node_at_offset::<ast::AttrInput>()?; 32 let attr = ctx.find_node_at_offset::<ast::Attr>()?;
33 let attr = input.syntax().parent().and_then(ast::Attr::cast)?; 33 let input = attr.token_tree()?;
34 34
35 let attr_name = attr 35 let attr_name = attr
36 .syntax() 36 .syntax()
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs
index 39a5321d1..e69f0a89b 100644
--- a/crates/ra_assists/src/handlers/add_explicit_type.rs
+++ b/crates/ra_assists/src/handlers/add_explicit_type.rs
@@ -1,6 +1,6 @@
1use hir::HirDisplay; 1use hir::HirDisplay;
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{self, AstNode, LetStmt, NameOwner, TypeAscriptionOwner}, 3 ast::{self, AstNode, LetStmt, NameOwner},
4 TextRange, 4 TextRange,
5}; 5};
6 6
@@ -22,11 +22,11 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
22// } 22// }
23// ``` 23// ```
24pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 24pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
25 let stmt = ctx.find_node_at_offset::<LetStmt>()?; 25 let let_stmt = ctx.find_node_at_offset::<LetStmt>()?;
26 let module = ctx.sema.scope(stmt.syntax()).module()?; 26 let module = ctx.sema.scope(let_stmt.syntax()).module()?;
27 let expr = stmt.initializer()?; 27 let expr = let_stmt.initializer()?;
28 // Must be a binding 28 // Must be a binding
29 let pat = match stmt.pat()? { 29 let pat = match let_stmt.pat()? {
30 ast::Pat::BindPat(bind_pat) => bind_pat, 30 ast::Pat::BindPat(bind_pat) => bind_pat,
31 _ => return None, 31 _ => return None,
32 }; 32 };
@@ -34,8 +34,8 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio
34 // The binding must have a name 34 // The binding must have a name
35 let name = pat.name()?; 35 let name = pat.name()?;
36 let name_range = name.syntax().text_range(); 36 let name_range = name.syntax().text_range();
37 let stmt_range = stmt.syntax().text_range(); 37 let stmt_range = let_stmt.syntax().text_range();
38 let eq_range = stmt.eq_token()?.text_range(); 38 let eq_range = let_stmt.eq_token()?.text_range();
39 // Assist should only be applicable if cursor is between 'let' and '=' 39 // Assist should only be applicable if cursor is between 'let' and '='
40 let let_range = TextRange::new(stmt_range.start(), eq_range.start()); 40 let let_range = TextRange::new(stmt_range.start(), eq_range.start());
41 let cursor_in_range = let_range.contains_range(ctx.frange.range); 41 let cursor_in_range = let_range.contains_range(ctx.frange.range);
@@ -44,7 +44,7 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio
44 } 44 }
45 // Assist not applicable if the type has already been specified 45 // Assist not applicable if the type has already been specified
46 // and it has no placeholders 46 // and it has no placeholders
47 let ascribed_ty = stmt.ascribed_type(); 47 let ascribed_ty = let_stmt.ty();
48 if let Some(ty) = &ascribed_ty { 48 if let Some(ty) = &ascribed_ty {
49 if ty.syntax().descendants().find_map(ast::PlaceholderType::cast).is_none() { 49 if ty.syntax().descendants().find_map(ast::PlaceholderType::cast).is_none() {
50 return None; 50 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 a2d9006e4..95a750aee 100644
--- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs
+++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs
@@ -111,16 +111,16 @@ fn add_missing_impl_members_inner(
111 label: &'static str, 111 label: &'static str,
112) -> Option<()> { 112) -> Option<()> {
113 let _p = ra_prof::profile("add_missing_impl_members_inner"); 113 let _p = ra_prof::profile("add_missing_impl_members_inner");
114 let impl_def = ctx.find_node_at_offset::<ast::ImplDef>()?; 114 let impl_def = ctx.find_node_at_offset::<ast::Impl>()?;
115 let impl_item_list = impl_def.assoc_item_list()?; 115 let impl_item_list = impl_def.assoc_item_list()?;
116 116
117 let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; 117 let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?;
118 118
119 let def_name = |item: &ast::AssocItem| -> Option<SmolStr> { 119 let def_name = |item: &ast::AssocItem| -> Option<SmolStr> {
120 match item { 120 match item {
121 ast::AssocItem::FnDef(def) => def.name(), 121 ast::AssocItem::Fn(def) => def.name(),
122 ast::AssocItem::TypeAliasDef(def) => def.name(), 122 ast::AssocItem::TypeAlias(def) => def.name(),
123 ast::AssocItem::ConstDef(def) => def.name(), 123 ast::AssocItem::Const(def) => def.name(),
124 ast::AssocItem::MacroCall(_) => None, 124 ast::AssocItem::MacroCall(_) => None,
125 } 125 }
126 .map(|it| it.text().clone()) 126 .map(|it| it.text().clone())
@@ -129,13 +129,13 @@ fn add_missing_impl_members_inner(
129 let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) 129 let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def)
130 .iter() 130 .iter()
131 .map(|i| match i { 131 .map(|i| match i {
132 hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db()).value), 132 hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value),
133 hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value), 133 hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source(ctx.db()).value),
134 hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value), 134 hir::AssocItem::Const(i) => ast::AssocItem::Const(i.source(ctx.db()).value),
135 }) 135 })
136 .filter(|t| def_name(&t).is_some()) 136 .filter(|t| def_name(&t).is_some())
137 .filter(|t| match t { 137 .filter(|t| match t {
138 ast::AssocItem::FnDef(def) => match mode { 138 ast::AssocItem::Fn(def) => match mode {
139 AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(), 139 AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(),
140 AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(), 140 AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(),
141 }, 141 },
@@ -158,10 +158,8 @@ fn add_missing_impl_members_inner(
158 .into_iter() 158 .into_iter()
159 .map(|it| ast_transform::apply(&*ast_transform, it)) 159 .map(|it| ast_transform::apply(&*ast_transform, it))
160 .map(|it| match it { 160 .map(|it| match it {
161 ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)), 161 ast::AssocItem::Fn(def) => ast::AssocItem::Fn(add_body(def)),
162 ast::AssocItem::TypeAliasDef(def) => { 162 ast::AssocItem::TypeAlias(def) => ast::AssocItem::TypeAlias(def.remove_bounds()),
163 ast::AssocItem::TypeAliasDef(def.remove_bounds())
164 }
165 _ => it, 163 _ => it,
166 }) 164 })
167 .map(|it| edit::remove_attrs_and_docs(&it)); 165 .map(|it| edit::remove_attrs_and_docs(&it));
@@ -174,7 +172,7 @@ fn add_missing_impl_members_inner(
174 Some(cap) => { 172 Some(cap) => {
175 let mut cursor = Cursor::Before(first_new_item.syntax()); 173 let mut cursor = Cursor::Before(first_new_item.syntax());
176 let placeholder; 174 let placeholder;
177 if let ast::AssocItem::FnDef(func) = &first_new_item { 175 if let ast::AssocItem::Fn(func) = &first_new_item {
178 if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) { 176 if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) {
179 if m.syntax().text() == "todo!()" { 177 if m.syntax().text() == "todo!()" {
180 placeholder = m; 178 placeholder = m;
@@ -192,7 +190,7 @@ fn add_missing_impl_members_inner(
192 }) 190 })
193} 191}
194 192
195fn add_body(fn_def: ast::FnDef) -> ast::FnDef { 193fn add_body(fn_def: ast::Fn) -> ast::Fn {
196 if fn_def.body().is_some() { 194 if fn_def.body().is_some() {
197 return fn_def; 195 return fn_def;
198 } 196 }
diff --git a/crates/ra_assists/src/handlers/change_return_type_to_result.rs b/crates/ra_assists/src/handlers/change_return_type_to_result.rs
index def00f7d8..167e162d8 100644
--- a/crates/ra_assists/src/handlers/change_return_type_to_result.rs
+++ b/crates/ra_assists/src/handlers/change_return_type_to_result.rs
@@ -20,9 +20,9 @@ use test_utils::mark;
20pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 20pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
21 let ret_type = ctx.find_node_at_offset::<ast::RetType>()?; 21 let ret_type = ctx.find_node_at_offset::<ast::RetType>()?;
22 // FIXME: extend to lambdas as well 22 // FIXME: extend to lambdas as well
23 let fn_def = ret_type.syntax().parent().and_then(ast::FnDef::cast)?; 23 let fn_def = ret_type.syntax().parent().and_then(ast::Fn::cast)?;
24 24
25 let type_ref = &ret_type.type_ref()?; 25 let type_ref = &ret_type.ty()?;
26 let ret_type_str = type_ref.syntax().text().to_string(); 26 let ret_type_str = type_ref.syntax().text().to_string();
27 let first_part_ret_type = ret_type_str.splitn(2, '<').next(); 27 let first_part_ret_type = ret_type_str.splitn(2, '<').next();
28 if let Some(ret_type_first_part) = first_part_ret_type { 28 if let Some(ret_type_first_part) = first_part_ret_type {
@@ -240,7 +240,7 @@ fn get_tail_expr_from_block(expr: &Expr) -> Option<Vec<NodeType>> {
240 Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 240 Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
241 Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 241 Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
242 Expr::Label(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 242 Expr::Label(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
243 Expr::RecordLit(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 243 Expr::RecordExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
244 Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 244 Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
245 Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 245 Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
246 Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 246 Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs
index 4343b423c..724daa93f 100644
--- a/crates/ra_assists/src/handlers/change_visibility.rs
+++ b/crates/ra_assists/src/handlers/change_visibility.rs
@@ -1,9 +1,7 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, NameOwner, VisibilityOwner}, 2 ast::{self, NameOwner, VisibilityOwner},
3 AstNode, 3 AstNode,
4 SyntaxKind::{ 4 SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, VISIBILITY},
5 CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY,
6 },
7 T, 5 T,
8}; 6};
9use test_utils::mark; 7use test_utils::mark;
@@ -38,7 +36,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
38 36
39 let (offset, target) = if let Some(keyword) = item_keyword { 37 let (offset, target) = if let Some(keyword) = item_keyword {
40 let parent = keyword.parent(); 38 let parent = keyword.parent();
41 let def_kws = vec![CONST_DEF, STATIC_DEF, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF]; 39 let def_kws = vec![CONST, STATIC, FN, MODULE, STRUCT, ENUM, TRAIT];
42 // Parent is not a definition, can't add visibility 40 // Parent is not a definition, can't add visibility
43 if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { 41 if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) {
44 return None; 42 return None;
@@ -49,7 +47,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
49 } 47 }
50 (vis_offset(&parent), keyword.text_range()) 48 (vis_offset(&parent), keyword.text_range())
51 } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() { 49 } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() {
52 let field = field_name.syntax().ancestors().find_map(ast::RecordFieldDef::cast)?; 50 let field = field_name.syntax().ancestors().find_map(ast::RecordField::cast)?;
53 if field.name()? != field_name { 51 if field.name()? != field_name {
54 mark::hit!(change_visibility_field_false_positive); 52 mark::hit!(change_visibility_field_false_positive);
55 return None; 53 return None;
@@ -58,7 +56,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
58 return None; 56 return None;
59 } 57 }
60 (vis_offset(field.syntax()), field_name.syntax().text_range()) 58 (vis_offset(field.syntax()), field_name.syntax().text_range())
61 } else if let Some(field) = ctx.find_node_at_offset::<ast::TupleFieldDef>() { 59 } else if let Some(field) = ctx.find_node_at_offset::<ast::TupleField>() {
62 if field.visibility().is_some() { 60 if field.visibility().is_some() {
63 return None; 61 return None;
64 } 62 }
diff --git a/crates/ra_assists/src/handlers/early_return.rs b/crates/ra_assists/src/handlers/early_return.rs
index 330459f3c..3650289fd 100644
--- a/crates/ra_assists/src/handlers/early_return.rs
+++ b/crates/ra_assists/src/handlers/early_return.rs
@@ -8,7 +8,7 @@ use ra_syntax::{
8 make, 8 make,
9 }, 9 },
10 AstNode, 10 AstNode,
11 SyntaxKind::{FN_DEF, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE}, 11 SyntaxKind::{FN, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE},
12 SyntaxNode, 12 SyntaxNode,
13}; 13};
14 14
@@ -88,7 +88,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
88 88
89 let early_expression: ast::Expr = match parent_container.kind() { 89 let early_expression: ast::Expr = match parent_container.kind() {
90 WHILE_EXPR | LOOP_EXPR => make::expr_continue(), 90 WHILE_EXPR | LOOP_EXPR => make::expr_continue(),
91 FN_DEF => make::expr_return(), 91 FN => make::expr_return(),
92 _ => return None, 92 _ => return None,
93 }; 93 };
94 94
diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
index 2b8e273b3..ccec688ca 100644
--- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -31,7 +31,7 @@ pub(crate) fn extract_struct_from_enum_variant(
31 acc: &mut Assists, 31 acc: &mut Assists,
32 ctx: &AssistContext, 32 ctx: &AssistContext,
33) -> Option<()> { 33) -> Option<()> {
34 let variant = ctx.find_node_at_offset::<ast::EnumVariant>()?; 34 let variant = ctx.find_node_at_offset::<ast::Variant>()?;
35 let field_list = match variant.kind() { 35 let field_list = match variant.kind() {
36 ast::StructKind::Tuple(field_list) => field_list, 36 ast::StructKind::Tuple(field_list) => field_list,
37 _ => return None, 37 _ => return None,
diff --git a/crates/ra_assists/src/handlers/extract_variable.rs b/crates/ra_assists/src/handlers/extract_variable.rs
index 098adf078..b925a2884 100644
--- a/crates/ra_assists/src/handlers/extract_variable.rs
+++ b/crates/ra_assists/src/handlers/extract_variable.rs
@@ -45,7 +45,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option
45 target, 45 target,
46 move |edit| { 46 move |edit| {
47 let field_shorthand = 47 let field_shorthand =
48 match to_extract.syntax().parent().and_then(ast::RecordField::cast) { 48 match to_extract.syntax().parent().and_then(ast::RecordExprField::cast) {
49 Some(field) => field.name_ref(), 49 Some(field) => field.name_ref(),
50 None => None, 50 None => None,
51 }; 51 };
diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs
index 1d3ed3c6a..1aefa79cc 100644
--- a/crates/ra_assists/src/handlers/fix_visibility.rs
+++ b/crates/ra_assists/src/handlers/fix_visibility.rs
@@ -82,7 +82,7 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext) -> O
82} 82}
83 83
84fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 84fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
85 let record_field: ast::RecordField = ctx.find_node_at_offset()?; 85 let record_field: ast::RecordExprField = ctx.find_node_at_offset()?;
86 let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?; 86 let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?;
87 87
88 let current_module = ctx.sema.scope(record_field.syntax()).module()?; 88 let current_module = ctx.sema.scope(record_field.syntax()).module()?;
diff --git a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
index a347e3c2e..9da23640a 100644
--- a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
+++ b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
@@ -22,7 +22,7 @@ use crate::{utils::FamousDefs, AssistContext, AssistId, AssistKind, Assists};
22// } 22// }
23// ``` 23// ```
24pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 24pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
25 let variant = ctx.find_node_at_offset::<ast::EnumVariant>()?; 25 let variant = ctx.find_node_at_offset::<ast::Variant>()?;
26 let variant_name = variant.name()?; 26 let variant_name = variant.name()?;
27 let enum_name = variant.parent_enum().name()?; 27 let enum_name = variant.parent_enum().name()?;
28 let field_list = match variant.kind() { 28 let field_list = match variant.kind() {
@@ -32,7 +32,7 @@ pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext
32 if field_list.fields().count() != 1 { 32 if field_list.fields().count() != 1 {
33 return None; 33 return None;
34 } 34 }
35 let field_type = field_list.fields().next()?.type_ref()?; 35 let field_type = field_list.fields().next()?.ty()?;
36 let path = match field_type { 36 let path = match field_type {
37 ast::TypeRef::PathType(it) => it, 37 ast::TypeRef::PathType(it) => it,
38 _ => return None, 38 _ => return None,
@@ -69,7 +69,7 @@ impl From<{0}> for {1} {{
69 69
70fn existing_from_impl( 70fn existing_from_impl(
71 sema: &'_ hir::Semantics<'_, RootDatabase>, 71 sema: &'_ hir::Semantics<'_, RootDatabase>,
72 variant: &ast::EnumVariant, 72 variant: &ast::Variant,
73) -> Option<()> { 73) -> Option<()> {
74 let variant = sema.to_def(variant)?; 74 let variant = sema.to_def(variant)?;
75 let enum_ = variant.parent_enum(sema.db); 75 let enum_ = variant.parent_enum(sema.db);
diff --git a/crates/ra_assists/src/handlers/generate_function.rs b/crates/ra_assists/src/handlers/generate_function.rs
index b721b96bb..56510861d 100644
--- a/crates/ra_assists/src/handlers/generate_function.rs
+++ b/crates/ra_assists/src/handlers/generate_function.rs
@@ -82,7 +82,7 @@ struct FunctionTemplate {
82 insert_offset: TextSize, 82 insert_offset: TextSize,
83 placeholder_expr: ast::MacroCall, 83 placeholder_expr: ast::MacroCall,
84 leading_ws: String, 84 leading_ws: String,
85 fn_def: ast::FnDef, 85 fn_def: ast::Fn,
86 trailing_ws: String, 86 trailing_ws: String,
87 file: FileId, 87 file: FileId,
88} 88}
@@ -104,7 +104,7 @@ impl FunctionTemplate {
104struct FunctionBuilder { 104struct FunctionBuilder {
105 target: GeneratedFunctionTarget, 105 target: GeneratedFunctionTarget,
106 fn_name: ast::Name, 106 fn_name: ast::Name,
107 type_params: Option<ast::TypeParamList>, 107 type_params: Option<ast::GenericParamList>,
108 params: ast::ParamList, 108 params: ast::ParamList,
109 file: FileId, 109 file: FileId,
110 needs_pub: bool, 110 needs_pub: bool,
@@ -200,7 +200,7 @@ fn fn_args(
200 ctx: &AssistContext, 200 ctx: &AssistContext,
201 target_module: hir::Module, 201 target_module: hir::Module,
202 call: &ast::CallExpr, 202 call: &ast::CallExpr,
203) -> Option<(Option<ast::TypeParamList>, ast::ParamList)> { 203) -> Option<(Option<ast::GenericParamList>, ast::ParamList)> {
204 let mut arg_names = Vec::new(); 204 let mut arg_names = Vec::new();
205 let mut arg_types = Vec::new(); 205 let mut arg_types = Vec::new();
206 for arg in call.arg_list()?.args() { 206 for arg in call.arg_list()?.args() {
diff --git a/crates/ra_assists/src/handlers/generate_impl.rs b/crates/ra_assists/src/handlers/generate_impl.rs
index 42eb4defa..d9b87c9c0 100644
--- a/crates/ra_assists/src/handlers/generate_impl.rs
+++ b/crates/ra_assists/src/handlers/generate_impl.rs
@@ -1,4 +1,4 @@
1use ra_syntax::ast::{self, AstNode, NameOwner, TypeParamsOwner}; 1use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner};
2use stdx::{format_to, SepBy}; 2use stdx::{format_to, SepBy};
3 3
4use crate::{AssistContext, AssistId, AssistKind, Assists}; 4use crate::{AssistContext, AssistId, AssistKind, Assists};
@@ -31,7 +31,7 @@ pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()
31 format!("Generate impl for `{}`", name), 31 format!("Generate impl for `{}`", name),
32 target, 32 target,
33 |edit| { 33 |edit| {
34 let type_params = nominal.type_param_list(); 34 let type_params = nominal.generic_param_list();
35 let start_offset = nominal.syntax().text_range().end(); 35 let start_offset = nominal.syntax().text_range().end();
36 let mut buf = String::new(); 36 let mut buf = String::new();
37 buf.push_str("\n\nimpl"); 37 buf.push_str("\n\nimpl");
diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs
index 25bc171bf..b84aa24b6 100644
--- a/crates/ra_assists/src/handlers/generate_new.rs
+++ b/crates/ra_assists/src/handlers/generate_new.rs
@@ -1,8 +1,6 @@
1use hir::Adt; 1use hir::Adt;
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{ 3 ast::{self, AstNode, GenericParamsOwner, NameOwner, StructKind, VisibilityOwner},
4 self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner,
5 },
6 T, 4 T,
7}; 5};
8use stdx::{format_to, SepBy}; 6use stdx::{format_to, SepBy};
@@ -30,7 +28,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
30// 28//
31// ``` 29// ```
32pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 30pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
33 let strukt = ctx.find_node_at_offset::<ast::StructDef>()?; 31 let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
34 32
35 // We want to only apply this to non-union structs with named fields 33 // We want to only apply this to non-union structs with named fields
36 let field_list = match strukt.kind() { 34 let field_list = match strukt.kind() {
@@ -53,9 +51,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
53 51
54 let params = field_list 52 let params = field_list
55 .fields() 53 .fields()
56 .filter_map(|f| { 54 .filter_map(|f| Some(format!("{}: {}", f.name()?.syntax(), f.ty()?.syntax())))
57 Some(format!("{}: {}", f.name()?.syntax(), f.ascribed_type()?.syntax()))
58 })
59 .sep_by(", "); 55 .sep_by(", ");
60 let fields = field_list.fields().filter_map(|f| f.name()).sep_by(", "); 56 let fields = field_list.fields().filter_map(|f| f.name()).sep_by(", ");
61 57
@@ -90,8 +86,8 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
90 86
91// Generates the surrounding `impl Type { <code> }` including type and lifetime 87// Generates the surrounding `impl Type { <code> }` including type and lifetime
92// parameters 88// parameters
93fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { 89fn generate_impl_text(strukt: &ast::Struct, code: &str) -> String {
94 let type_params = strukt.type_param_list(); 90 let type_params = strukt.generic_param_list();
95 let mut buf = String::with_capacity(code.len()); 91 let mut buf = String::with_capacity(code.len());
96 buf.push_str("\n\nimpl"); 92 buf.push_str("\n\nimpl");
97 if let Some(type_params) = &type_params { 93 if let Some(type_params) = &type_params {
@@ -121,7 +117,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
121// 117//
122// FIXME: change the new fn checking to a more semantic approach when that's more 118// FIXME: change the new fn checking to a more semantic approach when that's more
123// viable (e.g. we process proc macros, etc) 119// viable (e.g. we process proc macros, etc)
124fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> { 120fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option<ast::Impl>> {
125 let db = ctx.db(); 121 let db = ctx.db();
126 let module = strukt.syntax().ancestors().find(|node| { 122 let module = strukt.syntax().ancestors().find(|node| {
127 ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) 123 ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind())
@@ -129,7 +125,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Opti
129 125
130 let struct_def = ctx.sema.to_def(strukt)?; 126 let struct_def = ctx.sema.to_def(strukt)?;
131 127
132 let block = module.descendants().filter_map(ast::ImplDef::cast).find_map(|impl_blk| { 128 let block = module.descendants().filter_map(ast::Impl::cast).find_map(|impl_blk| {
133 let blk = ctx.sema.to_def(&impl_blk)?; 129 let blk = ctx.sema.to_def(&impl_blk)?;
134 130
135 // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}` 131 // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}`
@@ -157,10 +153,10 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Opti
157 Some(block) 153 Some(block)
158} 154}
159 155
160fn has_new_fn(imp: &ast::ImplDef) -> bool { 156fn has_new_fn(imp: &ast::Impl) -> bool {
161 if let Some(il) = imp.assoc_item_list() { 157 if let Some(il) = imp.assoc_item_list() {
162 for item in il.assoc_items() { 158 for item in il.assoc_items() {
163 if let ast::AssocItem::FnDef(f) = item { 159 if let ast::AssocItem::Fn(f) = item {
164 if let Some(name) = f.name() { 160 if let Some(name) = f.name() {
165 if name.text().eq_ignore_ascii_case("new") { 161 if name.text().eq_ignore_ascii_case("new") {
166 return true; 162 return true;
diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs
index 967593031..c3134f64d 100644
--- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs
+++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs
@@ -1,5 +1,5 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, 2 ast::{self, GenericParamsOwner, NameOwner},
3 AstNode, SyntaxKind, TextRange, TextSize, 3 AstNode, SyntaxKind, TextRange, TextSize,
4}; 4};
5use rustc_hash::FxHashSet; 5use rustc_hash::FxHashSet;
@@ -38,9 +38,9 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -
38 let lifetime_token = ctx 38 let lifetime_token = ctx
39 .find_token_at_offset(SyntaxKind::LIFETIME) 39 .find_token_at_offset(SyntaxKind::LIFETIME)
40 .filter(|lifetime| lifetime.text() == "'_")?; 40 .filter(|lifetime| lifetime.text() == "'_")?;
41 if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::FnDef::cast) { 41 if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) {
42 generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) 42 generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range())
43 } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) { 43 } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::Impl::cast) {
44 generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range()) 44 generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range())
45 } else { 45 } else {
46 None 46 None
@@ -50,11 +50,11 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -
50/// Generate the assist for the fn def case 50/// Generate the assist for the fn def case
51fn generate_fn_def_assist( 51fn generate_fn_def_assist(
52 acc: &mut Assists, 52 acc: &mut Assists,
53 fn_def: &ast::FnDef, 53 fn_def: &ast::Fn,
54 lifetime_loc: TextRange, 54 lifetime_loc: TextRange,
55) -> Option<()> { 55) -> Option<()> {
56 let param_list: ast::ParamList = fn_def.param_list()?; 56 let param_list: ast::ParamList = fn_def.param_list()?;
57 let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.type_param_list())?; 57 let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.generic_param_list())?;
58 let end_of_fn_ident = fn_def.name()?.ident_token()?.text_range().end(); 58 let end_of_fn_ident = fn_def.name()?.ident_token()?.text_range().end();
59 let self_param = 59 let self_param =
60 // use the self if it's a reference and has no explicit lifetime 60 // use the self if it's a reference and has no explicit lifetime
@@ -67,7 +67,7 @@ fn generate_fn_def_assist(
67 // otherwise, if there's a single reference parameter without a named liftime, use that 67 // otherwise, if there's a single reference parameter without a named liftime, use that
68 let fn_params_without_lifetime: Vec<_> = param_list 68 let fn_params_without_lifetime: Vec<_> = param_list
69 .params() 69 .params()
70 .filter_map(|param| match param.ascribed_type() { 70 .filter_map(|param| match param.ty() {
71 Some(ast::TypeRef::ReferenceType(ascribed_type)) 71 Some(ast::TypeRef::ReferenceType(ascribed_type))
72 if ascribed_type.lifetime_token() == None => 72 if ascribed_type.lifetime_token() == None =>
73 { 73 {
@@ -93,10 +93,10 @@ fn generate_fn_def_assist(
93/// Generate the assist for the impl def case 93/// Generate the assist for the impl def case
94fn generate_impl_def_assist( 94fn generate_impl_def_assist(
95 acc: &mut Assists, 95 acc: &mut Assists,
96 impl_def: &ast::ImplDef, 96 impl_def: &ast::Impl,
97 lifetime_loc: TextRange, 97 lifetime_loc: TextRange,
98) -> Option<()> { 98) -> Option<()> {
99 let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.type_param_list())?; 99 let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?;
100 let end_of_impl_kw = impl_def.impl_token()?.text_range().end(); 100 let end_of_impl_kw = impl_def.impl_token()?.text_range().end();
101 acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| { 101 acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| {
102 add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param); 102 add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param);
@@ -107,7 +107,7 @@ fn generate_impl_def_assist(
107/// Given a type parameter list, generate a unique lifetime parameter name 107/// Given a type parameter list, generate a unique lifetime parameter name
108/// which is not in the list 108/// which is not in the list
109fn generate_unique_lifetime_param_name( 109fn generate_unique_lifetime_param_name(
110 existing_type_param_list: &Option<ast::TypeParamList>, 110 existing_type_param_list: &Option<ast::GenericParamList>,
111) -> Option<char> { 111) -> Option<char> {
112 match existing_type_param_list { 112 match existing_type_param_list {
113 Some(type_params) => { 113 Some(type_params) => {
@@ -123,13 +123,13 @@ fn generate_unique_lifetime_param_name(
123 123
124/// Add the lifetime param to `builder`. If there are type parameters in `type_params_owner`, add it to the end. Otherwise 124/// Add the lifetime param to `builder`. If there are type parameters in `type_params_owner`, add it to the end. Otherwise
125/// add new type params brackets with the lifetime parameter at `new_type_params_loc`. 125/// add new type params brackets with the lifetime parameter at `new_type_params_loc`.
126fn add_lifetime_param<TypeParamsOwner: ast::TypeParamsOwner>( 126fn add_lifetime_param<TypeParamsOwner: ast::GenericParamsOwner>(
127 type_params_owner: &TypeParamsOwner, 127 type_params_owner: &TypeParamsOwner,
128 builder: &mut AssistBuilder, 128 builder: &mut AssistBuilder,
129 new_type_params_loc: TextSize, 129 new_type_params_loc: TextSize,
130 new_lifetime_param: char, 130 new_lifetime_param: char,
131) { 131) {
132 match type_params_owner.type_param_list() { 132 match type_params_owner.generic_param_list() {
133 // add the new lifetime parameter to an existing type param list 133 // add the new lifetime parameter to an existing type param list
134 Some(type_params) => { 134 Some(type_params) => {
135 builder.insert( 135 builder.insert(
diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs
index 6b73fff44..6d394443e 100644
--- a/crates/ra_assists/src/handlers/move_bounds.rs
+++ b/crates/ra_assists/src/handlers/move_bounds.rs
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
23// } 23// }
24// ``` 24// ```
25pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 25pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
26 let type_param_list = ctx.find_node_at_offset::<ast::TypeParamList>()?; 26 let type_param_list = ctx.find_node_at_offset::<ast::GenericParamList>()?;
27 27
28 let mut type_params = type_param_list.type_params(); 28 let mut type_params = type_param_list.type_params();
29 if type_params.all(|p| p.type_bound_list().is_none()) { 29 if type_params.all(|p| p.type_bound_list().is_none()) {
@@ -37,13 +37,13 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext
37 37
38 let anchor = match_ast! { 38 let anchor = match_ast! {
39 match parent { 39 match parent {
40 ast::FnDef(it) => it.body()?.syntax().clone().into(), 40 ast::Fn(it) => it.body()?.syntax().clone().into(),
41 ast::TraitDef(it) => it.assoc_item_list()?.syntax().clone().into(), 41 ast::Trait(it) => it.assoc_item_list()?.syntax().clone().into(),
42 ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(), 42 ast::Impl(it) => it.assoc_item_list()?.syntax().clone().into(),
43 ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(), 43 ast::Enum(it) => it.variant_list()?.syntax().clone().into(),
44 ast::StructDef(it) => { 44 ast::Struct(it) => {
45 it.syntax().children_with_tokens() 45 it.syntax().children_with_tokens()
46 .find(|it| it.kind() == RECORD_FIELD_DEF_LIST || it.kind() == T![;])? 46 .find(|it| it.kind() == RECORD_FIELD_LIST || it.kind() == T![;])?
47 }, 47 },
48 _ => return None 48 _ => return None
49 } 49 }
diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/ra_assists/src/handlers/reorder_fields.rs
index 2ac1c56cf..120250e79 100644
--- a/crates/ra_assists/src/handlers/reorder_fields.rs
+++ b/crates/ra_assists/src/handlers/reorder_fields.rs
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
23// ``` 23// ```
24// 24//
25pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 25pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
26 reorder::<ast::RecordLit>(acc, ctx).or_else(|| reorder::<ast::RecordPat>(acc, ctx)) 26 reorder::<ast::RecordExpr>(acc, ctx).or_else(|| reorder::<ast::RecordPat>(acc, ctx))
27} 27}
28 28
29fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 29fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
@@ -56,7 +56,7 @@ fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
56 56
57fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> { 57fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> {
58 match node.kind() { 58 match node.kind() {
59 RECORD_LIT => vec![RECORD_FIELD], 59 RECORD_EXPR => vec![RECORD_EXPR_FIELD],
60 RECORD_PAT => vec![RECORD_FIELD_PAT, BIND_PAT], 60 RECORD_PAT => vec![RECORD_FIELD_PAT, BIND_PAT],
61 _ => vec![], 61 _ => vec![],
62 } 62 }
@@ -65,7 +65,7 @@ fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> {
65fn get_field_name(node: &SyntaxNode) -> String { 65fn get_field_name(node: &SyntaxNode) -> String {
66 let res = match_ast! { 66 let res = match_ast! {
67 match node { 67 match node {
68 ast::RecordField(field) => field.field_name().map(|it| it.to_string()), 68 ast::RecordExprField(field) => field.field_name().map(|it| it.to_string()),
69 ast::RecordFieldPat(field) => field.field_name().map(|it| it.to_string()), 69 ast::RecordFieldPat(field) => field.field_name().map(|it| it.to_string()),
70 _ => None, 70 _ => None,
71 } 71 }
diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs
index 27c33df23..bb16ebd4e 100644
--- a/crates/ra_assists/src/utils.rs
+++ b/crates/ra_assists/src/utils.rs
@@ -56,7 +56,7 @@ pub(crate) fn render_snippet(_cap: SnippetCap, node: &SyntaxNode, cursor: Cursor
56 56
57pub fn get_missing_assoc_items( 57pub fn get_missing_assoc_items(
58 sema: &Semantics<RootDatabase>, 58 sema: &Semantics<RootDatabase>,
59 impl_def: &ast::ImplDef, 59 impl_def: &ast::Impl,
60) -> Vec<hir::AssocItem> { 60) -> Vec<hir::AssocItem> {
61 // Names must be unique between constants and functions. However, type aliases 61 // Names must be unique between constants and functions. However, type aliases
62 // may share the same name as a function or constant. 62 // may share the same name as a function or constant.
@@ -66,19 +66,19 @@ pub fn get_missing_assoc_items(
66 if let Some(item_list) = impl_def.assoc_item_list() { 66 if let Some(item_list) = impl_def.assoc_item_list() {
67 for item in item_list.assoc_items() { 67 for item in item_list.assoc_items() {
68 match item { 68 match item {
69 ast::AssocItem::FnDef(f) => { 69 ast::AssocItem::Fn(f) => {
70 if let Some(n) = f.name() { 70 if let Some(n) = f.name() {
71 impl_fns_consts.insert(n.syntax().to_string()); 71 impl_fns_consts.insert(n.syntax().to_string());
72 } 72 }
73 } 73 }
74 74
75 ast::AssocItem::TypeAliasDef(t) => { 75 ast::AssocItem::TypeAlias(t) => {
76 if let Some(n) = t.name() { 76 if let Some(n) = t.name() {
77 impl_type.insert(n.syntax().to_string()); 77 impl_type.insert(n.syntax().to_string());
78 } 78 }
79 } 79 }
80 80
81 ast::AssocItem::ConstDef(c) => { 81 ast::AssocItem::Const(c) => {
82 if let Some(n) = c.name() { 82 if let Some(n) = c.name() {
83 impl_fns_consts.insert(n.syntax().to_string()); 83 impl_fns_consts.insert(n.syntax().to_string());
84 } 84 }
@@ -109,7 +109,7 @@ pub fn get_missing_assoc_items(
109 109
110pub(crate) fn resolve_target_trait( 110pub(crate) fn resolve_target_trait(
111 sema: &Semantics<RootDatabase>, 111 sema: &Semantics<RootDatabase>,
112 impl_def: &ast::ImplDef, 112 impl_def: &ast::Impl,
113) -> Option<hir::Trait> { 113) -> Option<hir::Trait> {
114 let ast_path = impl_def 114 let ast_path = impl_def
115 .target_trait() 115 .target_trait()