impl HirDisplay for next_solver::Ty

This commit is contained in:
jackh726 2025-08-09 23:28:48 +00:00
parent b2f107cb8b
commit eeaefa4b9d
24 changed files with 580 additions and 388 deletions

View file

@ -3,6 +3,7 @@ use std::fmt;
use hir::{DisplayTarget, Field, HirDisplay, Layout, Semantics, Type};
use ide_db::{
RootDatabase,
base_db::salsa,
defs::Definition,
helpers::{get_definition, pick_best_token},
};
@ -141,7 +142,9 @@ pub(crate) fn view_memory_layout(
if let Ok(child_layout) = child_ty.layout(db) {
nodes.push(MemoryLayoutNode {
item_name: field.name(db),
typename: child_ty.display(db, display_target).to_string(),
typename: salsa::attach(db, || {
child_ty.display(db, display_target).to_string()
}),
size: child_layout.size(),
alignment: child_layout.align(),
offset: match *field {
@ -175,7 +178,7 @@ pub(crate) fn view_memory_layout(
}
}
ty.layout(db)
salsa::attach(db, || ty.layout(db))
.map(|layout| {
let item_name = match def {
// def is a datatype
@ -188,7 +191,7 @@ pub(crate) fn view_memory_layout(
def => def.name(db).map(|n| n.as_str().to_owned()).unwrap_or("[ROOT]".to_owned()),
};
let typename = ty.display(db, display_target).to_string();
let typename = salsa::attach(db, || ty.display(db, display_target).to_string());
let mut nodes = vec![MemoryLayoutNode {
item_name,