diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_assists/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_assists/src/ast_transform.rs | 21 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 7 |
3 files changed, 16 insertions, 13 deletions
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" } | |||
21 | ra_db = { path = "../ra_db" } | 21 | ra_db = { path = "../ra_db" } |
22 | ra_ide_db = { path = "../ra_ide_db" } | 22 | ra_ide_db = { path = "../ra_ide_db" } |
23 | hir = { path = "../ra_hir", package = "ra_hir" } | 23 | hir = { path = "../ra_hir", package = "ra_hir" } |
24 | hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } | ||
25 | test_utils = { path = "../test_utils" } | 24 | test_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. |
2 | use rustc_hash::FxHashMap; | 2 | use rustc_hash::FxHashMap; |
3 | 3 | ||
4 | use hir::{PathResolution, SemanticsScope}; | 4 | use hir::{HirDisplay, PathResolution, SemanticsScope}; |
5 | use hir_def::type_ref::TypeRef; | ||
6 | use ra_ide_db::RootDatabase; | 5 | use ra_ide_db::RootDatabase; |
7 | use ra_syntax::{ | 6 | use 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 | ||