Fix shifted_{in,out} calls

This commit is contained in:
Florian Diebold 2021-04-07 21:26:24 +02:00
parent dc0b581736
commit b25b147e86
5 changed files with 11 additions and 11 deletions

View File

@ -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},

View File

@ -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<usize> {
pub fn wrap_empty_binders<T>(value: T) -> Binders<T>
where
T: TypeWalk + HasInterner<Interner = Interner>,
T: Fold<Interner, Result = T> + HasInterner<Interner = Interner>,
{
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<T: HasInterner<Interner = Interner>>(
@ -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()

View File

@ -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<R>(
// 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,

View File

@ -288,7 +288,7 @@ pub(super) fn generic_predicate_to_inline_bound(
) -> Option<chalk_ir::Binders<rust_ir::InlineBound<Interner>>> {
// 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) => {

View File

@ -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<Tr
// FIXME: how to correctly handle higher-ranked bounds here?
WhereClause::Implemented(tr) => Some(
tr.clone()
.shifted_out_to(DebruijnIndex::ONE)
.shifted_out_to(&Interner, DebruijnIndex::ONE)
.expect("FIXME unexpected higher-ranked trait bound"),
),
_ => None,