mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Add Lifetimes to the HIR
This commit is contained in:
parent
41321d9678
commit
11f8664182
16 changed files with 249 additions and 96 deletions
|
@ -4,7 +4,7 @@ use std::fmt;
|
|||
|
||||
use crate::{
|
||||
db::HirDatabase, utils::generics, ApplicationTy, CallableDefId, FnSig, GenericPredicate,
|
||||
Obligation, OpaqueTyId, ProjectionTy, Substs, TraitRef, Ty, TypeCtor,
|
||||
Lifetime, Obligation, OpaqueTyId, ProjectionTy, Substs, TraitRef, Ty, TypeCtor,
|
||||
};
|
||||
use hir_def::{
|
||||
find_path, generics::TypeParamProvenance, item_scope::ItemInNs, AdtId, AssocContainerId,
|
||||
|
@ -710,6 +710,19 @@ impl HirDisplay for GenericPredicate {
|
|||
}
|
||||
}
|
||||
|
||||
impl HirDisplay for Lifetime {
|
||||
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
|
||||
match self {
|
||||
Lifetime::Parameter(id) => {
|
||||
let generics = generics(f.db.upcast(), id.parent);
|
||||
let param_data = &generics.params.lifetimes[id.local_id];
|
||||
write!(f, "{}", ¶m_data.name)
|
||||
}
|
||||
Lifetime::Static => write!(f, "'static"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl HirDisplay for Obligation {
|
||||
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
|
||||
match self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue