mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Fix shifted_{in,out} calls
This commit is contained in:
parent
dc0b581736
commit
b25b147e86
5 changed files with 11 additions and 11 deletions
|
@ -3,7 +3,7 @@
|
||||||
use std::iter::{repeat, repeat_with};
|
use std::iter::{repeat, repeat_with};
|
||||||
use std::{mem, sync::Arc};
|
use std::{mem, sync::Arc};
|
||||||
|
|
||||||
use chalk_ir::{cast::Cast, Mutability, TyVariableKind};
|
use chalk_ir::{cast::Cast, fold::Shift, Mutability, TyVariableKind};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp},
|
expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp},
|
||||||
path::{GenericArg, GenericArgs},
|
path::{GenericArg, GenericArgs},
|
||||||
|
|
|
@ -35,7 +35,7 @@ use std::sync::Arc;
|
||||||
use base_db::salsa;
|
use base_db::salsa;
|
||||||
use chalk_ir::{
|
use chalk_ir::{
|
||||||
cast::{CastTo, Caster},
|
cast::{CastTo, Caster},
|
||||||
fold::Fold,
|
fold::{Fold, Shift},
|
||||||
interner::HasInterner,
|
interner::HasInterner,
|
||||||
UintTy,
|
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>
|
pub fn wrap_empty_binders<T>(value: T) -> Binders<T>
|
||||||
where
|
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>>(
|
pub fn make_only_type_binders<T: HasInterner<Interner = Interner>>(
|
||||||
|
@ -187,7 +187,7 @@ impl CallableSig {
|
||||||
params_and_return: fn_ptr
|
params_and_return: fn_ptr
|
||||||
.substitution
|
.substitution
|
||||||
.clone()
|
.clone()
|
||||||
.shifted_out_to(DebruijnIndex::ONE)
|
.shifted_out_to(&Interner, DebruijnIndex::ONE)
|
||||||
.expect("unexpected lifetime vars in fn ptr")
|
.expect("unexpected lifetime vars in fn ptr")
|
||||||
.0
|
.0
|
||||||
.interned()
|
.interned()
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
use std::{iter, sync::Arc};
|
use std::{iter, sync::Arc};
|
||||||
|
|
||||||
use base_db::CrateId;
|
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::{
|
use hir_def::{
|
||||||
adt::StructKind,
|
adt::StructKind,
|
||||||
builtin_type::BuiltinType,
|
builtin_type::BuiltinType,
|
||||||
|
@ -488,7 +488,7 @@ impl<'a> TyLoweringContext<'a> {
|
||||||
};
|
};
|
||||||
// We need to shift in the bound vars, since
|
// We need to shift in the bound vars, since
|
||||||
// associated_type_shorthand_candidates does not do that
|
// 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
|
// FIXME handle type parameters on the segment
|
||||||
return Some(
|
return Some(
|
||||||
TyKind::Alias(AliasTy::Projection(ProjectionTy {
|
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?
|
// FIXME: how to correctly handle higher-ranked bounds here?
|
||||||
WhereClause::Implemented(tr) => search(
|
WhereClause::Implemented(tr) => search(
|
||||||
tr.clone()
|
tr.clone()
|
||||||
.shifted_out_to(DebruijnIndex::ONE)
|
.shifted_out_to(&Interner, DebruijnIndex::ONE)
|
||||||
.expect("FIXME unexpected higher-ranked trait bound"),
|
.expect("FIXME unexpected higher-ranked trait bound"),
|
||||||
),
|
),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
@ -288,7 +288,7 @@ pub(super) fn generic_predicate_to_inline_bound(
|
||||||
) -> Option<chalk_ir::Binders<rust_ir::InlineBound<Interner>>> {
|
) -> Option<chalk_ir::Binders<rust_ir::InlineBound<Interner>>> {
|
||||||
// An InlineBound is like a GenericPredicate, except the self type is left out.
|
// 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.
|
// 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();
|
let (pred, binders) = pred.as_ref().into_value_and_skipped_binders();
|
||||||
match pred {
|
match pred {
|
||||||
WhereClause::Implemented(trait_ref) => {
|
WhereClause::Implemented(trait_ref) => {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//! query, but can't be computed directly from `*Data` (ie, which need a `db`).
|
//! query, but can't be computed directly from `*Data` (ie, which need a `db`).
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use chalk_ir::{BoundVar, DebruijnIndex};
|
use chalk_ir::{fold::Shift, BoundVar, DebruijnIndex};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
generics::{
|
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?
|
// FIXME: how to correctly handle higher-ranked bounds here?
|
||||||
WhereClause::Implemented(tr) => Some(
|
WhereClause::Implemented(tr) => Some(
|
||||||
tr.clone()
|
tr.clone()
|
||||||
.shifted_out_to(DebruijnIndex::ONE)
|
.shifted_out_to(&Interner, DebruijnIndex::ONE)
|
||||||
.expect("FIXME unexpected higher-ranked trait bound"),
|
.expect("FIXME unexpected higher-ranked trait bound"),
|
||||||
),
|
),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue