diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-05 22:03:01 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-05 22:03:01 +0100 |
commit | 4bc8a018302d53951ae855ba57d07095a16ef182 (patch) | |
tree | db440a2bdd6148bc292bd20397f389671f8cb48c /crates/hir_ty/src/traits | |
parent | 7ce0e9c9ca552e063855d60df7dca65ba9953fc3 (diff) | |
parent | 1ae967bf8e01262f1ace1c06f6670f09fcf92fd2 (diff) |
Merge #8360
8360: Fix shifting of binders in FnPointer r=flodiebold a=flodiebold
- 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
Tested with the binders validator on various repos, so I'm pretty sure this doesn't mess things up :grimacing:
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/traits')
-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), |