Replace make_binders
by the now equivalent make_only_type_binders
This commit is contained in:
parent
8ce6fea325
commit
8040f4a5e3
@ -17,16 +17,14 @@ use super::ChalkContext;
|
|||||||
use crate::{
|
use crate::{
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
display::HirDisplay,
|
display::HirDisplay,
|
||||||
from_assoc_type_id,
|
from_assoc_type_id, make_only_type_binders,
|
||||||
method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS},
|
method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS},
|
||||||
to_assoc_type_id, to_chalk_trait_id,
|
to_assoc_type_id, to_chalk_trait_id,
|
||||||
utils::generics,
|
utils::generics,
|
||||||
AliasEq, AliasTy, BoundVar, CallableDefId, DebruijnIndex, FnDefId, ProjectionTy, Substitution,
|
AliasEq, AliasTy, BoundVar, CallableDefId, DebruijnIndex, FnDefId, ProjectionTy, Substitution,
|
||||||
TraitRef, TraitRefExt, Ty, TyBuilder, TyExt, TyKind, WhereClause,
|
TraitRef, TraitRefExt, Ty, TyBuilder, TyExt, TyKind, WhereClause,
|
||||||
};
|
};
|
||||||
use mapping::{
|
use mapping::{convert_where_clauses, generic_predicate_to_inline_bound, TypeAliasAsValue};
|
||||||
convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsValue,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub use self::interner::Interner;
|
pub use self::interner::Interner;
|
||||||
pub(crate) use self::interner::*;
|
pub(crate) use self::interner::*;
|
||||||
@ -187,8 +185,11 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
|||||||
let (datas, binders) = (*datas).as_ref().into_value_and_skipped_binders();
|
let (datas, binders) = (*datas).as_ref().into_value_and_skipped_binders();
|
||||||
let data = &datas.impl_traits[idx as usize];
|
let data = &datas.impl_traits[idx as usize];
|
||||||
let bound = OpaqueTyDatumBound {
|
let bound = OpaqueTyDatumBound {
|
||||||
bounds: make_binders(data.bounds.skip_binders().iter().cloned().collect(), 1),
|
bounds: make_only_type_binders(
|
||||||
where_clauses: make_binders(vec![], 0),
|
1,
|
||||||
|
data.bounds.skip_binders().iter().cloned().collect(),
|
||||||
|
),
|
||||||
|
where_clauses: make_only_type_binders(0, vec![]),
|
||||||
};
|
};
|
||||||
chalk_ir::Binders::new(binders, bound)
|
chalk_ir::Binders::new(binders, bound)
|
||||||
}
|
}
|
||||||
@ -236,25 +237,25 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
|||||||
.intern(&Interner),
|
.intern(&Interner),
|
||||||
});
|
});
|
||||||
let bound = OpaqueTyDatumBound {
|
let bound = OpaqueTyDatumBound {
|
||||||
bounds: make_binders(
|
bounds: make_only_type_binders(
|
||||||
|
1,
|
||||||
vec![
|
vec![
|
||||||
crate::wrap_empty_binders(impl_bound),
|
crate::wrap_empty_binders(impl_bound),
|
||||||
crate::wrap_empty_binders(proj_bound),
|
crate::wrap_empty_binders(proj_bound),
|
||||||
],
|
],
|
||||||
1,
|
|
||||||
),
|
),
|
||||||
where_clauses: make_binders(vec![], 0),
|
where_clauses: make_only_type_binders(0, vec![]),
|
||||||
};
|
};
|
||||||
// The opaque type has 1 parameter.
|
// The opaque type has 1 parameter.
|
||||||
make_binders(bound, 1)
|
make_only_type_binders(1, bound)
|
||||||
} else {
|
} else {
|
||||||
// If failed to find Symbol’s value as variable is void: Future::Output, return empty bounds as fallback.
|
// If failed to find Symbol’s value as variable is void: Future::Output, return empty bounds as fallback.
|
||||||
let bound = OpaqueTyDatumBound {
|
let bound = OpaqueTyDatumBound {
|
||||||
bounds: make_binders(vec![], 0),
|
bounds: make_only_type_binders(0, vec![]),
|
||||||
where_clauses: make_binders(vec![], 0),
|
where_clauses: make_only_type_binders(0, vec![]),
|
||||||
};
|
};
|
||||||
// The opaque type has 1 parameter.
|
// The opaque type has 1 parameter.
|
||||||
make_binders(bound, 1)
|
make_only_type_binders(1, bound)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -291,7 +292,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
|||||||
argument_types: sig.params().iter().cloned().collect(),
|
argument_types: sig.params().iter().cloned().collect(),
|
||||||
return_type: sig.ret().clone(),
|
return_type: sig.ret().clone(),
|
||||||
};
|
};
|
||||||
make_binders(io.shifted_in(&Interner), 0)
|
make_only_type_binders(0, io.shifted_in(&Interner))
|
||||||
}
|
}
|
||||||
fn closure_upvars(
|
fn closure_upvars(
|
||||||
&self,
|
&self,
|
||||||
@ -299,7 +300,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
|||||||
_substs: &chalk_ir::Substitution<Interner>,
|
_substs: &chalk_ir::Substitution<Interner>,
|
||||||
) -> chalk_ir::Binders<chalk_ir::Ty<Interner>> {
|
) -> chalk_ir::Binders<chalk_ir::Ty<Interner>> {
|
||||||
let ty = TyBuilder::unit();
|
let ty = TyBuilder::unit();
|
||||||
make_binders(ty, 0)
|
make_only_type_binders(0, ty)
|
||||||
}
|
}
|
||||||
fn closure_fn_substitution(
|
fn closure_fn_substitution(
|
||||||
&self,
|
&self,
|
||||||
@ -404,7 +405,7 @@ pub(crate) fn associated_ty_data_query(
|
|||||||
trait_id: to_chalk_trait_id(trait_),
|
trait_id: to_chalk_trait_id(trait_),
|
||||||
id,
|
id,
|
||||||
name: type_alias,
|
name: type_alias,
|
||||||
binders: make_binders(bound_data, generic_params.len()),
|
binders: make_only_type_binders(generic_params.len(), bound_data),
|
||||||
};
|
};
|
||||||
Arc::new(datum)
|
Arc::new(datum)
|
||||||
}
|
}
|
||||||
@ -437,7 +438,7 @@ pub(crate) fn trait_datum_query(
|
|||||||
lang_attr(db.upcast(), trait_).and_then(|name| well_known_trait_from_lang_attr(&name));
|
lang_attr(db.upcast(), trait_).and_then(|name| well_known_trait_from_lang_attr(&name));
|
||||||
let trait_datum = TraitDatum {
|
let trait_datum = TraitDatum {
|
||||||
id: trait_id,
|
id: trait_id,
|
||||||
binders: make_binders(trait_datum_bound, bound_vars.len(&Interner)),
|
binders: make_only_type_binders(bound_vars.len(&Interner), trait_datum_bound),
|
||||||
flags,
|
flags,
|
||||||
associated_ty_ids,
|
associated_ty_ids,
|
||||||
well_known,
|
well_known,
|
||||||
@ -506,7 +507,7 @@ pub(crate) fn struct_datum_query(
|
|||||||
// FIXME set ADT kind
|
// FIXME set ADT kind
|
||||||
kind: rust_ir::AdtKind::Struct,
|
kind: rust_ir::AdtKind::Struct,
|
||||||
id: struct_id,
|
id: struct_id,
|
||||||
binders: make_binders(struct_datum_bound, num_params),
|
binders: make_only_type_binders(num_params, struct_datum_bound),
|
||||||
flags,
|
flags,
|
||||||
};
|
};
|
||||||
Arc::new(struct_datum)
|
Arc::new(struct_datum)
|
||||||
@ -575,7 +576,7 @@ fn impl_def_datum(
|
|||||||
.collect();
|
.collect();
|
||||||
debug!("impl_datum: {:?}", impl_datum_bound);
|
debug!("impl_datum: {:?}", impl_datum_bound);
|
||||||
let impl_datum = ImplDatum {
|
let impl_datum = ImplDatum {
|
||||||
binders: make_binders(impl_datum_bound, bound_vars.len(&Interner)),
|
binders: make_only_type_binders(bound_vars.len(&Interner), impl_datum_bound),
|
||||||
impl_type,
|
impl_type,
|
||||||
polarity,
|
polarity,
|
||||||
associated_ty_value_ids,
|
associated_ty_value_ids,
|
||||||
@ -635,13 +636,13 @@ pub(crate) fn fn_def_datum_query(
|
|||||||
let where_clauses = convert_where_clauses(db, callable_def.into(), &bound_vars);
|
let where_clauses = convert_where_clauses(db, callable_def.into(), &bound_vars);
|
||||||
let bound = rust_ir::FnDefDatumBound {
|
let bound = rust_ir::FnDefDatumBound {
|
||||||
// Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway
|
// Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway
|
||||||
inputs_and_output: make_binders(
|
inputs_and_output: make_only_type_binders(
|
||||||
|
0,
|
||||||
rust_ir::FnDefInputsAndOutputDatum {
|
rust_ir::FnDefInputsAndOutputDatum {
|
||||||
argument_types: sig.params().iter().cloned().collect(),
|
argument_types: sig.params().iter().cloned().collect(),
|
||||||
return_type: sig.ret().clone(),
|
return_type: sig.ret().clone(),
|
||||||
}
|
}
|
||||||
.shifted_in(&Interner),
|
.shifted_in(&Interner),
|
||||||
0,
|
|
||||||
),
|
),
|
||||||
where_clauses,
|
where_clauses,
|
||||||
};
|
};
|
||||||
|
@ -71,20 +71,6 @@ impl ToChalk for TypeAliasAsValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn make_binders<T>(value: T, num_vars: usize) -> chalk_ir::Binders<T>
|
|
||||||
where
|
|
||||||
T: HasInterner<Interner = Interner>,
|
|
||||||
{
|
|
||||||
chalk_ir::Binders::new(
|
|
||||||
chalk_ir::VariableKinds::from_iter(
|
|
||||||
&Interner,
|
|
||||||
std::iter::repeat(chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General))
|
|
||||||
.take(num_vars),
|
|
||||||
),
|
|
||||||
value,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn convert_where_clauses(
|
pub(super) fn convert_where_clauses(
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
def: GenericDefId,
|
def: GenericDefId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user