diff options
author | Florian Diebold <[email protected]> | 2021-04-05 21:32:58 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-05 22:00:50 +0100 |
commit | 1ae967bf8e01262f1ace1c06f6670f09fcf92fd2 (patch) | |
tree | db440a2bdd6148bc292bd20397f389671f8cb48c /crates/hir_ty/src/traits/chalk | |
parent | edc59d897d56815e8b9814cdc4ff084100e4f3b4 (diff) |
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
Diffstat (limited to 'crates/hir_ty/src/traits/chalk')
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 9 |
1 files changed, 3 insertions, 6 deletions
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 @@ | |||
3 | //! Chalk (in both directions); plus some helper functions for more specialized | 3 | //! Chalk (in both directions); plus some helper functions for more specialized |
4 | //! conversions. | 4 | //! conversions. |
5 | 5 | ||
6 | use chalk_ir::{cast::Cast, fold::shift::Shift, interner::HasInterner, LifetimeData}; | 6 | use chalk_ir::{cast::Cast, interner::HasInterner, LifetimeData}; |
7 | use chalk_solve::rust_ir; | 7 | use chalk_solve::rust_ir; |
8 | 8 | ||
9 | use base_db::salsa::InternKey; | 9 | use base_db::salsa::InternKey; |
@@ -25,7 +25,7 @@ impl ToChalk for Ty { | |||
25 | TyKind::Ref(m, ty) => ref_to_chalk(db, m, ty), | 25 | TyKind::Ref(m, ty) => ref_to_chalk(db, m, ty), |
26 | TyKind::Array(ty) => array_to_chalk(db, ty), | 26 | TyKind::Array(ty) => array_to_chalk(db, ty), |
27 | TyKind::Function(FnPointer { sig, substitution: substs, .. }) => { | 27 | TyKind::Function(FnPointer { sig, substitution: substs, .. }) => { |
28 | let substitution = chalk_ir::FnSubst(substs.0.to_chalk(db).shifted_in(&Interner)); | 28 | let substitution = chalk_ir::FnSubst(substs.0.to_chalk(db)); |
29 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { | 29 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { |
30 | num_binders: 0, | 30 | num_binders: 0, |
31 | sig, | 31 | sig, |
@@ -132,10 +132,7 @@ impl ToChalk for Ty { | |||
132 | .. | 132 | .. |
133 | }) => { | 133 | }) => { |
134 | assert_eq!(num_binders, 0); | 134 | assert_eq!(num_binders, 0); |
135 | let substs = crate::FnSubst(from_chalk( | 135 | let substs = crate::FnSubst(from_chalk(db, substitution.0)); |
136 | db, | ||
137 | substitution.0.shifted_out(&Interner).expect("fn ptr should have no binders"), | ||
138 | )); | ||
139 | TyKind::Function(FnPointer { num_binders, sig, substitution: substs }) | 136 | TyKind::Function(FnPointer { num_binders, sig, substitution: substs }) |
140 | } | 137 | } |
141 | chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx), | 138 | chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx), |