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
This commit is contained in:
Florian Diebold 2021-04-05 22:32:58 +02:00
parent edc59d897d
commit 1ae967bf8e
4 changed files with 23 additions and 10 deletions

View file

@ -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();