Fix case where non FnOnce variables is marked callable

This commit is contained in:
GrayJack 2020-10-26 15:20:33 -03:00
parent d01e412eb1
commit 08e95a5dc1
No known key found for this signature in database
GPG key ID: 12C54E04AAB9931E
2 changed files with 14 additions and 1 deletions

View file

@ -1398,7 +1398,7 @@ impl Type {
};
let canonical_ty = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) };
method_resolution::implements_trait(
method_resolution::implements_trait_unique(
&canonical_ty,
db,
self.ty.environment.clone(),

View file

@ -740,6 +740,19 @@ pub fn implements_trait(
solution.is_some()
}
pub fn implements_trait_unique(
ty: &Canonical<Ty>,
db: &dyn HirDatabase,
env: Arc<TraitEnvironment>,
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(