diff options
Diffstat (limited to 'crates/ra_assists/src/assists/add_missing_impl_members.rs')
-rw-r--r-- | crates/ra_assists/src/assists/add_missing_impl_members.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_assists/src/assists/add_missing_impl_members.rs b/crates/ra_assists/src/assists/add_missing_impl_members.rs index 22f1157cc..942b34dc1 100644 --- a/crates/ra_assists/src/assists/add_missing_impl_members.rs +++ b/crates/ra_assists/src/assists/add_missing_impl_members.rs | |||
@@ -207,25 +207,23 @@ fn get_syntactic_substs(impl_block: ast::ImplBlock) -> Option<Vec<ast::TypeRef>> | |||
207 | } | 207 | } |
208 | 208 | ||
209 | // FIXME: This should be a general utility (not even just for assists) | 209 | // FIXME: This should be a general utility (not even just for assists) |
210 | fn substitute_type_params<N: AstNode>( | 210 | fn substitute_type_params<N: AstNode + Clone>( |
211 | db: &impl HirDatabase, | 211 | db: &impl HirDatabase, |
212 | node: hir::InFile<N>, | 212 | node: hir::InFile<N>, |
213 | substs: &HashMap<hir::TypeParam, ast::TypeRef>, | 213 | substs: &HashMap<hir::TypeParam, ast::TypeRef>, |
214 | ) -> N { | 214 | ) -> N { |
215 | let type_param_replacements = node | 215 | let type_param_replacements = node |
216 | .value | 216 | .clone() |
217 | .syntax() | 217 | .descendants::<ast::TypeRef>() |
218 | .descendants() | ||
219 | .filter_map(ast::TypeRef::cast) | ||
220 | .filter_map(|n| { | 218 | .filter_map(|n| { |
221 | let path = match &n { | 219 | let path = match &n.value { |
222 | ast::TypeRef::PathType(path_type) => path_type.path()?, | 220 | ast::TypeRef::PathType(path_type) => path_type.path()?, |
223 | _ => return None, | 221 | _ => return None, |
224 | }; | 222 | }; |
225 | let analyzer = hir::SourceAnalyzer::new(db, node.with_value(n.syntax()), None); | 223 | let analyzer = hir::SourceAnalyzer::new(db, n.syntax(), None); |
226 | let resolution = analyzer.resolve_path(db, &path)?; | 224 | let resolution = analyzer.resolve_path(db, &path)?; |
227 | match resolution { | 225 | match resolution { |
228 | hir::PathResolution::TypeParam(tp) => Some((n, substs.get(&tp)?.clone())), | 226 | hir::PathResolution::TypeParam(tp) => Some((n.value, substs.get(&tp)?.clone())), |
229 | _ => None, | 227 | _ => None, |
230 | } | 228 | } |
231 | }) | 229 | }) |