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/method_resolution.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'crates/hir_ty/src/method_resolution.rs') diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 6d65d3eb9..427844c12 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -21,8 +21,8 @@ use crate::{ primitive::{self, FloatTy, IntTy, UintTy}, utils::all_super_traits, AdtId, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSig, ForeignDefId, - InEnvironment, Interner, Scalar, Substitution, TraitEnvironment, Ty, TyBuilder, TyKind, - TypeWalk, + InEnvironment, Interner, LifetimeData, Scalar, Substitution, TraitEnvironment, Ty, TyBuilder, + TyKind, TypeWalk, }; /// This is used as a key for indexing impls. @@ -453,7 +453,12 @@ fn iterate_method_candidates_with_autoref( } let refed = Canonical { binders: deref_chain[0].binders.clone(), - value: TyKind::Ref(Mutability::Not, deref_chain[0].value.clone()).intern(&Interner), + value: TyKind::Ref( + Mutability::Not, + LifetimeData::Static.intern(&Interner), + deref_chain[0].value.clone(), + ) + .intern(&Interner), }; if iterate_method_candidates_by_receiver( &refed, @@ -470,7 +475,12 @@ fn iterate_method_candidates_with_autoref( } let ref_muted = Canonical { binders: deref_chain[0].binders.clone(), - value: TyKind::Ref(Mutability::Mut, deref_chain[0].value.clone()).intern(&Interner), + value: TyKind::Ref( + Mutability::Mut, + LifetimeData::Static.intern(&Interner), + deref_chain[0].value.clone(), + ) + .intern(&Interner), }; if iterate_method_candidates_by_receiver( &ref_muted, -- 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/method_resolution.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'crates/hir_ty/src/method_resolution.rs') diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 427844c12..436dea22b 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -19,10 +19,11 @@ use crate::{ db::HirDatabase, from_foreign_def_id, primitive::{self, FloatTy, IntTy, UintTy}, + static_lifetime, utils::all_super_traits, AdtId, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSig, ForeignDefId, - InEnvironment, Interner, LifetimeData, Scalar, Substitution, TraitEnvironment, Ty, TyBuilder, - TyKind, TypeWalk, + InEnvironment, Interner, Scalar, Substitution, TraitEnvironment, Ty, TyBuilder, TyKind, + TypeWalk, }; /// This is used as a key for indexing impls. @@ -453,12 +454,8 @@ fn iterate_method_candidates_with_autoref( } let refed = Canonical { binders: deref_chain[0].binders.clone(), - value: TyKind::Ref( - Mutability::Not, - LifetimeData::Static.intern(&Interner), - deref_chain[0].value.clone(), - ) - .intern(&Interner), + value: TyKind::Ref(Mutability::Not, static_lifetime(), deref_chain[0].value.clone()) + .intern(&Interner), }; if iterate_method_candidates_by_receiver( &refed, @@ -475,12 +472,8 @@ fn iterate_method_candidates_with_autoref( } let ref_muted = Canonical { binders: deref_chain[0].binders.clone(), - value: TyKind::Ref( - Mutability::Mut, - LifetimeData::Static.intern(&Interner), - deref_chain[0].value.clone(), - ) - .intern(&Interner), + value: TyKind::Ref(Mutability::Mut, static_lifetime(), deref_chain[0].value.clone()) + .intern(&Interner), }; if iterate_method_candidates_by_receiver( &ref_muted, -- cgit v1.2.3