diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir/src/code_model.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 63c1a8ebf..563145f92 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs | |||
@@ -1398,7 +1398,7 @@ impl Type { | |||
1398 | }; | 1398 | }; |
1399 | 1399 | ||
1400 | let canonical_ty = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) }; | 1400 | let canonical_ty = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) }; |
1401 | method_resolution::implements_trait( | 1401 | method_resolution::implements_trait_unique( |
1402 | &canonical_ty, | 1402 | &canonical_ty, |
1403 | db, | 1403 | db, |
1404 | self.ty.environment.clone(), | 1404 | self.ty.environment.clone(), |
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 8961df404..5a6f0c67f 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -740,6 +740,19 @@ pub fn implements_trait( | |||
740 | solution.is_some() | 740 | solution.is_some() |
741 | } | 741 | } |
742 | 742 | ||
743 | pub fn implements_trait_unique( | ||
744 | ty: &Canonical<Ty>, | ||
745 | db: &dyn HirDatabase, | ||
746 | env: Arc<TraitEnvironment>, | ||
747 | krate: CrateId, | ||
748 | trait_: TraitId, | ||
749 | ) -> bool { | ||
750 | let goal = generic_implements_goal(db, env, trait_, ty.clone()); | ||
751 | let solution = db.trait_solve(krate, goal); | ||
752 | |||
753 | matches!(solution, Some(crate::traits::Solution::Unique(_))) | ||
754 | } | ||
755 | |||
743 | /// This creates Substs for a trait with the given Self type and type variables | 756 | /// This creates Substs for a trait with the given Self type and type variables |
744 | /// for all other parameters, to query Chalk with it. | 757 | /// for all other parameters, to query Chalk with it. |
745 | fn generic_implements_goal( | 758 | fn generic_implements_goal( |