diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-20 08:47:42 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-20 08:47:42 +0000 |
commit | d24e8f9ea42dd2d08b2e02f8106690fd4baa8071 (patch) | |
tree | 3da030379556170d1d18235c234ae95bbe28fba4 /crates/ra_hir/src/generics.rs | |
parent | 4340d9b0e435bde11c0cc79e9f284856a836ccdc (diff) | |
parent | 0e771915faf057ec4561224b75ec9b5be93d71c8 (diff) |
Merge #2321
2321: Allow non-path default type parameters r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/generics.rs')
-rw-r--r-- | crates/ra_hir/src/generics.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs index 8925ba3a9..78fab1a13 100644 --- a/crates/ra_hir/src/generics.rs +++ b/crates/ra_hir/src/generics.rs | |||
@@ -5,12 +5,9 @@ | |||
5 | 5 | ||
6 | use std::sync::Arc; | 6 | use std::sync::Arc; |
7 | 7 | ||
8 | use hir_def::{ | 8 | use hir_def::type_ref::{TypeBound, TypeRef}; |
9 | path::Path, | ||
10 | type_ref::{TypeBound, TypeRef}, | ||
11 | }; | ||
12 | use hir_expand::name::{self, AsName}; | 9 | use hir_expand::name::{self, AsName}; |
13 | use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner}; | 10 | use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner}; |
14 | 11 | ||
15 | use crate::{ | 12 | use crate::{ |
16 | db::{AstDatabase, DefDatabase, HirDatabase}, | 13 | db::{AstDatabase, DefDatabase, HirDatabase}, |
@@ -24,7 +21,7 @@ pub struct GenericParam { | |||
24 | // FIXME: give generic params proper IDs | 21 | // FIXME: give generic params proper IDs |
25 | pub idx: u32, | 22 | pub idx: u32, |
26 | pub name: Name, | 23 | pub name: Name, |
27 | pub default: Option<Path>, | 24 | pub default: Option<TypeRef>, |
28 | } | 25 | } |
29 | 26 | ||
30 | /// Data about the generic parameters of a function, struct, impl, etc. | 27 | /// Data about the generic parameters of a function, struct, impl, etc. |
@@ -140,7 +137,7 @@ impl GenericParams { | |||
140 | for (idx, type_param) in params.type_params().enumerate() { | 137 | for (idx, type_param) in params.type_params().enumerate() { |
141 | let name = type_param.name().map_or_else(Name::missing, |it| it.as_name()); | 138 | let name = type_param.name().map_or_else(Name::missing, |it| it.as_name()); |
142 | // FIXME: Use `Path::from_src` | 139 | // FIXME: Use `Path::from_src` |
143 | let default = type_param.default_type().and_then(|t| t.path()).and_then(Path::from_ast); | 140 | let default = type_param.default_type().map(TypeRef::from_ast); |
144 | 141 | ||
145 | let param = GenericParam { idx: idx as u32 + start, name: name.clone(), default }; | 142 | let param = GenericParam { idx: idx as u32 + start, name: name.clone(), default }; |
146 | self.params.push(param); | 143 | self.params.push(param); |