From 96756f1b1df4729fd00ca96a59971b3997c91934 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 5 Apr 2021 22:08:16 +0200 Subject: Add Lifetime to TyKind::Ref --- crates/hir_ty/src/lower.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'crates/hir_ty/src/lower.rs') diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 3cbb6ad54..5a769fa6a 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -34,7 +34,7 @@ use crate::{ variant_data, Generics, }, AliasEq, AliasTy, Binders, BoundVar, CallableSig, DebruijnIndex, DynTy, FnPointer, FnSig, - FnSubst, ImplTraitId, OpaqueTy, PolyFnSig, ProjectionTy, QuantifiedWhereClause, + FnSubst, ImplTraitId, LifetimeData, OpaqueTy, PolyFnSig, ProjectionTy, QuantifiedWhereClause, QuantifiedWhereClauses, ReturnTypeImplTrait, ReturnTypeImplTraits, Substitution, TraitEnvironment, TraitRef, Ty, TyBuilder, TyKind, TypeWalk, WhereClause, }; @@ -174,7 +174,9 @@ impl<'a> TyLoweringContext<'a> { } TypeRef::Reference(inner, _, mutability) => { let inner_ty = self.lower_ty(inner); - TyKind::Ref(lower_to_chalk_mutability(*mutability), inner_ty).intern(&Interner) + let lifetime = LifetimeData::Static.intern(&Interner); + TyKind::Ref(lower_to_chalk_mutability(*mutability), lifetime, inner_ty) + .intern(&Interner) } TypeRef::Placeholder => TyKind::Error.intern(&Interner), TypeRef::Fn(params, is_varargs) => { -- cgit v1.2.3 From 9da191c7e07abec9d9f056fd94ee151aef7417a7 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 5 Apr 2021 22:12:40 +0200 Subject: Add Lifetime to DynTy --- crates/hir_ty/src/lower.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates/hir_ty/src/lower.rs') diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 5a769fa6a..ff795377a 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -200,7 +200,8 @@ impl<'a> TyLoweringContext<'a> { ) }); let bounds = crate::make_only_type_binders(1, bounds); - TyKind::Dyn(DynTy { bounds }).intern(&Interner) + TyKind::Dyn(DynTy { bounds, lifetime: LifetimeData::Static.intern(&Interner) }) + .intern(&Interner) } TypeRef::ImplTrait(bounds) => { match self.impl_trait_mode { @@ -392,6 +393,7 @@ impl<'a> TyLoweringContext<'a> { ))), ), ), + lifetime: LifetimeData::Static.intern(&Interner), }; TyKind::Dyn(dyn_ty).intern(&Interner) }; -- cgit v1.2.3 From 08dc69599efb4961319c0118b789d3abb264b7fa Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 6 Apr 2021 10:50:55 +0200 Subject: Use a constructor function for Static lifetimes --- crates/hir_ty/src/lower.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'crates/hir_ty/src/lower.rs') diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index ff795377a..df6619af3 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -27,14 +27,14 @@ use stdx::impl_from; use crate::{ db::HirDatabase, - to_assoc_type_id, to_chalk_trait_id, to_placeholder_idx, + static_lifetime, to_assoc_type_id, to_chalk_trait_id, to_placeholder_idx, traits::chalk::{Interner, ToChalk}, utils::{ all_super_trait_refs, associated_type_by_name_including_super_traits, generics, variant_data, Generics, }, AliasEq, AliasTy, Binders, BoundVar, CallableSig, DebruijnIndex, DynTy, FnPointer, FnSig, - FnSubst, ImplTraitId, LifetimeData, OpaqueTy, PolyFnSig, ProjectionTy, QuantifiedWhereClause, + FnSubst, ImplTraitId, OpaqueTy, PolyFnSig, ProjectionTy, QuantifiedWhereClause, QuantifiedWhereClauses, ReturnTypeImplTrait, ReturnTypeImplTraits, Substitution, TraitEnvironment, TraitRef, Ty, TyBuilder, TyKind, TypeWalk, WhereClause, }; @@ -174,7 +174,7 @@ impl<'a> TyLoweringContext<'a> { } TypeRef::Reference(inner, _, mutability) => { let inner_ty = self.lower_ty(inner); - let lifetime = LifetimeData::Static.intern(&Interner); + let lifetime = static_lifetime(); TyKind::Ref(lower_to_chalk_mutability(*mutability), lifetime, inner_ty) .intern(&Interner) } @@ -200,8 +200,7 @@ impl<'a> TyLoweringContext<'a> { ) }); let bounds = crate::make_only_type_binders(1, bounds); - TyKind::Dyn(DynTy { bounds, lifetime: LifetimeData::Static.intern(&Interner) }) - .intern(&Interner) + TyKind::Dyn(DynTy { bounds, lifetime: static_lifetime() }).intern(&Interner) } TypeRef::ImplTrait(bounds) => { match self.impl_trait_mode { @@ -393,7 +392,7 @@ impl<'a> TyLoweringContext<'a> { ))), ), ), - lifetime: LifetimeData::Static.intern(&Interner), + lifetime: static_lifetime(), }; TyKind::Dyn(dyn_ty).intern(&Interner) }; -- cgit v1.2.3