aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
authorJosh Mcguigan <[email protected]>2021-03-16 15:45:46 +0000
committerJosh Mcguigan <[email protected]>2021-03-26 16:11:50 +0000
commit957939292ec9038f139bd10e093e9673609eea04 (patch)
tree5babed3a488b43ea561874be3bda36198ccb421b /crates/hir_ty
parent20e32fc946010f8c46728d6cb8bab1b96b3f48b9 (diff)
completion relevance consider if types can be unified
Diffstat (limited to 'crates/hir_ty')
-rw-r--r--crates/hir_ty/src/infer.rs5
-rw-r--r--crates/hir_ty/src/infer/unify.rs4
-rw-r--r--crates/hir_ty/src/lib.rs2
3 files changed, 10 insertions, 1 deletions
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs
index 8f9cf7480..e4407ff50 100644
--- a/crates/hir_ty/src/infer.rs
+++ b/crates/hir_ty/src/infer.rs
@@ -45,6 +45,11 @@ use crate::{
45 to_assoc_type_id, to_chalk_trait_id, AliasEq, AliasTy, Interner, TyKind, 45 to_assoc_type_id, to_chalk_trait_id, AliasEq, AliasTy, Interner, TyKind,
46}; 46};
47 47
48// This lint has a false positive here. See the link below for details.
49//
50// https://github.com/rust-lang/rust/issues/57411
51#[allow(unreachable_pub)]
52pub use unify::could_unify;
48pub(crate) use unify::unify; 53pub(crate) use unify::unify;
49 54
50mod unify; 55mod unify;
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
160pub fn could_unify(t1: &Ty, t2: &Ty) -> bool {
161 InferenceTable::new().unify(t1, t2)
162}
163
160pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substitution> { 164pub(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(
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 69265286f..6f9c698e6 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -41,7 +41,7 @@ use crate::{
41}; 41};
42 42
43pub use autoderef::autoderef; 43pub use autoderef::autoderef;
44pub use infer::{InferenceResult, InferenceVar}; 44pub use infer::{could_unify, InferenceResult, InferenceVar};
45pub use lower::{ 45pub use lower::{
46 associated_type_shorthand_candidates, callable_item_sig, CallableDefId, ImplTraitLoweringMode, 46 associated_type_shorthand_candidates, callable_item_sig, CallableDefId, ImplTraitLoweringMode,
47 TyDefId, TyLoweringContext, ValueTyDefId, 47 TyDefId, TyLoweringContext, ValueTyDefId,