diff options
| author | Michael Howell <michael@notriddle.com> | 2022-02-13 13:06:06 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2022-02-16 09:12:32 -0700 |
| commit | 65fc7058d88f28f6fa33970ef866b59e33f4255b (patch) | |
| tree | 1ea83f641e34e8ee3bc994aed4496bc164a2c044 /compiler | |
| parent | 05d165233794c48217e2e2bb6de8ee9763ea1084 (diff) | |
| download | rust-65fc7058d88f28f6fa33970ef866b59e33f4255b.tar.gz rust-65fc7058d88f28f6fa33970ef866b59e33f4255b.zip | |
Do not suggest "is a function" for free variables
Part of #82323
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_typeck/src/check/method/suggest.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index 8aa22852a6f..f2b228fa002 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -40,7 +40,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, |
