diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-19 18:03:36 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-19 18:03:36 +0000 |
commit | 1c296d54e3dcc36c1a778873f26035000a352ba2 (patch) | |
tree | 0a6ce660ee32080287284c93bffaaaada91f3584 /crates/ra_ide_api/src | |
parent | bade91db081a3465dea3547ab8ab669f78fde9dc (diff) | |
parent | 5f3509e140d19b989db418a00ac6778c622cde5d (diff) |
Merge #576
576: Beginnings of generics r=matklad a=flodiebold
This implements the beginnings of the generics infrastructure; generic parameters for structs work and are correctly substituted in fields. Functions and methods aren't handled at all yet (as the tests show).
The name resolution in `ty` really needs refactoring now, I hope to do that next ;)
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 1 |
2 files changed, 5 insertions, 2 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 473edc50e..76c2f8173 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -24,7 +24,9 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { | |||
24 | fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { | 24 | fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { |
25 | for receiver in receiver.autoderef(ctx.db) { | 25 | for receiver in receiver.autoderef(ctx.db) { |
26 | match receiver { | 26 | match receiver { |
27 | Ty::Adt { def_id, .. } => { | 27 | Ty::Adt { |
28 | def_id, ref substs, .. | ||
29 | } => { | ||
28 | match def_id.resolve(ctx.db) { | 30 | match def_id.resolve(ctx.db) { |
29 | Def::Struct(s) => { | 31 | Def::Struct(s) => { |
30 | for field in s.fields(ctx.db) { | 32 | for field in s.fields(ctx.db) { |
@@ -33,7 +35,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) | |||
33 | field.name().to_string(), | 35 | field.name().to_string(), |
34 | ) | 36 | ) |
35 | .kind(CompletionItemKind::Field) | 37 | .kind(CompletionItemKind::Field) |
36 | .set_detail(field.ty(ctx.db).map(|ty| ty.to_string())) | 38 | .set_detail(field.ty(ctx.db).map(|ty| ty.subst(substs).to_string())) |
37 | .add_to(acc); | 39 | .add_to(acc); |
38 | } | 40 | } |
39 | } | 41 | } |
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index c2978f909..a1b666899 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -129,6 +129,7 @@ salsa::database_storage! { | |||
129 | fn body_hir() for hir::db::BodyHirQuery; | 129 | fn body_hir() for hir::db::BodyHirQuery; |
130 | fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery; | 130 | fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery; |
131 | fn fn_signature() for hir::db::FnSignatureQuery; | 131 | fn fn_signature() for hir::db::FnSignatureQuery; |
132 | fn generic_params() for hir::db::GenericParamsQuery; | ||
132 | } | 133 | } |
133 | } | 134 | } |
134 | } | 135 | } |