Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/view_memory_layout.rs')
-rw-r--r--crates/ide/src/view_memory_layout.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/crates/ide/src/view_memory_layout.rs b/crates/ide/src/view_memory_layout.rs
index 950f3f6c64..47ca616f31 100644
--- a/crates/ide/src/view_memory_layout.rs
+++ b/crates/ide/src/view_memory_layout.rs
@@ -3,7 +3,6 @@ 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},
};
@@ -99,7 +98,7 @@ pub(crate) fn view_memory_layout(
Definition::BuiltinType(it) => it.ty(db),
Definition::SelfType(it) => it.self_ty(db),
Definition::Local(it) => it.ty(db),
- Definition::Field(it) => it.ty(db),
+ Definition::Field(it) => it.ty(db).to_type(db),
Definition::Const(it) => it.ty(db),
Definition::Static(it) => it.ty(db),
_ => return None,
@@ -139,12 +138,10 @@ pub(crate) fn view_memory_layout(
nodes[parent_idx].children_len = fields.len() as u64;
for (field, child_ty) in fields.iter() {
- if let Ok(child_layout) = salsa::attach(db, || child_ty.layout(db)) {
+ if let Ok(child_layout) = child_ty.layout(db) {
nodes.push(MemoryLayoutNode {
item_name: field.name(db),
- typename: salsa::attach(db, || {
- child_ty.display(db, display_target).to_string()
- }),
+ typename: { child_ty.display(db, display_target).to_string() },
size: child_layout.size(),
alignment: child_layout.align(),
offset: match *field {
@@ -172,13 +169,13 @@ pub(crate) fn view_memory_layout(
}
for (i, (_, child_ty)) in fields.iter().enumerate() {
- if let Ok(child_layout) = salsa::attach(db, || child_ty.layout(db)) {
+ if let Ok(child_layout) = child_ty.layout(db) {
read_layout(nodes, db, child_ty, &child_layout, children_start + i, display_target);
}
}
}
- salsa::attach(db, || ty.layout(db))
+ ty.layout(db)
.map(|layout| {
let item_name = match def {
// def is a datatype
@@ -191,7 +188,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 = salsa::attach(db, || ty.display(db, display_target).to_string());
+ let typename = ty.display(db, display_target).to_string();
let mut nodes = vec![MemoryLayoutNode {
item_name,
@@ -222,7 +219,7 @@ mod tests {
) -> Option<RecursiveMemoryLayout> {
let (analysis, position, _) = fixture::annotations(ra_fixture);
- view_memory_layout(&analysis.db, position)
+ hir::attach_db(&analysis.db, || view_memory_layout(&analysis.db, position))
}
#[test]