mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Replace unused hir_ty::Lifetime with chalk equivalents
This commit is contained in:
parent
87e56eb94c
commit
d587ca2991
4 changed files with 50 additions and 18 deletions
|
@ -1,8 +1,10 @@
|
|||
//! FIXME: write short doc here
|
||||
|
||||
use std::{array, fmt};
|
||||
use std::{
|
||||
array,
|
||||
fmt::{self, Debug},
|
||||
};
|
||||
|
||||
use chalk_ir::Mutability;
|
||||
use hir_def::{
|
||||
db::DefDatabase,
|
||||
find_path,
|
||||
|
@ -16,9 +18,10 @@ use hir_def::{
|
|||
use hir_expand::name::Name;
|
||||
|
||||
use crate::{
|
||||
db::HirDatabase, from_assoc_type_id, from_foreign_def_id, from_placeholder_idx, primitive,
|
||||
to_assoc_type_id, traits::chalk::from_chalk, utils::generics, AdtId, AliasEq, AliasTy,
|
||||
CallableDefId, CallableSig, DomainGoal, GenericArg, ImplTraitId, Interner, Lifetime, OpaqueTy,
|
||||
db::HirDatabase, from_assoc_type_id, from_foreign_def_id, from_placeholder_idx,
|
||||
lt_from_placeholder_idx, primitive, to_assoc_type_id, traits::chalk::from_chalk,
|
||||
utils::generics, AdtId, AliasEq, AliasTy, CallableDefId, CallableSig, DomainGoal, GenericArg,
|
||||
ImplTraitId, Interner, Lifetime, LifetimeData, LifetimeOutlives, Mutability, OpaqueTy,
|
||||
ProjectionTy, QuantifiedWhereClause, Scalar, TraitRef, Ty, TyExt, TyKind, WhereClause,
|
||||
};
|
||||
|
||||
|
@ -827,15 +830,35 @@ impl HirDisplay for WhereClause {
|
|||
}
|
||||
}
|
||||
|
||||
impl HirDisplay for LifetimeOutlives {
|
||||
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
|
||||
self.a.hir_fmt(f)?;
|
||||
write!(f, ": ")?;
|
||||
self.b.hir_fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl HirDisplay for Lifetime {
|
||||
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
|
||||
self.interned().hir_fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl HirDisplay for LifetimeData {
|
||||
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
|
||||
match self {
|
||||
Lifetime::Parameter(id) => {
|
||||
LifetimeData::BoundVar(idx) => write!(f, "?{}.{}", idx.debruijn.depth(), idx.index),
|
||||
LifetimeData::InferenceVar(_) => write!(f, "_"),
|
||||
LifetimeData::Placeholder(idx) => {
|
||||
let id = lt_from_placeholder_idx(f.db, *idx);
|
||||
let generics = generics(f.db.upcast(), id.parent);
|
||||
let param_data = &generics.params.lifetimes[id.local_id];
|
||||
write!(f, "{}", ¶m_data.name)
|
||||
write!(f, "{}", param_data.name)
|
||||
}
|
||||
Lifetime::Static => write!(f, "'static"),
|
||||
LifetimeData::Static => write!(f, "'static"),
|
||||
LifetimeData::Empty(_) => Ok(()),
|
||||
LifetimeData::Erased => Ok(()),
|
||||
LifetimeData::Phantom(_, _) => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue