Skip to content

Commit 08e95a5

Browse files
committed
Fix case where non FnOnce variables is marked callable
1 parent d01e412 commit 08e95a5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

crates/hir/src/code_model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ impl Type {
13981398
};
13991399

14001400
let canonical_ty = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) };
1401-
method_resolution::implements_trait(
1401+
method_resolution::implements_trait_unique(
14021402
&canonical_ty,
14031403
db,
14041404
self.ty.environment.clone(),

crates/hir_ty/src/method_resolution.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,19 @@ pub fn implements_trait(
740740
solution.is_some()
741741
}
742742

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+
743756
/// This creates Substs for a trait with the given Self type and type variables
744757
/// for all other parameters, to query Chalk with it.
745758
fn generic_implements_goal(

0 commit comments

Comments
 (0)