diff options
Diffstat (limited to 'crates/ra_assists')
13 files changed, 46 insertions, 45 deletions
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 5ea4f9f5b..28f3f3546 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs | |||
@@ -32,7 +32,7 @@ impl<'a> AstTransform<'a> for NullTransformer { | |||
32 | 32 | ||
33 | pub struct SubstituteTypeParams<'a> { | 33 | pub struct SubstituteTypeParams<'a> { |
34 | source_scope: &'a SemanticsScope<'a>, | 34 | source_scope: &'a SemanticsScope<'a>, |
35 | substs: FxHashMap<hir::TypeParam, ast::TypeRef>, | 35 | substs: FxHashMap<hir::TypeParam, ast::Type>, |
36 | previous: Box<dyn AstTransform<'a> + 'a>, | 36 | previous: Box<dyn AstTransform<'a> + 'a>, |
37 | } | 37 | } |
38 | 38 | ||
@@ -79,19 +79,25 @@ impl<'a> SubstituteTypeParams<'a> { | |||
79 | }; | 79 | }; |
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::Impl) -> Option<Vec<ast::TypeRef>> { | 83 | fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::Type>> { |
84 | let target_trait = impl_def.target_trait()?; | 84 | let target_trait = impl_def.trait_()?; |
85 | let path_type = match target_trait { | 85 | let path_type = match target_trait { |
86 | ast::TypeRef::PathType(path) => path, | 86 | ast::Type::PathType(path) => path, |
87 | _ => return None, | 87 | _ => return None, |
88 | }; | 88 | }; |
89 | let type_arg_list = path_type.path()?.segment()?.type_arg_list()?; | 89 | let generic_arg_list = path_type.path()?.segment()?.generic_arg_list()?; |
90 | |||
90 | let mut result = Vec::new(); | 91 | let mut result = Vec::new(); |
91 | for type_arg in type_arg_list.type_args() { | 92 | for generic_arg in generic_arg_list.generic_args() { |
92 | let type_arg: ast::TypeArg = type_arg; | 93 | match generic_arg { |
93 | result.push(type_arg.type_ref()?); | 94 | ast::GenericArg::TypeArg(type_arg) => result.push(type_arg.ty()?), |
95 | ast::GenericArg::AssocTypeArg(_) | ||
96 | | ast::GenericArg::LifetimeArg(_) | ||
97 | | ast::GenericArg::ConstArg(_) => (), | ||
98 | } | ||
94 | } | 99 | } |
100 | |||
95 | Some(result) | 101 | Some(result) |
96 | } | 102 | } |
97 | } | 103 | } |
@@ -99,9 +105,9 @@ impl<'a> SubstituteTypeParams<'a> { | |||
99 | &self, | 105 | &self, |
100 | node: &ra_syntax::SyntaxNode, | 106 | node: &ra_syntax::SyntaxNode, |
101 | ) -> Option<ra_syntax::SyntaxNode> { | 107 | ) -> Option<ra_syntax::SyntaxNode> { |
102 | let type_ref = ast::TypeRef::cast(node.clone())?; | 108 | let type_ref = ast::Type::cast(node.clone())?; |
103 | let path = match &type_ref { | 109 | let path = match &type_ref { |
104 | ast::TypeRef::PathType(path_type) => path_type.path()?, | 110 | ast::Type::PathType(path_type) => path_type.path()?, |
105 | _ => return None, | 111 | _ => return None, |
106 | }; | 112 | }; |
107 | // FIXME: use `hir::Path::from_src` instead. | 113 | // FIXME: use `hir::Path::from_src` instead. |
@@ -157,7 +163,7 @@ impl<'a> QualifyPaths<'a> { | |||
157 | 163 | ||
158 | let type_args = p | 164 | let type_args = p |
159 | .segment() | 165 | .segment() |
160 | .and_then(|s| s.type_arg_list()) | 166 | .and_then(|s| s.generic_arg_list()) |
161 | .map(|arg_list| apply(self, arg_list)); | 167 | .map(|arg_list| apply(self, arg_list)); |
162 | if let Some(type_args) = type_args { | 168 | if let Some(type_args) = type_args { |
163 | let last_segment = path.segment().unwrap(); | 169 | let last_segment = path.segment().unwrap(); |
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs index e69f0a89b..135a2ac9c 100644 --- a/crates/ra_assists/src/handlers/add_explicit_type.rs +++ b/crates/ra_assists/src/handlers/add_explicit_type.rs | |||
@@ -27,7 +27,7 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio | |||
27 | let expr = let_stmt.initializer()?; | 27 | let expr = let_stmt.initializer()?; |
28 | // Must be a binding | 28 | // Must be a binding |
29 | let pat = match let_stmt.pat()? { | 29 | let pat = match let_stmt.pat()? { |
30 | ast::Pat::BindPat(bind_pat) => bind_pat, | 30 | ast::Pat::IdentPat(bind_pat) => bind_pat, |
31 | _ => return None, | 31 | _ => return None, |
32 | }; | 32 | }; |
33 | let pat_range = pat.syntax().text_range(); | 33 | let pat_range = pat.syntax().text_range(); |
@@ -46,7 +46,7 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio | |||
46 | // and it has no placeholders | 46 | // and it has no placeholders |
47 | let ascribed_ty = let_stmt.ty(); | 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::InferType::cast).is_none() { |
50 | return None; | 50 | return None; |
51 | } | 51 | } |
52 | } | 52 | } |
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 167e162d8..b83c94404 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 | |||
@@ -74,6 +74,7 @@ impl TailReturnCollector { | |||
74 | let expr = match &stmt { | 74 | let expr = match &stmt { |
75 | ast::Stmt::ExprStmt(stmt) => stmt.expr(), | 75 | ast::Stmt::ExprStmt(stmt) => stmt.expr(), |
76 | ast::Stmt::LetStmt(stmt) => stmt.initializer(), | 76 | ast::Stmt::LetStmt(stmt) => stmt.initializer(), |
77 | ast::Stmt::Item(_) => continue, | ||
77 | }; | 78 | }; |
78 | if let Some(expr) = &expr { | 79 | if let Some(expr) = &expr { |
79 | self.handle_exprs(expr, collect_break); | 80 | self.handle_exprs(expr, collect_break); |
@@ -94,6 +95,7 @@ impl TailReturnCollector { | |||
94 | let expr_stmt = match &expr_stmt { | 95 | let expr_stmt = match &expr_stmt { |
95 | ast::Stmt::ExprStmt(stmt) => stmt.expr(), | 96 | ast::Stmt::ExprStmt(stmt) => stmt.expr(), |
96 | ast::Stmt::LetStmt(stmt) => stmt.initializer(), | 97 | ast::Stmt::LetStmt(stmt) => stmt.initializer(), |
98 | ast::Stmt::Item(_) => None, | ||
97 | }; | 99 | }; |
98 | if let Some(expr) = &expr_stmt { | 100 | if let Some(expr) = &expr_stmt { |
99 | self.handle_exprs(expr, collect_break); | 101 | self.handle_exprs(expr, collect_break); |
@@ -239,7 +241,6 @@ fn get_tail_expr_from_block(expr: &Expr) -> Option<Vec<NodeType>> { | |||
239 | Expr::ArrayExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 241 | Expr::ArrayExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
240 | Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 242 | Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
241 | Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 243 | Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
242 | Expr::Label(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | ||
243 | Expr::RecordExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 244 | Expr::RecordExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
244 | Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 245 | Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
245 | Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 246 | Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
diff --git a/crates/ra_assists/src/handlers/early_return.rs b/crates/ra_assists/src/handlers/early_return.rs index 3650289fd..69852b611 100644 --- a/crates/ra_assists/src/handlers/early_return.rs +++ b/crates/ra_assists/src/handlers/early_return.rs | |||
@@ -51,11 +51,11 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext) | |||
51 | // Check if there is an IfLet that we can handle. | 51 | // Check if there is an IfLet that we can handle. |
52 | let if_let_pat = match cond.pat() { | 52 | let if_let_pat = match cond.pat() { |
53 | None => None, // No IfLet, supported. | 53 | None => None, // No IfLet, supported. |
54 | Some(ast::Pat::TupleStructPat(pat)) if pat.args().count() == 1 => { | 54 | Some(ast::Pat::TupleStructPat(pat)) if pat.fields().count() == 1 => { |
55 | let path = pat.path()?; | 55 | let path = pat.path()?; |
56 | match path.qualifier() { | 56 | match path.qualifier() { |
57 | None => { | 57 | None => { |
58 | let bound_ident = pat.args().next().unwrap(); | 58 | let bound_ident = pat.fields().next().unwrap(); |
59 | Some((path, bound_ident)) | 59 | Some((path, bound_ident)) |
60 | } | 60 | } |
61 | Some(_) => return None, | 61 | Some(_) => return None, |
diff --git a/crates/ra_assists/src/handlers/extract_variable.rs b/crates/ra_assists/src/handlers/extract_variable.rs index b925a2884..cc62db0c4 100644 --- a/crates/ra_assists/src/handlers/extract_variable.rs +++ b/crates/ra_assists/src/handlers/extract_variable.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode}, | 2 | ast::{self, AstNode}, |
3 | SyntaxKind::{ | 3 | SyntaxKind::{ |
4 | BLOCK_EXPR, BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, | 4 | BLOCK_EXPR, BREAK_EXPR, CLOSURE_EXPR, COMMENT, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, |
5 | }, | 5 | }, |
6 | SyntaxNode, | 6 | SyntaxNode, |
7 | }; | 7 | }; |
@@ -148,7 +148,7 @@ impl Anchor { | |||
148 | } | 148 | } |
149 | 149 | ||
150 | if let Some(parent) = node.parent() { | 150 | if let Some(parent) = node.parent() { |
151 | if parent.kind() == MATCH_ARM || parent.kind() == LAMBDA_EXPR { | 151 | if parent.kind() == MATCH_ARM || parent.kind() == CLOSURE_EXPR { |
152 | return Some(Anchor::WrapInBlock(node)); | 152 | return Some(Anchor::WrapInBlock(node)); |
153 | } | 153 | } |
154 | } | 154 | } |
diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs index 708e1bc6c..b2e14f9d7 100644 --- a/crates/ra_assists/src/handlers/fill_match_arms.rs +++ b/crates/ra_assists/src/handlers/fill_match_arms.rs | |||
@@ -43,7 +43,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option< | |||
43 | 43 | ||
44 | let mut arms: Vec<MatchArm> = match_arm_list.arms().collect(); | 44 | let mut arms: Vec<MatchArm> = match_arm_list.arms().collect(); |
45 | if arms.len() == 1 { | 45 | if arms.len() == 1 { |
46 | if let Some(Pat::PlaceholderPat(..)) = arms[0].pat() { | 46 | if let Some(Pat::WildcardPat(..)) = arms[0].pat() { |
47 | arms.clear(); | 47 | arms.clear(); |
48 | } | 48 | } |
49 | } | 49 | } |
@@ -116,17 +116,15 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option< | |||
116 | match (first_new_arm, ctx.config.snippet_cap) { | 116 | match (first_new_arm, ctx.config.snippet_cap) { |
117 | (Some(first_new_arm), Some(cap)) => { | 117 | (Some(first_new_arm), Some(cap)) => { |
118 | let extend_lifetime; | 118 | let extend_lifetime; |
119 | let cursor = match first_new_arm | 119 | let cursor = |
120 | .syntax() | 120 | match first_new_arm.syntax().descendants().find_map(ast::WildcardPat::cast) |
121 | .descendants() | 121 | { |
122 | .find_map(ast::PlaceholderPat::cast) | 122 | Some(it) => { |
123 | { | 123 | extend_lifetime = it.syntax().clone(); |
124 | Some(it) => { | 124 | Cursor::Replace(&extend_lifetime) |
125 | extend_lifetime = it.syntax().clone(); | 125 | } |
126 | Cursor::Replace(&extend_lifetime) | 126 | None => Cursor::Before(first_new_arm.syntax()), |
127 | } | 127 | }; |
128 | None => Cursor::Before(first_new_arm.syntax()), | ||
129 | }; | ||
130 | let snippet = render_snippet(cap, new_arm_list.syntax(), cursor); | 128 | let snippet = render_snippet(cap, new_arm_list.syntax(), cursor); |
131 | builder.replace_snippet(cap, old_range, snippet); | 129 | builder.replace_snippet(cap, old_range, snippet); |
132 | } | 130 | } |
@@ -152,7 +150,7 @@ fn does_pat_match_variant(pat: &Pat, var: &Pat) -> bool { | |||
152 | let first_node_text = |pat: &Pat| pat.syntax().first_child().map(|node| node.text()); | 150 | let first_node_text = |pat: &Pat| pat.syntax().first_child().map(|node| node.text()); |
153 | 151 | ||
154 | let pat_head = match pat { | 152 | let pat_head = match pat { |
155 | Pat::BindPat(bind_pat) => { | 153 | Pat::IdentPat(bind_pat) => { |
156 | if let Some(p) = bind_pat.pat() { | 154 | if let Some(p) = bind_pat.pat() { |
157 | first_node_text(&p) | 155 | first_node_text(&p) |
158 | } else { | 156 | } else { |
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 9da23640a..4c1aef8a2 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 | |||
@@ -34,7 +34,7 @@ pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext | |||
34 | } | 34 | } |
35 | let field_type = field_list.fields().next()?.ty()?; | 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::Type::PathType(it) => it, |
38 | _ => return None, | 38 | _ => return None, |
39 | }; | 39 | }; |
40 | 40 | ||
diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs index 2fdfabaf5..3c58020f8 100644 --- a/crates/ra_assists/src/handlers/inline_local_variable.rs +++ b/crates/ra_assists/src/handlers/inline_local_variable.rs | |||
@@ -29,7 +29,7 @@ use crate::{ | |||
29 | pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 29 | pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
30 | let let_stmt = ctx.find_node_at_offset::<ast::LetStmt>()?; | 30 | let let_stmt = ctx.find_node_at_offset::<ast::LetStmt>()?; |
31 | let bind_pat = match let_stmt.pat()? { | 31 | let bind_pat = match let_stmt.pat()? { |
32 | ast::Pat::BindPat(pat) => pat, | 32 | ast::Pat::IdentPat(pat) => pat, |
33 | _ => return None, | 33 | _ => return None, |
34 | }; | 34 | }; |
35 | if bind_pat.mut_token().is_some() { | 35 | if bind_pat.mut_token().is_some() { |
diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs index c3134f64d..fbaf3c06b 100644 --- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs +++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs | |||
@@ -68,7 +68,7 @@ fn generate_fn_def_assist( | |||
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.ty() { | 70 | .filter_map(|param| match param.ty() { |
71 | Some(ast::TypeRef::ReferenceType(ascribed_type)) | 71 | Some(ast::Type::RefType(ascribed_type)) |
72 | if ascribed_type.lifetime_token() == None => | 72 | if ascribed_type.lifetime_token() == None => |
73 | { | 73 | { |
74 | Some(ascribed_type.amp_token()?.text_range().end()) | 74 | Some(ascribed_type.amp_token()?.text_range().end()) |
diff --git a/crates/ra_assists/src/handlers/merge_match_arms.rs b/crates/ra_assists/src/handlers/merge_match_arms.rs index 186a1f618..563292282 100644 --- a/crates/ra_assists/src/handlers/merge_match_arms.rs +++ b/crates/ra_assists/src/handlers/merge_match_arms.rs | |||
@@ -86,7 +86,7 @@ pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option | |||
86 | } | 86 | } |
87 | 87 | ||
88 | fn contains_placeholder(a: &ast::MatchArm) -> bool { | 88 | fn contains_placeholder(a: &ast::MatchArm) -> bool { |
89 | matches!(a.pat(), Some(ast::Pat::PlaceholderPat(..))) | 89 | matches!(a.pat(), Some(ast::Pat::WildcardPat(..))) |
90 | } | 90 | } |
91 | 91 | ||
92 | #[cfg(test)] | 92 | #[cfg(test)] |
diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/ra_assists/src/handlers/reorder_fields.rs index 120250e79..c9b743a06 100644 --- a/crates/ra_assists/src/handlers/reorder_fields.rs +++ b/crates/ra_assists/src/handlers/reorder_fields.rs | |||
@@ -57,7 +57,7 @@ fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
57 | fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> { | 57 | fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> { |
58 | match node.kind() { | 58 | match node.kind() { |
59 | RECORD_EXPR => vec![RECORD_EXPR_FIELD], | 59 | RECORD_EXPR => vec![RECORD_EXPR_FIELD], |
60 | RECORD_PAT => vec![RECORD_FIELD_PAT, BIND_PAT], | 60 | RECORD_PAT => vec![RECORD_PAT_FIELD, IDENT_PAT], |
61 | _ => vec![], | 61 | _ => vec![], |
62 | } | 62 | } |
63 | } | 63 | } |
@@ -66,7 +66,7 @@ fn get_field_name(node: &SyntaxNode) -> String { | |||
66 | let res = match_ast! { | 66 | let res = match_ast! { |
67 | match node { | 67 | match node { |
68 | ast::RecordExprField(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::RecordPatField(field) => field.field_name().map(|it| it.to_string()), |
70 | _ => None, | 70 | _ => None, |
71 | } | 71 | } |
72 | }; | 72 | }; |
diff --git a/crates/ra_assists/src/handlers/replace_let_with_if_let.rs b/crates/ra_assists/src/handlers/replace_let_with_if_let.rs index a49292c97..64ad15a23 100644 --- a/crates/ra_assists/src/handlers/replace_let_with_if_let.rs +++ b/crates/ra_assists/src/handlers/replace_let_with_if_let.rs | |||
@@ -62,8 +62,7 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext) -> | |||
62 | let if_ = make::expr_if(make::condition(init, Some(with_placeholder)), block); | 62 | let if_ = make::expr_if(make::condition(init, Some(with_placeholder)), block); |
63 | let stmt = make::expr_stmt(if_); | 63 | let stmt = make::expr_stmt(if_); |
64 | 64 | ||
65 | let placeholder = | 65 | let placeholder = stmt.syntax().descendants().find_map(ast::WildcardPat::cast).unwrap(); |
66 | stmt.syntax().descendants().find_map(ast::PlaceholderPat::cast).unwrap(); | ||
67 | let stmt = stmt.replace_descendant(placeholder.into(), original_pat); | 66 | let stmt = stmt.replace_descendant(placeholder.into(), original_pat); |
68 | 67 | ||
69 | edit.replace_ast(ast::Stmt::from(let_stmt), ast::Stmt::from(stmt)); | 68 | edit.replace_ast(ast::Stmt::from(let_stmt), ast::Stmt::from(stmt)); |
diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index bb16ebd4e..373de273c 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs | |||
@@ -111,11 +111,8 @@ pub(crate) fn resolve_target_trait( | |||
111 | sema: &Semantics<RootDatabase>, | 111 | sema: &Semantics<RootDatabase>, |
112 | impl_def: &ast::Impl, | 112 | impl_def: &ast::Impl, |
113 | ) -> Option<hir::Trait> { | 113 | ) -> Option<hir::Trait> { |
114 | let ast_path = impl_def | 114 | let ast_path = |
115 | .target_trait() | 115 | impl_def.trait_().map(|it| it.syntax().clone()).and_then(ast::PathType::cast)?.path()?; |
116 | .map(|it| it.syntax().clone()) | ||
117 | .and_then(ast::PathType::cast)? | ||
118 | .path()?; | ||
119 | 116 | ||
120 | match sema.resolve_path(&ast_path) { | 117 | match sema.resolve_path(&ast_path) { |
121 | Some(hir::PathResolution::Def(hir::ModuleDef::Trait(def))) => Some(def), | 118 | Some(hir::PathResolution::Def(hir::ModuleDef::Trait(def))) => Some(def), |