aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits/chalk.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/traits/chalk.rs')
-rw-r--r--crates/hir_ty/src/traits/chalk.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs
index 55181cc49..bb92d8e2a 100644
--- a/crates/hir_ty/src/traits/chalk.rs
+++ b/crates/hir_ty/src/traits/chalk.rs
@@ -17,14 +17,15 @@ use super::ChalkContext;
17use crate::{ 17use crate::{
18 db::HirDatabase, 18 db::HirDatabase,
19 display::HirDisplay, 19 display::HirDisplay,
20 from_assoc_type_id,
20 method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS}, 21 method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS},
22 to_assoc_type_id,
21 utils::generics, 23 utils::generics,
22 BoundVar, CallableDefId, CallableSig, DebruijnIndex, GenericPredicate, ProjectionPredicate, 24 BoundVar, CallableDefId, CallableSig, DebruijnIndex, FnDefId, GenericPredicate,
23 ProjectionTy, Substs, TraitRef, Ty, TyKind, 25 ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TyKind,
24}; 26};
25use mapping::{ 27use mapping::{
26 convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsAssocType, 28 convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsValue,
27 TypeAliasAsValue,
28}; 29};
29 30
30pub use self::interner::Interner; 31pub use self::interner::Interner;
@@ -234,7 +235,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
234 ty: TyKind::BoundVar(BoundVar { debruijn: DebruijnIndex::ONE, index: 0 }) 235 ty: TyKind::BoundVar(BoundVar { debruijn: DebruijnIndex::ONE, index: 0 })
235 .intern(&Interner), 236 .intern(&Interner),
236 projection_ty: ProjectionTy { 237 projection_ty: ProjectionTy {
237 associated_ty: future_output, 238 associated_ty: to_assoc_type_id(future_output),
238 // Self type as the first parameter. 239 // Self type as the first parameter.
239 parameters: Substs::single( 240 parameters: Substs::single(
240 TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)) 241 TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0))
@@ -383,7 +384,7 @@ pub(crate) fn associated_ty_data_query(
383 id: AssocTypeId, 384 id: AssocTypeId,
384) -> Arc<AssociatedTyDatum> { 385) -> Arc<AssociatedTyDatum> {
385 debug!("associated_ty_data {:?}", id); 386 debug!("associated_ty_data {:?}", id);
386 let type_alias: TypeAliasId = from_chalk::<TypeAliasAsAssocType, _>(db, id).0; 387 let type_alias: TypeAliasId = from_assoc_type_id(id);
387 let trait_ = match type_alias.lookup(db.upcast()).container { 388 let trait_ = match type_alias.lookup(db.upcast()).container {
388 AssocContainerId::TraitId(t) => t, 389 AssocContainerId::TraitId(t) => t,
389 _ => panic!("associated type not in trait"), 390 _ => panic!("associated type not in trait"),
@@ -438,10 +439,8 @@ pub(crate) fn trait_datum_query(
438 fundamental: false, 439 fundamental: false,
439 }; 440 };
440 let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars); 441 let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars);
441 let associated_ty_ids = trait_data 442 let associated_ty_ids =
442 .associated_types() 443 trait_data.associated_types().map(|type_alias| to_assoc_type_id(type_alias)).collect();
443 .map(|type_alias| TypeAliasAsAssocType(type_alias).to_chalk(db))
444 .collect();
445 let trait_datum_bound = rust_ir::TraitDatumBound { where_clauses }; 444 let trait_datum_bound = rust_ir::TraitDatumBound { where_clauses };
446 let well_known = 445 let well_known =
447 lang_attr(db.upcast(), trait_).and_then(|name| well_known_trait_from_lang_attr(&name)); 446 lang_attr(db.upcast(), trait_).and_then(|name| well_known_trait_from_lang_attr(&name));
@@ -623,7 +622,7 @@ fn type_alias_associated_ty_value(
623 let value_bound = rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) }; 622 let value_bound = rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) };
624 let value = rust_ir::AssociatedTyValue { 623 let value = rust_ir::AssociatedTyValue {
625 impl_id: impl_id.to_chalk(db), 624 impl_id: impl_id.to_chalk(db),
626 associated_ty_id: TypeAliasAsAssocType(assoc_ty).to_chalk(db), 625 associated_ty_id: to_assoc_type_id(assoc_ty),
627 value: make_binders(value_bound, ty.num_binders), 626 value: make_binders(value_bound, ty.num_binders),
628 }; 627 };
629 Arc::new(value) 628 Arc::new(value)