diff options
Diffstat (limited to 'crates/hir_ty/src/traits/chalk.rs')
-rw-r--r-- | crates/hir_ty/src/traits/chalk.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index d74c83737..e513fa8f4 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs | |||
@@ -19,8 +19,8 @@ use crate::{ | |||
19 | display::HirDisplay, | 19 | display::HirDisplay, |
20 | method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS}, | 20 | method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS}, |
21 | utils::generics, | 21 | utils::generics, |
22 | BoundVar, CallableDefId, DebruijnIndex, FnSig, GenericPredicate, ProjectionPredicate, | 22 | BoundVar, CallableDefId, CallableSig, DebruijnIndex, GenericPredicate, ProjectionPredicate, |
23 | ProjectionTy, Substs, TraitRef, Ty, TypeCtor, | 23 | ProjectionTy, Substs, TraitRef, Ty, |
24 | }; | 24 | }; |
25 | use mapping::{ | 25 | use mapping::{ |
26 | convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsAssocType, | 26 | convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsAssocType, |
@@ -90,7 +90,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
90 | ty: &Ty, | 90 | ty: &Ty, |
91 | binders: &CanonicalVarKinds<Interner>, | 91 | binders: &CanonicalVarKinds<Interner>, |
92 | ) -> Option<chalk_ir::TyVariableKind> { | 92 | ) -> Option<chalk_ir::TyVariableKind> { |
93 | if let Ty::Bound(bv) = ty { | 93 | if let Ty::BoundVar(bv) = ty { |
94 | let binders = binders.as_slice(&Interner); | 94 | let binders = binders.as_slice(&Interner); |
95 | if bv.debruijn == DebruijnIndex::INNERMOST { | 95 | if bv.debruijn == DebruijnIndex::INNERMOST { |
96 | if let chalk_ir::VariableKind::Ty(tk) = binders[bv.index].kind { | 96 | if let chalk_ir::VariableKind::Ty(tk) = binders[bv.index].kind { |
@@ -220,18 +220,18 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
220 | let impl_bound = GenericPredicate::Implemented(TraitRef { | 220 | let impl_bound = GenericPredicate::Implemented(TraitRef { |
221 | trait_: future_trait, | 221 | trait_: future_trait, |
222 | // Self type as the first parameter. | 222 | // Self type as the first parameter. |
223 | substs: Substs::single(Ty::Bound(BoundVar { | 223 | substs: Substs::single(Ty::BoundVar(BoundVar { |
224 | debruijn: DebruijnIndex::INNERMOST, | 224 | debruijn: DebruijnIndex::INNERMOST, |
225 | index: 0, | 225 | index: 0, |
226 | })), | 226 | })), |
227 | }); | 227 | }); |
228 | let proj_bound = GenericPredicate::Projection(ProjectionPredicate { | 228 | let proj_bound = GenericPredicate::Projection(ProjectionPredicate { |
229 | // The parameter of the opaque type. | 229 | // The parameter of the opaque type. |
230 | ty: Ty::Bound(BoundVar { debruijn: DebruijnIndex::ONE, index: 0 }), | 230 | ty: Ty::BoundVar(BoundVar { debruijn: DebruijnIndex::ONE, index: 0 }), |
231 | projection_ty: ProjectionTy { | 231 | projection_ty: ProjectionTy { |
232 | associated_ty: future_output, | 232 | associated_ty: future_output, |
233 | // Self type as the first parameter. | 233 | // Self type as the first parameter. |
234 | parameters: Substs::single(Ty::Bound(BoundVar::new( | 234 | parameters: Substs::single(Ty::BoundVar(BoundVar::new( |
235 | DebruijnIndex::INNERMOST, | 235 | DebruijnIndex::INNERMOST, |
236 | 0, | 236 | 0, |
237 | ))), | 237 | ))), |
@@ -286,9 +286,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
286 | ) -> chalk_ir::Binders<rust_ir::FnDefInputsAndOutputDatum<Interner>> { | 286 | ) -> chalk_ir::Binders<rust_ir::FnDefInputsAndOutputDatum<Interner>> { |
287 | let sig_ty: Ty = | 287 | let sig_ty: Ty = |
288 | from_chalk(self.db, substs.at(&Interner, 0).assert_ty_ref(&Interner).clone()); | 288 | from_chalk(self.db, substs.at(&Interner, 0).assert_ty_ref(&Interner).clone()); |
289 | let sig = FnSig::from_fn_ptr_substs( | 289 | let sig = CallableSig::from_substs( |
290 | &sig_ty.substs().expect("first closure param should be fn ptr"), | 290 | &sig_ty.substs().expect("first closure param should be fn ptr"), |
291 | false, | ||
292 | ); | 291 | ); |
293 | let io = rust_ir::FnDefInputsAndOutputDatum { | 292 | let io = rust_ir::FnDefInputsAndOutputDatum { |
294 | argument_types: sig.params().iter().map(|ty| ty.clone().to_chalk(self.db)).collect(), | 293 | argument_types: sig.params().iter().map(|ty| ty.clone().to_chalk(self.db)).collect(), |
@@ -393,7 +392,7 @@ pub(crate) fn associated_ty_data_query( | |||
393 | let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db.upcast()); | 392 | let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db.upcast()); |
394 | let ctx = crate::TyLoweringContext::new(db, &resolver) | 393 | let ctx = crate::TyLoweringContext::new(db, &resolver) |
395 | .with_type_param_mode(crate::lower::TypeParamLoweringMode::Variable); | 394 | .with_type_param_mode(crate::lower::TypeParamLoweringMode::Variable); |
396 | let self_ty = Ty::Bound(crate::BoundVar::new(crate::DebruijnIndex::INNERMOST, 0)); | 395 | let self_ty = Ty::BoundVar(crate::BoundVar::new(crate::DebruijnIndex::INNERMOST, 0)); |
397 | let bounds = type_alias_data | 396 | let bounds = type_alias_data |
398 | .bounds | 397 | .bounds |
399 | .iter() | 398 | .iter() |
@@ -489,10 +488,11 @@ pub(crate) fn struct_datum_query( | |||
489 | struct_id: AdtId, | 488 | struct_id: AdtId, |
490 | ) -> Arc<StructDatum> { | 489 | ) -> Arc<StructDatum> { |
491 | debug!("struct_datum {:?}", struct_id); | 490 | debug!("struct_datum {:?}", struct_id); |
492 | let type_ctor = TypeCtor::Adt(from_chalk(db, struct_id)); | 491 | let adt_id = from_chalk(db, struct_id); |
492 | let type_ctor = Ty::Adt(adt_id, Substs::empty()); | ||
493 | debug!("struct {:?} = {:?}", struct_id, type_ctor); | 493 | debug!("struct {:?} = {:?}", struct_id, type_ctor); |
494 | let num_params = type_ctor.num_ty_params(db); | 494 | let num_params = generics(db.upcast(), adt_id.into()).len(); |
495 | let upstream = type_ctor.krate(db) != Some(krate); | 495 | let upstream = adt_id.module(db.upcast()).krate() != krate; |
496 | let where_clauses = type_ctor | 496 | let where_clauses = type_ctor |
497 | .as_generic_def() | 497 | .as_generic_def() |
498 | .map(|generic_def| { | 498 | .map(|generic_def| { |