From 08e95a5dc1035c57f2cfe6f61f0d64280b940b10 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Mon, 26 Oct 2020 15:20:33 -0300 Subject: Fix case where non FnOnce variables is marked callable --- crates/hir_ty/src/method_resolution.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'crates/hir_ty') 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( solution.is_some() } +pub fn implements_trait_unique( + ty: &Canonical, + db: &dyn HirDatabase, + env: Arc, + krate: CrateId, + trait_: TraitId, +) -> bool { + let goal = generic_implements_goal(db, env, trait_, ty.clone()); + let solution = db.trait_solve(krate, goal); + + matches!(solution, Some(crate::traits::Solution::Unique(_))) +} + /// This creates Substs for a trait with the given Self type and type variables /// for all other parameters, to query Chalk with it. fn generic_implements_goal( -- cgit v1.2.3