about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukas@zed.dev>2025-08-13 09:42:32 +0200
committerLukas Wirth <lukas@zed.dev>2025-08-13 09:42:50 +0200
commit4bbbe6ee2b0c3c630d605c47ba0d4215d2522240 (patch)
treeffd52c87f94dfa518824c0a011f838aa22d8d397
parent6e4644fd31d3bd1e0ece59112d84f9c7ed1ebb67 (diff)
downloadrust-4bbbe6ee2b0c3c630d605c47ba0d4215d2522240.tar.gz
rust-4bbbe6ee2b0c3c630d605c47ba0d4215d2522240.zip
fix: Attach db for inlay hint compute
-rw-r--r--src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs2
-rw-r--r--src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs18
2 files changed, 11 insertions, 9 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs
index 9c1bd52065f..54fec4aefbd 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs
@@ -289,7 +289,7 @@ impl<'db> DbInterner<'db> {
             krate: None,
             block: None,
         })
-        .unwrap()
+        .expect("db is expected to be attached")
     }
 
     pub fn new_with(
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs
index f6416fe51c3..424890fe370 100644
--- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs
@@ -107,14 +107,16 @@ pub(crate) fn inlay_hints(
         }
     };
     let mut preorder = file.preorder();
-    while let Some(event) = preorder.next() {
-        if matches!((&event, range_limit), (WalkEvent::Enter(node), Some(range)) if range.intersect(node.text_range()).is_none())
-        {
-            preorder.skip_subtree();
-            continue;
+    salsa::attach(sema.db, || {
+        while let Some(event) = preorder.next() {
+            if matches!((&event, range_limit), (WalkEvent::Enter(node), Some(range)) if range.intersect(node.text_range()).is_none())
+            {
+                preorder.skip_subtree();
+                continue;
+            }
+            hints(event);
         }
-        hints(event);
-    }
+    });
     if let Some(range_limit) = range_limit {
         acc.retain(|hint| range_limit.contains_range(hint.range));
     }
@@ -736,7 +738,7 @@ fn label_of_ty(
         config: &InlayHintsConfig,
         display_target: DisplayTarget,
     ) -> Result<(), HirDisplayError> {
-        let iter_item_type = salsa::attach(sema.db, || hint_iterator(sema, famous_defs, ty));
+        let iter_item_type = hint_iterator(sema, famous_defs, ty);
         match iter_item_type {
             Some((iter_trait, item, ty)) => {
                 const LABEL_START: &str = "impl ";