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/traits/chalk/mapping.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'crates/hir_ty/src/traits/chalk') diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 13d8d1111..3047fbacb 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs @@ -3,7 +3,7 @@ //! Chalk (in both directions); plus some helper functions for more specialized //! conversions. -use chalk_ir::{cast::Cast, fold::shift::Shift, interner::HasInterner, LifetimeData}; +use chalk_ir::{cast::Cast, interner::HasInterner, LifetimeData}; use chalk_solve::rust_ir; use base_db::salsa::InternKey; @@ -25,7 +25,7 @@ impl ToChalk for Ty { TyKind::Ref(m, ty) => ref_to_chalk(db, m, ty), TyKind::Array(ty) => array_to_chalk(db, ty), TyKind::Function(FnPointer { sig, substitution: substs, .. }) => { - let substitution = chalk_ir::FnSubst(substs.0.to_chalk(db).shifted_in(&Interner)); + let substitution = chalk_ir::FnSubst(substs.0.to_chalk(db)); chalk_ir::TyKind::Function(chalk_ir::FnPointer { num_binders: 0, sig, @@ -132,10 +132,7 @@ impl ToChalk for Ty { .. }) => { assert_eq!(num_binders, 0); - let substs = crate::FnSubst(from_chalk( - db, - substitution.0.shifted_out(&Interner).expect("fn ptr should have no binders"), - )); + let substs = crate::FnSubst(from_chalk(db, substitution.0)); TyKind::Function(FnPointer { num_binders, sig, substitution: substs }) } chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx), -- cgit v1.2.3