diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-13 12:05:02 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-13 12:05:02 +0000 |
commit | 93527b5f193ed214f6ae0f8112eaec2eebabd016 (patch) | |
tree | fda6b0e03da9ef7fc7426dbf785bd6c050e845dd /crates/ra_ide/src/display | |
parent | 02b44006b8e37a8cd3f96d5b1c949d62e01be2e8 (diff) | |
parent | d6195fa21f09aa3f987e09d847c156e1788ec834 (diff) |
Merge #3574
3574: Fix completion of HashMap::new r=matklad a=flodiebold
The `ty` function in code_model returned the type with placeholders for type parameters. That's nice for printing, but not good for completion, because placeholders won't unify with anything else: So the type we got for `HashMap` was `HashMap<K, V, T>`, which doesn't unify with `HashMap<?, ?, RandomState>`, so the `new` method wasn't shown.
Now we instead return `HashMap<{unknown}, {unknown}, {unknown}>`, which does unify with the impl type. Maybe we should just expose this properly as variables though, i.e. we'd return something like `exists<type, type, type> HashMap<?0, ?1, ?2>` (in Chalk notation). It'll make the API more complicated, but harder to misuse. (And it would handle cases like `type TypeAlias<T> = HashMap<T, T>` more correctly.)
The `ty` function for fields was used for signature help, so there we want placeholders so that it looks nicer, I think. Hence I renamed it to `signature_ty`.
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/display')
-rw-r--r-- | crates/ra_ide/src/display/function_signature.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs index 2c4c932de..ec1bbd5a0 100644 --- a/crates/ra_ide/src/display/function_signature.rs +++ b/crates/ra_ide/src/display/function_signature.rs | |||
@@ -64,7 +64,7 @@ impl FunctionSignature { | |||
64 | .fields(db) | 64 | .fields(db) |
65 | .into_iter() | 65 | .into_iter() |
66 | .map(|field: hir::StructField| { | 66 | .map(|field: hir::StructField| { |
67 | let ty = field.ty(db); | 67 | let ty = field.signature_ty(db); |
68 | format!("{}", ty.display(db)) | 68 | format!("{}", ty.display(db)) |
69 | }) | 69 | }) |
70 | .collect(); | 70 | .collect(); |
@@ -102,7 +102,7 @@ impl FunctionSignature { | |||
102 | .into_iter() | 102 | .into_iter() |
103 | .map(|field: hir::StructField| { | 103 | .map(|field: hir::StructField| { |
104 | let name = field.name(db); | 104 | let name = field.name(db); |
105 | let ty = field.ty(db); | 105 | let ty = field.signature_ty(db); |
106 | format!("{}: {}", name, ty.display(db)) | 106 | format!("{}: {}", name, ty.display(db)) |
107 | }) | 107 | }) |
108 | .collect(); | 108 | .collect(); |