aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/ast_transform.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs
index d81218bc8..4001ca73c 100644
--- a/crates/ra_assists/src/ast_transform.rs
+++ b/crates/ra_assists/src/ast_transform.rs
@@ -1,8 +1,7 @@
1//! `AstTransformer`s are functions that replace nodes in an AST and can be easily combined. 1//! `AstTransformer`s are functions that replace nodes in an AST and can be easily combined.
2use rustc_hash::FxHashMap; 2use rustc_hash::FxHashMap;
3 3
4use hir::{PathResolution, SemanticsScope}; 4use hir::{HirDisplay, PathResolution, SemanticsScope};
5use hir_def::type_ref::TypeRef;
6use ra_ide_db::RootDatabase; 5use ra_ide_db::RootDatabase;
7use ra_syntax::{ 6use ra_syntax::{
8 algo::SyntaxRewriter, 7 algo::SyntaxRewriter,
@@ -61,14 +60,18 @@ impl<'a> SubstituteTypeParams<'a> {
61 .zip(substs.into_iter().map(Some).chain(std::iter::repeat(None))) 60 .zip(substs.into_iter().map(Some).chain(std::iter::repeat(None)))
62 .filter_map(|(k, v)| match v { 61 .filter_map(|(k, v)| match v {
63 Some(v) => Some((k, v)), 62 Some(v) => Some((k, v)),
64 None => match k.default(source_scope.db)? { 63 None => {
65 TypeRef::Path(path) => Some(( 64 let default = k.default(source_scope.db)?;
65 Some((
66 k, 66 k,
67 ast::make::type_arg(&format!("{}", path.mod_path().as_ident()?)) 67 ast::make::type_arg(
68 .type_ref()?, 68 &default
69 )), 69 .display_source_code(source_scope.db, source_scope.module()?.into())
70 _ => None, 70 .ok()?,
71 }, 71 )
72 .type_ref()?,
73 ))
74 }
72 }) 75 })
73 .collect(); 76 .collect();
74 return SubstituteTypeParams { 77 return SubstituteTypeParams {