aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty')
-rw-r--r--crates/hir_ty/Cargo.toml2
-rw-r--r--crates/hir_ty/src/display.rs6
-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
-rw-r--r--crates/hir_ty/src/method_resolution.rs4
6 files changed, 15 insertions, 8 deletions
diff --git a/crates/hir_ty/Cargo.toml b/crates/hir_ty/Cargo.toml
index 0ef27cd37..030b7eebe 100644
--- a/crates/hir_ty/Cargo.toml
+++ b/crates/hir_ty/Cargo.toml
@@ -12,7 +12,7 @@ doctest = false
12[dependencies] 12[dependencies]
13cov-mark = { version = "1.1", features = ["thread-local"] } 13cov-mark = { version = "1.1", features = ["thread-local"] }
14itertools = "0.10.0" 14itertools = "0.10.0"
15arrayvec = "0.5.1" 15arrayvec = "0.6"
16smallvec = "1.2.0" 16smallvec = "1.2.0"
17ena = "0.14.0" 17ena = "0.14.0"
18log = "0.4.8" 18log = "0.4.8"
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index 6149067c7..51480304b 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -1,8 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use std::fmt; 3use std::{array, fmt};
4 4
5use arrayvec::ArrayVec;
6use chalk_ir::Mutability; 5use chalk_ir::Mutability;
7use hir_def::{ 6use hir_def::{
8 db::DefDatabase, 7 db::DefDatabase,
@@ -669,8 +668,7 @@ fn fn_traits(db: &dyn DefDatabase, trait_: TraitId) -> impl Iterator<Item = Trai
669 db.lang_item(krate, "fn_mut".into()), 668 db.lang_item(krate, "fn_mut".into()),
670 db.lang_item(krate, "fn_once".into()), 669 db.lang_item(krate, "fn_once".into()),
671 ]; 670 ];
672 // FIXME: Replace ArrayVec when into_iter is a thing on arrays 671 array::IntoIter::new(fn_traits).into_iter().flatten().flat_map(|it| it.as_trait())
673 ArrayVec::from(fn_traits).into_iter().flatten().flat_map(|it| it.as_trait())
674} 672}
675 673
676pub fn write_bounds_like_dyn_trait_with_prefix( 674pub fn write_bounds_like_dyn_trait_with_prefix(
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,
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs
index 84d9a1e18..bf7d5eded 100644
--- a/crates/hir_ty/src/method_resolution.rs
+++ b/crates/hir_ty/src/method_resolution.rs
@@ -228,12 +228,12 @@ impl Ty {
228 &self, 228 &self,
229 db: &dyn HirDatabase, 229 db: &dyn HirDatabase,
230 cur_crate: CrateId, 230 cur_crate: CrateId,
231 ) -> Option<ArrayVec<[CrateId; 2]>> { 231 ) -> Option<ArrayVec<CrateId, 2>> {
232 // Types like slice can have inherent impls in several crates, (core and alloc). 232 // Types like slice can have inherent impls in several crates, (core and alloc).
233 // The corresponding impls are marked with lang items, so we can use them to find the required crates. 233 // The corresponding impls are marked with lang items, so we can use them to find the required crates.
234 macro_rules! lang_item_crate { 234 macro_rules! lang_item_crate {
235 ($($name:expr),+ $(,)?) => {{ 235 ($($name:expr),+ $(,)?) => {{
236 let mut v = ArrayVec::<[LangItemTarget; 2]>::new(); 236 let mut v = ArrayVec::<LangItemTarget, 2>::new();
237 $( 237 $(
238 v.extend(db.lang_item(cur_crate, $name.into())); 238 v.extend(db.lang_item(cur_crate, $name.into()));
239 )+ 239 )+