diff options
author | Lukas Wirth <[email protected]> | 2021-04-05 19:46:15 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-04-05 19:46:15 +0100 |
commit | d587ca2991406bd348768b2912c3cb66c869e7e8 (patch) | |
tree | 91f0421f3ca76f846548017d8a6c5a4b142b96bc /crates/hir_ty/src/display.rs | |
parent | 87e56eb94ced9943977a38e7d4c6697587187ce6 (diff) |
Replace unused hir_ty::Lifetime with chalk equivalents
Diffstat (limited to 'crates/hir_ty/src/display.rs')
-rw-r--r-- | crates/hir_ty/src/display.rs | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index f31e6b108..01c7ef91f 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -1,8 +1,10 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use std::{array, fmt}; | 3 | use std::{ |
4 | array, | ||
5 | fmt::{self, Debug}, | ||
6 | }; | ||
4 | 7 | ||
5 | use chalk_ir::Mutability; | ||
6 | use hir_def::{ | 8 | use hir_def::{ |
7 | db::DefDatabase, | 9 | db::DefDatabase, |
8 | find_path, | 10 | find_path, |
@@ -16,9 +18,10 @@ use hir_def::{ | |||
16 | use hir_expand::name::Name; | 18 | use hir_expand::name::Name; |
17 | 19 | ||
18 | use crate::{ | 20 | use crate::{ |
19 | db::HirDatabase, from_assoc_type_id, from_foreign_def_id, from_placeholder_idx, primitive, | 21 | db::HirDatabase, from_assoc_type_id, from_foreign_def_id, from_placeholder_idx, |
20 | to_assoc_type_id, traits::chalk::from_chalk, utils::generics, AdtId, AliasEq, AliasTy, | 22 | lt_from_placeholder_idx, primitive, to_assoc_type_id, traits::chalk::from_chalk, |
21 | CallableDefId, CallableSig, DomainGoal, GenericArg, ImplTraitId, Interner, Lifetime, OpaqueTy, | 23 | utils::generics, AdtId, AliasEq, AliasTy, CallableDefId, CallableSig, DomainGoal, GenericArg, |
24 | ImplTraitId, Interner, Lifetime, LifetimeData, LifetimeOutlives, Mutability, OpaqueTy, | ||
22 | ProjectionTy, QuantifiedWhereClause, Scalar, TraitRef, Ty, TyExt, TyKind, WhereClause, | 25 | ProjectionTy, QuantifiedWhereClause, Scalar, TraitRef, Ty, TyExt, TyKind, WhereClause, |
23 | }; | 26 | }; |
24 | 27 | ||
@@ -827,15 +830,35 @@ impl HirDisplay for WhereClause { | |||
827 | } | 830 | } |
828 | } | 831 | } |
829 | 832 | ||
833 | impl HirDisplay for LifetimeOutlives { | ||
834 | fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> { | ||
835 | self.a.hir_fmt(f)?; | ||
836 | write!(f, ": ")?; | ||
837 | self.b.hir_fmt(f) | ||
838 | } | ||
839 | } | ||
840 | |||
830 | impl HirDisplay for Lifetime { | 841 | impl HirDisplay for Lifetime { |
831 | fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> { | 842 | fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> { |
843 | self.interned().hir_fmt(f) | ||
844 | } | ||
845 | } | ||
846 | |||
847 | impl HirDisplay for LifetimeData { | ||
848 | fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> { | ||
832 | match self { | 849 | match self { |
833 | Lifetime::Parameter(id) => { | 850 | LifetimeData::BoundVar(idx) => write!(f, "?{}.{}", idx.debruijn.depth(), idx.index), |
851 | LifetimeData::InferenceVar(_) => write!(f, "_"), | ||
852 | LifetimeData::Placeholder(idx) => { | ||
853 | let id = lt_from_placeholder_idx(f.db, *idx); | ||
834 | let generics = generics(f.db.upcast(), id.parent); | 854 | let generics = generics(f.db.upcast(), id.parent); |
835 | let param_data = &generics.params.lifetimes[id.local_id]; | 855 | let param_data = &generics.params.lifetimes[id.local_id]; |
836 | write!(f, "{}", ¶m_data.name) | 856 | write!(f, "{}", param_data.name) |
837 | } | 857 | } |
838 | Lifetime::Static => write!(f, "'static"), | 858 | LifetimeData::Static => write!(f, "'static"), |
859 | LifetimeData::Empty(_) => Ok(()), | ||
860 | LifetimeData::Erased => Ok(()), | ||
861 | LifetimeData::Phantom(_, _) => Ok(()), | ||
839 | } | 862 | } |
840 | } | 863 | } |
841 | } | 864 | } |