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_ty/src/infer | |
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_ty/src/infer')
-rw-r--r-- | crates/hir_ty/src/infer/unify.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 75250a369..6e7b0f5a6 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs | |||
@@ -157,6 +157,10 @@ impl<T> Canonicalized<T> { | |||
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | pub fn could_unify(t1: &Ty, t2: &Ty) -> bool { | ||
161 | InferenceTable::new().unify(t1, t2) | ||
162 | } | ||
163 | |||
160 | pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substitution> { | 164 | pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substitution> { |
161 | let mut table = InferenceTable::new(); | 165 | let mut table = InferenceTable::new(); |
162 | let vars = Substitution( | 166 | let vars = Substitution( |