diff options
| author | Michael Goulet <michael@errs.io> | 2022-08-10 20:53:06 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-08-16 03:00:32 +0000 |
| commit | 5309375d2c8d51dafedb5404f0fb49f402350394 (patch) | |
| tree | 0cc5caf474d106828f82b5e2afdcff22316d6f5d /compiler/rustc_query_impl/src | |
| parent | 40336865fe7d4a01139a3336639c6971647e885c (diff) | |
Do not report cycle error when inferring return type for suggestion
Diffstat (limited to 'compiler/rustc_query_impl/src')
| -rw-r--r-- | compiler/rustc_query_impl/src/values.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_query_impl/src/values.rs b/compiler/rustc_query_impl/src/values.rs index 718a2971c40..0ed48f8d4a0 100644 --- a/compiler/rustc_query_impl/src/values.rs +++ b/compiler/rustc_query_impl/src/values.rs @@ -43,3 +43,23 @@ impl<'tcx> Value<'tcx> for AdtSizedConstraint<'_> { } } } + +impl<'tcx> Value<'tcx> for ty::Binder<'_, ty::FnSig<'_>> { + fn from_cycle_error(tcx: QueryCtxt<'tcx>) -> Self { + let err = tcx.ty_error(); + // FIXME(compiler-errors): It would be nice if we could get the + // query key, so we could at least generate a fn signature that + // has the right arity. + let fn_sig = ty::Binder::dummy(tcx.mk_fn_sig( + [].into_iter(), + err, + false, + rustc_hir::Unsafety::Normal, + rustc_target::spec::abi::Abi::Rust, + )); + + // SAFETY: This is never called when `Self` is not `ty::Binder<'tcx, ty::FnSig<'tcx>>`. + // FIXME: Represent the above fact in the trait system somehow. + unsafe { std::mem::transmute::<ty::PolyFnSig<'tcx>, ty::Binder<'_, ty::FnSig<'_>>>(fn_sig) } + } +} |
