Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/body/pretty.rs')
| -rw-r--r-- | crates/hir-def/src/body/pretty.rs | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/crates/hir-def/src/body/pretty.rs b/crates/hir-def/src/body/pretty.rs index 601878e8e7..a389a283b5 100644 --- a/crates/hir-def/src/body/pretty.rs +++ b/crates/hir-def/src/body/pretty.rs @@ -18,27 +18,21 @@ use super::*; pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBodyId) -> String { let header = match owner { DefWithBodyId::FunctionId(it) => { - let item_tree_id = it.lookup(db).id; - format!( - "fn {}", - item_tree_id.item_tree(db)[item_tree_id.value].name.display(db.upcast()) - ) + it.lookup(db).id.resolved(db, |it| format!("fn {} = ", it.name.display(db.upcast()))) } - DefWithBodyId::StaticId(it) => { - let item_tree_id = it.lookup(db).id; + DefWithBodyId::StaticId(it) => it + .lookup(db) + .id + .resolved(db, |it| format!("static {} = ", it.name.display(db.upcast()))), + DefWithBodyId::ConstId(it) => it.lookup(db).id.resolved(db, |it| { format!( - "static {} = ", - item_tree_id.item_tree(db)[item_tree_id.value].name.display(db.upcast()) + "const {} = ", + match &it.name { + Some(name) => name.display(db.upcast()).to_string(), + None => "_".to_string(), + } ) - } - DefWithBodyId::ConstId(it) => { - let item_tree_id = it.lookup(db).id; - let name = match &item_tree_id.item_tree(db)[item_tree_id.value].name { - Some(name) => name.display(db.upcast()).to_string(), - None => "_".to_string(), - }; - format!("const {name} = ") - } + }), DefWithBodyId::InTypeConstId(_) => format!("In type const = "), DefWithBodyId::VariantId(it) => { let loc = it.lookup(db); |