From 12905e5b58f22df026ef30afa6f0bdf7319cbddd Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 5 Jan 2020 21:32:18 +0100 Subject: Some more refactoring --- crates/ra_assists/src/assists/add_missing_impl_members.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'crates/ra_assists/src/assists/add_missing_impl_members.rs') 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> } // FIXME: This should be a general utility (not even just for assists) -fn substitute_type_params( +fn substitute_type_params( db: &impl HirDatabase, node: hir::InFile, substs: &HashMap, ) -> N { let type_param_replacements = node - .value - .syntax() - .descendants() - .filter_map(ast::TypeRef::cast) + .clone() + .descendants::() .filter_map(|n| { - let path = match &n { + let path = match &n.value { ast::TypeRef::PathType(path_type) => path_type.path()?, _ => return None, }; - let analyzer = hir::SourceAnalyzer::new(db, node.with_value(n.syntax()), None); + let analyzer = hir::SourceAnalyzer::new(db, n.syntax(), None); let resolution = analyzer.resolve_path(db, &path)?; match resolution { - hir::PathResolution::TypeParam(tp) => Some((n, substs.get(&tp)?.clone())), + hir::PathResolution::TypeParam(tp) => Some((n.value, substs.get(&tp)?.clone())), _ => None, } }) -- cgit v1.2.3