1
Fork 0

Rollup merge of #93996 - notriddle:notriddle/magically-becomes-a-function, r=petrochenkov

Do not suggest "is a function" for free variables

Part of #82323
This commit is contained in:
Matthias Krüger 2022-02-17 06:30:01 +01:00 committed by GitHub
commit 3e727054ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 106 additions and 0 deletions

View file

@ -42,7 +42,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Err(..) => return false,
};
// This conditional prevents us from asking to call errors and unresolved types.
// It might seem that we can use `predicate_must_hold_modulo_regions`,
// but since a Dummy binder is used to fill in the FnOnce trait's arguments,
// type resolution always gives a "maybe" here.
if self.autoderef(span, ty).any(|(ty, _)| {
info!("check deref {:?} error", ty);
matches!(ty.kind(), ty::Error(_) | ty::Infer(_))
}) {
return false;
}
self.autoderef(span, ty).any(|(ty, _)| {
info!("check deref {:?} impl FnOnce", ty);
self.probe(|_| {
let fn_once_substs = tcx.mk_substs_trait(
ty,