diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-26 16:29:20 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-26 16:29:20 +0000 |
commit | 4ecaad98e074c42dbf637a11afcb630aafffd7b3 (patch) | |
tree | 50832b85e65752b040affcc8d34dc5cd8c2625b9 /crates/hir/src/lib.rs | |
parent | 20e32fc946010f8c46728d6cb8bab1b96b3f48b9 (diff) | |
parent | 0e31ae2cef92f973a6ee3def3f1feaa94dcb7a4f (diff) |
Merge #8056
8056: completion relevance consider if types can be unified r=JoshMcguigan a=JoshMcguigan
This PR improves completion relevance scoring for generic types, in cases where the types could unify.
### Before
![pre-could-unify](https://user-images.githubusercontent.com/22216761/111338556-46d94e80-8634-11eb-9936-2b20eb9e6756.png)
### After
![post-could-unify](https://user-images.githubusercontent.com/22216761/111338598-4e005c80-8634-11eb-92e0-69c2c1cda6fc.png)
changelog feature improve completions
Co-authored-by: Josh Mcguigan <[email protected]>
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r-- | crates/hir/src/lib.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 05a60e158..4ee08ef21 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -51,7 +51,7 @@ use hir_def::{ | |||
51 | }; | 51 | }; |
52 | use hir_expand::{diagnostics::DiagnosticSink, name::name, MacroDefKind}; | 52 | use hir_expand::{diagnostics::DiagnosticSink, name::name, MacroDefKind}; |
53 | use hir_ty::{ | 53 | use hir_ty::{ |
54 | autoderef, | 54 | autoderef, could_unify, |
55 | method_resolution::{self, TyFingerprint}, | 55 | method_resolution::{self, TyFingerprint}, |
56 | primitive::UintTy, | 56 | primitive::UintTy, |
57 | to_assoc_type_id, | 57 | to_assoc_type_id, |
@@ -2154,6 +2154,10 @@ impl Type { | |||
2154 | 2154 | ||
2155 | walk_type(db, self, &mut cb); | 2155 | walk_type(db, self, &mut cb); |
2156 | } | 2156 | } |
2157 | |||
2158 | pub fn could_unify_with(&self, other: &Type) -> bool { | ||
2159 | could_unify(&self.ty, &other.ty) | ||
2160 | } | ||
2157 | } | 2161 | } |
2158 | 2162 | ||
2159 | // FIXME: closures | 2163 | // FIXME: closures |