From 1ae967bf8e01262f1ace1c06f6670f09fcf92fd2 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 5 Apr 2021 22:32:58 +0200 Subject: Fix shifting of binders in FnPointer - don't shift in/out for Chalk mapping (we want to have the same binders now) - do shift in when creating the signature for a closure (though it shouldn't matter much) - do shift in when lowering a `fn()` type - correctly deal with the implied binder in TypeWalk --- crates/hir_ty/src/infer/expr.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'crates/hir_ty/src/infer') diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index a2a7236a8..ff564106b 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -23,7 +23,7 @@ use crate::{ traits::{chalk::from_chalk, FnTrait}, utils::{generics, variant_data, Generics}, AdtId, Binders, CallableDefId, FnPointer, FnSig, FnSubst, InEnvironment, Interner, - ProjectionTyExt, Rawness, Scalar, Substitution, TraitRef, Ty, TyBuilder, TyKind, + ProjectionTyExt, Rawness, Scalar, Substitution, TraitRef, Ty, TyBuilder, TyKind, TypeWalk, }; use super::{ @@ -262,7 +262,9 @@ impl<'a> InferenceContext<'a> { let sig_ty = TyKind::Function(FnPointer { num_binders: 0, sig: FnSig { abi: (), safety: chalk_ir::Safety::Safe, variadic: false }, - substitution: FnSubst(Substitution::from_iter(&Interner, sig_tys.clone())), + substitution: FnSubst( + Substitution::from_iter(&Interner, sig_tys.clone()).shifted_in(&Interner), + ), }) .intern(&Interner); let closure_id = self.db.intern_closure((self.owner, tgt_expr)).into(); -- cgit v1.2.3