Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/inlay_hints.rs')
-rw-r--r--crates/ide/src/inlay_hints.rs76
1 files changed, 39 insertions, 37 deletions
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 424890fe37..d7d3171664 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -738,44 +738,46 @@ fn label_of_ty(
config: &InlayHintsConfig,
display_target: DisplayTarget,
) -> Result<(), HirDisplayError> {
- let iter_item_type = hint_iterator(sema, famous_defs, ty);
- match iter_item_type {
- Some((iter_trait, item, ty)) => {
- const LABEL_START: &str = "impl ";
- const LABEL_ITERATOR: &str = "Iterator";
- const LABEL_MIDDLE: &str = "<";
- const LABEL_ITEM: &str = "Item";
- const LABEL_MIDDLE2: &str = " = ";
- const LABEL_END: &str = ">";
-
- max_length = max_length.map(|len| {
- len.saturating_sub(
- LABEL_START.len()
- + LABEL_ITERATOR.len()
- + LABEL_MIDDLE.len()
- + LABEL_MIDDLE2.len()
- + LABEL_END.len(),
- )
- });
-
- label_builder.write_str(LABEL_START)?;
- label_builder.start_location_link(ModuleDef::from(iter_trait).into());
- label_builder.write_str(LABEL_ITERATOR)?;
- label_builder.end_location_link();
- label_builder.write_str(LABEL_MIDDLE)?;
- label_builder.start_location_link(ModuleDef::from(item).into());
- label_builder.write_str(LABEL_ITEM)?;
- label_builder.end_location_link();
- label_builder.write_str(LABEL_MIDDLE2)?;
- rec(sema, famous_defs, max_length, &ty, label_builder, config, display_target)?;
- label_builder.write_str(LABEL_END)?;
- Ok(())
+ salsa::attach(sema.db, || {
+ let iter_item_type = hint_iterator(sema, famous_defs, ty);
+ match iter_item_type {
+ Some((iter_trait, item, ty)) => {
+ const LABEL_START: &str = "impl ";
+ const LABEL_ITERATOR: &str = "Iterator";
+ const LABEL_MIDDLE: &str = "<";
+ const LABEL_ITEM: &str = "Item";
+ const LABEL_MIDDLE2: &str = " = ";
+ const LABEL_END: &str = ">";
+
+ max_length = max_length.map(|len| {
+ len.saturating_sub(
+ LABEL_START.len()
+ + LABEL_ITERATOR.len()
+ + LABEL_MIDDLE.len()
+ + LABEL_MIDDLE2.len()
+ + LABEL_END.len(),
+ )
+ });
+
+ label_builder.write_str(LABEL_START)?;
+ label_builder.start_location_link(ModuleDef::from(iter_trait).into());
+ label_builder.write_str(LABEL_ITERATOR)?;
+ label_builder.end_location_link();
+ label_builder.write_str(LABEL_MIDDLE)?;
+ label_builder.start_location_link(ModuleDef::from(item).into());
+ label_builder.write_str(LABEL_ITEM)?;
+ label_builder.end_location_link();
+ label_builder.write_str(LABEL_MIDDLE2)?;
+ rec(sema, famous_defs, max_length, &ty, label_builder, config, display_target)?;
+ label_builder.write_str(LABEL_END)?;
+ Ok(())
+ }
+ None => ty
+ .display_truncated(sema.db, max_length, display_target)
+ .with_closure_style(config.closure_style)
+ .write_to(label_builder),
}
- None => ty
- .display_truncated(sema.db, max_length, display_target)
- .with_closure_style(config.closure_style)
- .write_to(label_builder),
- }
+ })
}
let mut label_builder = InlayHintLabelBuilder {