aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--crates/ra_assists/Cargo.toml1
-rw-r--r--crates/ra_assists/src/ast_transform.rs21
-rw-r--r--crates/ra_hir/src/code_model.rs7
4 files changed, 16 insertions, 14 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b28c6d98b..3a34978b1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -936,7 +936,6 @@ dependencies = [
936 "ra_db", 936 "ra_db",
937 "ra_fmt", 937 "ra_fmt",
938 "ra_hir", 938 "ra_hir",
939 "ra_hir_def",
940 "ra_ide_db", 939 "ra_ide_db",
941 "ra_prof", 940 "ra_prof",
942 "ra_syntax", 941 "ra_syntax",
diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml
index 488ab7bc8..3bcf58ba4 100644
--- a/crates/ra_assists/Cargo.toml
+++ b/crates/ra_assists/Cargo.toml
@@ -21,5 +21,4 @@ ra_prof = { path = "../ra_prof" }
21ra_db = { path = "../ra_db" } 21ra_db = { path = "../ra_db" }
22ra_ide_db = { path = "../ra_ide_db" } 22ra_ide_db = { path = "../ra_ide_db" }
23hir = { path = "../ra_hir", package = "ra_hir" } 23hir = { path = "../ra_hir", package = "ra_hir" }
24hir_def = { path = "../ra_hir_def", package = "ra_hir_def" }
25test_utils = { path = "../test_utils" } 24test_utils = { path = "../test_utils" }
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 {
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 3c56f39c1..3936f5aaa 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -990,9 +990,10 @@ impl TypeParam {
990 } 990 }
991 } 991 }
992 992
993 pub fn default(self, db: &dyn HirDatabase) -> Option<TypeRef> { 993 pub fn default(self, db: &dyn HirDatabase) -> Option<Ty> {
994 let params = db.generic_params(self.id.parent); 994 let params = db.generic_defaults(self.id.parent);
995 params.types[self.id.local_id].default.clone() 995 let local_idx: u32 = self.id.local_id.into_raw().into();
996 params.get(local_idx as usize).map(|d| d.clone())
996 } 997 }
997} 998}
998 999