diff options
Diffstat (limited to 'crates/hir_ty/src/traits')
-rw-r--r-- | crates/hir_ty/src/traits/chalk.rs | 20 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 15 |
2 files changed, 19 insertions, 16 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index 232cf9cd0..bef6e7e9c 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs | |||
@@ -22,7 +22,7 @@ use crate::{ | |||
22 | to_assoc_type_id, | 22 | to_assoc_type_id, |
23 | utils::generics, | 23 | utils::generics, |
24 | BoundVar, CallableDefId, CallableSig, DebruijnIndex, FnDefId, GenericPredicate, | 24 | BoundVar, CallableDefId, CallableSig, DebruijnIndex, FnDefId, GenericPredicate, |
25 | ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TyKind, | 25 | ProjectionPredicate, ProjectionTy, Substitution, TraitRef, Ty, TyKind, |
26 | }; | 26 | }; |
27 | use mapping::{ | 27 | use mapping::{ |
28 | convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsValue, | 28 | convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsValue, |
@@ -221,7 +221,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
221 | let impl_bound = GenericPredicate::Implemented(TraitRef { | 221 | let impl_bound = GenericPredicate::Implemented(TraitRef { |
222 | trait_: future_trait, | 222 | trait_: future_trait, |
223 | // Self type as the first parameter. | 223 | // Self type as the first parameter. |
224 | substs: Substs::single( | 224 | substs: Substitution::single( |
225 | TyKind::BoundVar(BoundVar { | 225 | TyKind::BoundVar(BoundVar { |
226 | debruijn: DebruijnIndex::INNERMOST, | 226 | debruijn: DebruijnIndex::INNERMOST, |
227 | index: 0, | 227 | index: 0, |
@@ -236,7 +236,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
236 | projection_ty: ProjectionTy { | 236 | projection_ty: ProjectionTy { |
237 | associated_ty_id: to_assoc_type_id(future_output), | 237 | associated_ty_id: to_assoc_type_id(future_output), |
238 | // Self type as the first parameter. | 238 | // Self type as the first parameter. |
239 | substitution: Substs::single( | 239 | substitution: Substitution::single( |
240 | TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)) | 240 | TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)) |
241 | .intern(&Interner), | 241 | .intern(&Interner), |
242 | ), | 242 | ), |
@@ -313,7 +313,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
313 | _closure_id: chalk_ir::ClosureId<Interner>, | 313 | _closure_id: chalk_ir::ClosureId<Interner>, |
314 | _substs: &chalk_ir::Substitution<Interner>, | 314 | _substs: &chalk_ir::Substitution<Interner>, |
315 | ) -> chalk_ir::Substitution<Interner> { | 315 | ) -> chalk_ir::Substitution<Interner> { |
316 | Substs::empty().to_chalk(self.db) | 316 | Substitution::empty().to_chalk(self.db) |
317 | } | 317 | } |
318 | 318 | ||
319 | fn trait_name(&self, trait_id: chalk_ir::TraitId<Interner>) -> String { | 319 | fn trait_name(&self, trait_id: chalk_ir::TraitId<Interner>) -> String { |
@@ -392,7 +392,7 @@ pub(crate) fn associated_ty_data_query( | |||
392 | // Lower bounds -- we could/should maybe move this to a separate query in `lower` | 392 | // Lower bounds -- we could/should maybe move this to a separate query in `lower` |
393 | let type_alias_data = db.type_alias_data(type_alias); | 393 | let type_alias_data = db.type_alias_data(type_alias); |
394 | let generic_params = generics(db.upcast(), type_alias.into()); | 394 | let generic_params = generics(db.upcast(), type_alias.into()); |
395 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); | 395 | let bound_vars = Substitution::bound_vars(&generic_params, DebruijnIndex::INNERMOST); |
396 | let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db.upcast()); | 396 | let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db.upcast()); |
397 | let ctx = crate::TyLoweringContext::new(db, &resolver) | 397 | let ctx = crate::TyLoweringContext::new(db, &resolver) |
398 | .with_type_param_mode(crate::lower::TypeParamLoweringMode::Variable); | 398 | .with_type_param_mode(crate::lower::TypeParamLoweringMode::Variable); |
@@ -427,9 +427,9 @@ pub(crate) fn trait_datum_query( | |||
427 | let trait_data = db.trait_data(trait_); | 427 | let trait_data = db.trait_data(trait_); |
428 | debug!("trait {:?} = {:?}", trait_id, trait_data.name); | 428 | debug!("trait {:?} = {:?}", trait_id, trait_data.name); |
429 | let generic_params = generics(db.upcast(), trait_.into()); | 429 | let generic_params = generics(db.upcast(), trait_.into()); |
430 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); | 430 | let bound_vars = Substitution::bound_vars(&generic_params, DebruijnIndex::INNERMOST); |
431 | let flags = rust_ir::TraitFlags { | 431 | let flags = rust_ir::TraitFlags { |
432 | auto: trait_data.auto, | 432 | auto: trait_data.is_auto, |
433 | upstream: trait_.lookup(db.upcast()).container.krate() != krate, | 433 | upstream: trait_.lookup(db.upcast()).container.krate() != krate, |
434 | non_enumerable: true, | 434 | non_enumerable: true, |
435 | coinductive: false, // only relevant for Chalk testing | 435 | coinductive: false, // only relevant for Chalk testing |
@@ -496,7 +496,7 @@ pub(crate) fn struct_datum_query( | |||
496 | let upstream = adt_id.module(db.upcast()).krate() != krate; | 496 | let upstream = adt_id.module(db.upcast()).krate() != krate; |
497 | let where_clauses = { | 497 | let where_clauses = { |
498 | let generic_params = generics(db.upcast(), adt_id.into()); | 498 | let generic_params = generics(db.upcast(), adt_id.into()); |
499 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); | 499 | let bound_vars = Substitution::bound_vars(&generic_params, DebruijnIndex::INNERMOST); |
500 | convert_where_clauses(db, adt_id.into(), &bound_vars) | 500 | convert_where_clauses(db, adt_id.into(), &bound_vars) |
501 | }; | 501 | }; |
502 | let flags = rust_ir::AdtFlags { | 502 | let flags = rust_ir::AdtFlags { |
@@ -545,7 +545,7 @@ fn impl_def_datum( | |||
545 | let impl_data = db.impl_data(impl_id); | 545 | let impl_data = db.impl_data(impl_id); |
546 | 546 | ||
547 | let generic_params = generics(db.upcast(), impl_id.into()); | 547 | let generic_params = generics(db.upcast(), impl_id.into()); |
548 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); | 548 | let bound_vars = Substitution::bound_vars(&generic_params, DebruijnIndex::INNERMOST); |
549 | let trait_ = trait_ref.trait_; | 549 | let trait_ = trait_ref.trait_; |
550 | let impl_type = if impl_id.lookup(db.upcast()).container.krate() == krate { | 550 | let impl_type = if impl_id.lookup(db.upcast()).container.krate() == krate { |
551 | rust_ir::ImplType::Local | 551 | rust_ir::ImplType::Local |
@@ -635,7 +635,7 @@ pub(crate) fn fn_def_datum_query( | |||
635 | let callable_def: CallableDefId = from_chalk(db, fn_def_id); | 635 | let callable_def: CallableDefId = from_chalk(db, fn_def_id); |
636 | let generic_params = generics(db.upcast(), callable_def.into()); | 636 | let generic_params = generics(db.upcast(), callable_def.into()); |
637 | let sig = db.callable_item_signature(callable_def); | 637 | let sig = db.callable_item_signature(callable_def); |
638 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); | 638 | let bound_vars = Substitution::bound_vars(&generic_params, DebruijnIndex::INNERMOST); |
639 | let where_clauses = convert_where_clauses(db, callable_def.into(), &bound_vars); | 639 | let where_clauses = convert_where_clauses(db, callable_def.into(), &bound_vars); |
640 | let bound = rust_ir::FnDefDatumBound { | 640 | let bound = rust_ir::FnDefDatumBound { |
641 | // Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway | 641 | // Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway |
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 6a8b6752e..524814f43 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -15,7 +15,7 @@ use crate::{ | |||
15 | primitive::UintTy, | 15 | primitive::UintTy, |
16 | traits::{Canonical, Obligation}, | 16 | traits::{Canonical, Obligation}, |
17 | AliasTy, CallableDefId, FnPointer, GenericPredicate, InEnvironment, OpaqueTy, | 17 | AliasTy, CallableDefId, FnPointer, GenericPredicate, InEnvironment, OpaqueTy, |
18 | ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitRef, Ty, | 18 | ProjectionPredicate, ProjectionTy, Scalar, Substitution, TraitRef, Ty, |
19 | }; | 19 | }; |
20 | 20 | ||
21 | use super::interner::*; | 21 | use super::interner::*; |
@@ -134,7 +134,7 @@ impl ToChalk for Ty { | |||
134 | .. | 134 | .. |
135 | }) => { | 135 | }) => { |
136 | assert_eq!(num_binders, 0); | 136 | assert_eq!(num_binders, 0); |
137 | let substs: Substs = from_chalk( | 137 | let substs: Substitution = from_chalk( |
138 | db, | 138 | db, |
139 | substitution.0.shifted_out(&Interner).expect("fn ptr should have no binders"), | 139 | substitution.0.shifted_out(&Interner).expect("fn ptr should have no binders"), |
140 | ); | 140 | ); |
@@ -213,14 +213,17 @@ fn array_to_chalk(db: &dyn HirDatabase, ty: Ty) -> chalk_ir::Ty<Interner> { | |||
213 | chalk_ir::TyKind::Array(arg, const_).intern(&Interner) | 213 | chalk_ir::TyKind::Array(arg, const_).intern(&Interner) |
214 | } | 214 | } |
215 | 215 | ||
216 | impl ToChalk for Substs { | 216 | impl ToChalk for Substitution { |
217 | type Chalk = chalk_ir::Substitution<Interner>; | 217 | type Chalk = chalk_ir::Substitution<Interner>; |
218 | 218 | ||
219 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Substitution<Interner> { | 219 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Substitution<Interner> { |
220 | chalk_ir::Substitution::from_iter(&Interner, self.iter().map(|ty| ty.clone().to_chalk(db))) | 220 | chalk_ir::Substitution::from_iter(&Interner, self.iter().map(|ty| ty.clone().to_chalk(db))) |
221 | } | 221 | } |
222 | 222 | ||
223 | fn from_chalk(db: &dyn HirDatabase, parameters: chalk_ir::Substitution<Interner>) -> Substs { | 223 | fn from_chalk( |
224 | db: &dyn HirDatabase, | ||
225 | parameters: chalk_ir::Substitution<Interner>, | ||
226 | ) -> Substitution { | ||
224 | let tys = parameters | 227 | let tys = parameters |
225 | .iter(&Interner) | 228 | .iter(&Interner) |
226 | .map(|p| match p.ty(&Interner) { | 229 | .map(|p| match p.ty(&Interner) { |
@@ -228,7 +231,7 @@ impl ToChalk for Substs { | |||
228 | None => unimplemented!(), | 231 | None => unimplemented!(), |
229 | }) | 232 | }) |
230 | .collect(); | 233 | .collect(); |
231 | Substs(tys) | 234 | Substitution(tys) |
232 | } | 235 | } |
233 | } | 236 | } |
234 | 237 | ||
@@ -489,7 +492,7 @@ where | |||
489 | pub(super) fn convert_where_clauses( | 492 | pub(super) fn convert_where_clauses( |
490 | db: &dyn HirDatabase, | 493 | db: &dyn HirDatabase, |
491 | def: GenericDefId, | 494 | def: GenericDefId, |
492 | substs: &Substs, | 495 | substs: &Substitution, |
493 | ) -> Vec<chalk_ir::QuantifiedWhereClause<Interner>> { | 496 | ) -> Vec<chalk_ir::QuantifiedWhereClause<Interner>> { |
494 | let generic_predicates = db.generic_predicates(def); | 497 | let generic_predicates = db.generic_predicates(def); |
495 | let mut result = Vec::with_capacity(generic_predicates.len()); | 498 | let mut result = Vec::with_capacity(generic_predicates.len()); |