aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/traits')
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 3047fbacb..9267e32b5 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -3,16 +3,16 @@
3//! Chalk (in both directions); plus some helper functions for more specialized 3//! Chalk (in both directions); plus some helper functions for more specialized
4//! conversions. 4//! conversions.
5 5
6use chalk_ir::{cast::Cast, interner::HasInterner, LifetimeData}; 6use chalk_ir::{cast::Cast, interner::HasInterner};
7use chalk_solve::rust_ir; 7use chalk_solve::rust_ir;
8 8
9use base_db::salsa::InternKey; 9use base_db::salsa::InternKey;
10use hir_def::{GenericDefId, TypeAliasId}; 10use hir_def::{GenericDefId, TypeAliasId};
11 11
12use crate::{ 12use crate::{
13 chalk_ext::ProjectionTyExt, db::HirDatabase, primitive::UintTy, AliasTy, CallableDefId, 13 chalk_ext::ProjectionTyExt, db::HirDatabase, primitive::UintTy, static_lifetime, AliasTy,
14 Canonical, DomainGoal, FnPointer, GenericArg, InEnvironment, OpaqueTy, ProjectionTy, 14 CallableDefId, Canonical, DomainGoal, FnPointer, GenericArg, InEnvironment, Lifetime, OpaqueTy,
15 QuantifiedWhereClause, Scalar, Substitution, TraitRef, Ty, TypeWalk, WhereClause, 15 ProjectionTy, QuantifiedWhereClause, Scalar, Substitution, TraitRef, Ty, TypeWalk, WhereClause,
16}; 16};
17 17
18use super::interner::*; 18use super::interner::*;
@@ -22,7 +22,7 @@ impl ToChalk for Ty {
22 type Chalk = chalk_ir::Ty<Interner>; 22 type Chalk = chalk_ir::Ty<Interner>;
23 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> { 23 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> {
24 match self.into_inner() { 24 match self.into_inner() {
25 TyKind::Ref(m, ty) => ref_to_chalk(db, m, ty), 25 TyKind::Ref(m, lt, ty) => ref_to_chalk(db, m, lt, ty),
26 TyKind::Array(ty) => array_to_chalk(db, ty), 26 TyKind::Array(ty) => array_to_chalk(db, ty),
27 TyKind::Function(FnPointer { sig, substitution: substs, .. }) => { 27 TyKind::Function(FnPointer { sig, substitution: substs, .. }) => {
28 let substitution = chalk_ir::FnSubst(substs.0.to_chalk(db)); 28 let substitution = chalk_ir::FnSubst(substs.0.to_chalk(db));
@@ -100,7 +100,7 @@ impl ToChalk for Ty {
100 ); 100 );
101 let bounded_ty = chalk_ir::DynTy { 101 let bounded_ty = chalk_ir::DynTy {
102 bounds: chalk_ir::Binders::new(binders, where_clauses), 102 bounds: chalk_ir::Binders::new(binders, where_clauses),
103 lifetime: LifetimeData::Static.intern(&Interner), 103 lifetime: static_lifetime(),
104 }; 104 };
105 chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner) 105 chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner)
106 } 106 }
@@ -149,6 +149,7 @@ impl ToChalk for Ty {
149 where_clauses.bounds.binders.clone(), 149 where_clauses.bounds.binders.clone(),
150 crate::QuantifiedWhereClauses::from_iter(&Interner, bounds), 150 crate::QuantifiedWhereClauses::from_iter(&Interner, bounds),
151 ), 151 ),
152 lifetime: static_lifetime(),
152 }) 153 })
153 } 154 }
154 155
@@ -167,8 +168,8 @@ impl ToChalk for Ty {
167 } 168 }
168 chalk_ir::TyKind::Raw(mutability, ty) => TyKind::Raw(mutability, from_chalk(db, ty)), 169 chalk_ir::TyKind::Raw(mutability, ty) => TyKind::Raw(mutability, from_chalk(db, ty)),
169 chalk_ir::TyKind::Slice(ty) => TyKind::Slice(from_chalk(db, ty)), 170 chalk_ir::TyKind::Slice(ty) => TyKind::Slice(from_chalk(db, ty)),
170 chalk_ir::TyKind::Ref(mutability, _lifetime, ty) => { 171 chalk_ir::TyKind::Ref(mutability, lifetime, ty) => {
171 TyKind::Ref(mutability, from_chalk(db, ty)) 172 TyKind::Ref(mutability, lifetime, from_chalk(db, ty))
172 } 173 }
173 chalk_ir::TyKind::Str => TyKind::Str, 174 chalk_ir::TyKind::Str => TyKind::Str,
174 chalk_ir::TyKind::Never => TyKind::Never, 175 chalk_ir::TyKind::Never => TyKind::Never,
@@ -192,10 +193,11 @@ impl ToChalk for Ty {
192fn ref_to_chalk( 193fn ref_to_chalk(
193 db: &dyn HirDatabase, 194 db: &dyn HirDatabase,
194 mutability: chalk_ir::Mutability, 195 mutability: chalk_ir::Mutability,
196 _lifetime: Lifetime,
195 ty: Ty, 197 ty: Ty,
196) -> chalk_ir::Ty<Interner> { 198) -> chalk_ir::Ty<Interner> {
197 let arg = ty.to_chalk(db); 199 let arg = ty.to_chalk(db);
198 let lifetime = LifetimeData::Static.intern(&Interner); 200 let lifetime = static_lifetime();
199 chalk_ir::TyKind::Ref(mutability, lifetime, arg).intern(&Interner) 201 chalk_ir::TyKind::Ref(mutability, lifetime, arg).intern(&Interner)
200} 202}
201 203