From b25b147e8604f62a5620a5833112e358ebeeb287 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 7 Apr 2021 21:26:24 +0200 Subject: Fix shifted_{in,out} calls --- crates/hir_ty/src/infer/expr.rs | 2 +- crates/hir_ty/src/lib.rs | 8 ++++---- crates/hir_ty/src/lower.rs | 6 +++--- crates/hir_ty/src/traits/chalk/mapping.rs | 2 +- crates/hir_ty/src/utils.rs | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 9841988c5..5f03079e8 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -3,7 +3,7 @@ use std::iter::{repeat, repeat_with}; use std::{mem, sync::Arc}; -use chalk_ir::{cast::Cast, Mutability, TyVariableKind}; +use chalk_ir::{cast::Cast, fold::Shift, Mutability, TyVariableKind}; use hir_def::{ expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, path::{GenericArg, GenericArgs}, diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index 78ae3545a..7d4793c2f 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs @@ -35,7 +35,7 @@ use std::sync::Arc; use base_db::salsa; use chalk_ir::{ cast::{CastTo, Caster}, - fold::Fold, + fold::{Fold, Shift}, interner::HasInterner, UintTy, }; @@ -123,9 +123,9 @@ pub fn param_idx(db: &dyn HirDatabase, id: TypeParamId) -> Option { pub fn wrap_empty_binders(value: T) -> Binders where - T: TypeWalk + HasInterner, + T: Fold + HasInterner, { - Binders::empty(&Interner, value.shifted_in_from(DebruijnIndex::ONE)) + Binders::empty(&Interner, value.shifted_in_from(&Interner, DebruijnIndex::ONE)) } pub fn make_only_type_binders>( @@ -187,7 +187,7 @@ impl CallableSig { params_and_return: fn_ptr .substitution .clone() - .shifted_out_to(DebruijnIndex::ONE) + .shifted_out_to(&Interner, DebruijnIndex::ONE) .expect("unexpected lifetime vars in fn ptr") .0 .interned() diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index d4ba707b4..b45e811fa 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -8,7 +8,7 @@ use std::{iter, sync::Arc}; use base_db::CrateId; -use chalk_ir::{cast::Cast, interner::HasInterner, Mutability, Safety}; +use chalk_ir::{cast::Cast, fold::Shift, interner::HasInterner, Mutability, Safety}; use hir_def::{ adt::StructKind, builtin_type::BuiltinType, @@ -488,7 +488,7 @@ impl<'a> TyLoweringContext<'a> { }; // We need to shift in the bound vars, since // associated_type_shorthand_candidates does not do that - let substs = substs.shifted_in_from(self.in_binders); + let substs = substs.shifted_in_from(&Interner, self.in_binders); // FIXME handle type parameters on the segment return Some( TyKind::Alias(AliasTy::Projection(ProjectionTy { @@ -847,7 +847,7 @@ pub fn associated_type_shorthand_candidates( // FIXME: how to correctly handle higher-ranked bounds here? WhereClause::Implemented(tr) => search( tr.clone() - .shifted_out_to(DebruijnIndex::ONE) + .shifted_out_to(&Interner, DebruijnIndex::ONE) .expect("FIXME unexpected higher-ranked trait bound"), ), _ => None, diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index c2e289660..62cf0fecf 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs @@ -288,7 +288,7 @@ pub(super) fn generic_predicate_to_inline_bound( ) -> Option>> { // An InlineBound is like a GenericPredicate, except the self type is left out. // We don't have a special type for this, but Chalk does. - let self_ty_shifted_in = self_ty.clone().shifted_in_from(DebruijnIndex::ONE); + let self_ty_shifted_in = self_ty.clone().shifted_in_from(&Interner, DebruijnIndex::ONE); let (pred, binders) = pred.as_ref().into_value_and_skipped_binders(); match pred { WhereClause::Implemented(trait_ref) => { diff --git a/crates/hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs index 8d5d5cd73..d26f5152c 100644 --- a/crates/hir_ty/src/utils.rs +++ b/crates/hir_ty/src/utils.rs @@ -2,7 +2,7 @@ //! query, but can't be computed directly from `*Data` (ie, which need a `db`). use std::sync::Arc; -use chalk_ir::{BoundVar, DebruijnIndex}; +use chalk_ir::{fold::Shift, BoundVar, DebruijnIndex}; use hir_def::{ db::DefDatabase, generics::{ @@ -69,7 +69,7 @@ fn direct_super_trait_refs(db: &dyn HirDatabase, trait_ref: &TraitRef) -> Vec Some( tr.clone() - .shifted_out_to(DebruijnIndex::ONE) + .shifted_out_to(&Interner, DebruijnIndex::ONE) .expect("FIXME unexpected higher-ranked trait bound"), ), _ => None, -- cgit v1.2.3