Repository: rust-lang/rust-analyzer
Pull request #12314 (2022-05-19 14:49:58)

minor: simplify


Patch:
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 3cb60d9e44..bf82e83822 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -57,19 +57,19 @@ pub enum InlayKind {
     TypeHint,
 }
 
+// FIXME: This should live somewhere more general
+#[derive(Debug)]
+pub enum RangeOrOffset {
+    Range(TextRange),
+    Offset(TextSize),
+}
+
 #[derive(Debug)]
 pub struct InlayHint {
     pub range: TextRange,
     pub kind: InlayKind,
     pub label: String,
-    pub tooltip: Option<InlayTooltip>,
-}
-
-#[derive(Debug)]
-pub enum InlayTooltip {
-    String(String),
-    HoverRanged(FileId, TextRange),
-    HoverOffset(FileId, TextSize),
+    pub hover_trigger: Option<RangeOrOffset>,
 }
 
 // Feature: Inlay Hints
@@ -109,7 +109,7 @@ pub(crate) fn inlay_hints(
 
     let mut acc = Vec::new();
 
-    let hints = |node| hints(&mut acc, &sema, config, file_id, node);
+    let hints = |node| hints(&mut acc, &sema, config, node);
     match range_limit {
         Some(FileRange { range, .. }) => match file.covering_element(range) {
             NodeOrToken::Token(_) => return acc,
@@ -128,7 +128,6 @@ fn hints(
     hints: &mut Vec<InlayHint>,
     sema: &Semantics<RootDatabase>,
     config: &InlayHintsConfig,
-    file_id: FileId,
     node: SyntaxNode,
 ) {
     let famous_defs = match sema.scope(&node) {
@@ -136,17 +135,17 @@ fn hints(
         None => return,
     };
 
-    closing_brace_hints(hints, sema, config, file_id, node.clone());
+    closing_brace_hints(hints, sema, config, node.clone());
     match_ast! {
         match node {
             ast::Expr(expr) => {
-                chaining_hints(hints, sema, &famous_defs, config, file_id, &expr);
+                chaining_hints(hints, sema, &famous_defs, config, &expr);
                 match expr {
                     ast::Expr::CallExpr(it) => param_name_hints(hints, sema, config, ast::Expr::from(it)),
                     ast::Expr::MethodCallExpr(it) => {
                         param_name_hints(hints, sema, config, ast::Expr::from(it))
                     }
-                    ast::Expr::ClosureExpr(it) => closure_ret_hints(hints, sema, &famous_defs, config, file_id, it),
+                    ast::Expr::ClosureExpr(it) => closure_ret_hints(hints, sema, &famous_defs, config, it),
                     // We could show reborrows for all expressions, but usually that is just noise to the user
                     // and the main point here is to show why "moving" a mutable reference doesn't necessarily move it
                     ast::Expr::PathExpr(_) => reborrow_hints(hints, sema, config, &expr),
@@ -156,7 +155,7 @@ fn hints(
             ast::Pat(it) => {
                 binding_mode_hints(hints, sema, config, &it);
                 if let ast::Pat::IdentPat(it) = it {
-                    bind_pat_hints(hints, sema, config, file_id, &it);
+                    bind_pat_hints(hints, sema, config, &it);
                 }
                 Some(())
             },
@@ -170,7 +169,6 @@ fn closing_brace_hints(
     acc: &mut Vec<InlayHint>,
     sema: &Semantics<RootDatabase>,
     config: &InlayHintsConfig,
-    file_id: FileId,
     node: SyntaxNode,
 ) -> Option<()> {
     let min_lines = config.closing_brace_hints_min_lines?;
@@ -265,7 +263,7 @@ fn closing_brace_hints(
         range: closing_token.text_range(),
         kind: InlayKind::ClosingBraceHint,
         label,
-        tooltip: name_offset.map(|it| InlayTooltip::HoverOffset(file_id, it)),
+        hover_trigger: name_offset.map(RangeOrOffset::Offset),
     });
 
     None
@@ -284,7 +282,7 @@ fn lifetime_fn_hints(
         range: t.text_range(),
         kind: InlayKind::LifetimeHint,
         label,
-        tooltip: Some(InlayTooltip::String("Elided lifetime".into())),
+        hover_trigger: None,
     };
 
     let param_list = func.param_list()?;
@@ -430,22 +428,20 @@ fn lifetime_fn_hints(
         (Some(gpl), allocated_lifetimes) => {
             let angle_tok = gpl.l_angle_token()?;
             let is_empty = gpl.generic_params().next().is_none();
-            acc.push(InlayHint {
-                range: angle_tok.text_range(),
-                kind: InlayKind::LifetimeHint,
-                label: format!(
+            acc.push(mk_lt_hint(
+                angle_tok,
+                format!(
                     "{}{}",
                     allocated_lifetimes.iter().format(", "),
                     if is_empty { "" } else { ", " }
                 ),
-                tooltip: Some(InlayTooltip::String("Elided lifetimes".into())),
-            });
+            ));
         }
         (None, allocated_lifetimes) => acc.push(InlayHint {
             range: func.name()?.syntax().text_range(),
             kind: InlayKind::GenericParamListHint,
             label: format!("<{}>", allocated_lifetimes.iter().format(", "),).into(),
-            tooltip: Some(InlayTooltip::String("Elided lifetimes".into())),
+            hover_trigger: None,
         }),
     }
     Some(())
@@ -456,7 +452,6 @@ fn closure_ret_hints(
     sema: &Semantics<RootDatabase>,
     famous_defs: &FamousDefs,
     config: &InlayHintsConfig,
-    file_id: FileId,
     closure: ast::ClosureExpr,
 ) -> Option<()> {
     if !config.closure_return_type_hints {
@@ -480,7 +475,7 @@ fn closure_ret_hints(
         kind: InlayKind::ClosureReturnTypeHint,
         label: hint_iterator(sema, &famous_defs, config, &ty)
             .unwrap_or_else(|| ty.display_truncated(sema.db, config.max_length).to_string()),
-        tooltip: Some(InlayTooltip::HoverRanged(file_id, param_list.syntax().text_range())),
+        hover_trigger: None,
     });
     Some(())
 }
@@ -507,7 +502,7 @@ fn reborrow_hints(
         range: expr.syntax().text_range(),
         kind: InlayKind::ImplicitReborrowHint,
         label: label.to_string(),
-        tooltip: Some(InlayTooltip::String("Compiler inserted reborrow".into())),
+        hover_trigger: None,
     });
     Some(())
 }
@@ -517,7 +512,6 @@ fn chaining_hints(
     sema: &Semantics<RootDatabase>,
     famous_defs: &FamousDefs,
     config: &InlayHintsConfig,
-    file_id: FileId,
     expr: &ast::Expr,
 ) -> Option<()> {
     if !config.chaining_hints {
@@ -567,7 +561,7 @@ fn chaining_hints(
                 label: hint_iterator(sema, &famous_defs, config, &ty).unwrap_or_else(|| {
                     ty.display_truncated(sema.db, config.max_length).to_string()
                 }),
-                tooltip: Some(InlayTooltip::HoverRanged(file_id, expr.syntax().text_range())),
+                hover_trigger: Some(RangeOrOffset::Range(expr.syntax().text_range())),
             });
         }
     }
@@ -592,35 +586,24 @@ fn param_name_hints(
         .filter_map(|((param, _ty), arg)| {
             // Only annotate hints for expressions that exist in the original file
             let range = sema.original_range_opt(arg.syntax())?;
-            let (param_name, name_syntax) = match param.as_ref()? {
-                Either::Left(pat) => ("self".to_string(), pat.name()),
+            let param_name = match param? {
+                Either::Left(_) => "self".to_string(),
                 Either::Right(pat) => match pat {
-                    ast::Pat::IdentPat(it) => (it.name()?.to_string(), it.name()),
+                    ast::Pat::IdentPat(it) => it.name()?.to_string(),
                     _ => return None,
                 },
             };
-            Some((name_syntax, param_name, arg, range))
+            Some((param_name, arg, range))
         })
-        .filter(|(_, param_name, arg, _)| {
+        .filter(|(param_name, arg, _)| {
             !should_hide_param_name_hint(sema, &callable, param_name, arg)
         })
-        .map(|(param, param_name, _, FileRange { range, .. })| {
-            let mut tooltip = None;
-            if let Some(name) = param {
-                if let hir::CallableKind::Function(f) = callable.kind() {
-                    // assert the file is cached so we can map out of macros
-                    if let Some(_) = sema.source(f) {
-                        tooltip = sema.original_range_opt(name.syntax());
-                    }
-                }
-            }
-
-            InlayHint {
-                range,
-                kind: InlayKind::ParameterHint,
-                label: param_name,
-                tooltip: tooltip.map(|it| InlayTooltip::HoverOffset(it.file_id, it.range.start())),
-            }
+        .map(|(param_name, _, FileRange { range, .. })| InlayHint {
+            range,
+            kind: InlayKind::ParameterHint,
+            label: param_name.into(),
+            // FIXME: Show hover for parameter
+            hover_trigger: None,
         });
 
     acc.extend(hints);
@@ -650,7 +633,7 @@ fn binding_mode_hints(
             range,
             kind: InlayKind::BindingModeHint,
             label: r.to_string(),
-            tooltip: Some(InlayTooltip::String("Inferred binding mode".into())),
+            hover_trigger: None,
         });
     });
     match pat {
@@ -665,7 +648,7 @@ fn binding_mode_hints(
                 range,
                 kind: InlayKind::BindingModeHint,
                 label: bm.to_string(),
-                tooltip: Some(InlayTooltip::String("Inferred binding mode".into())),
+                hover_trigger: None,
             });
         }
         _ => (),
@@ -678,7 +661,6 @@ fn bind_pat_hints(
     acc: &mut Vec<InlayHint>,
     sema: &Semantics<RootDatabase>,
     config: &InlayHintsConfig,
-    file_id: FileId,
     pat: &ast::IdentPat,
 ) -> Option<()> {
     if !config.type_hints {
@@ -717,10 +699,7 @@ fn bind_pat_hints(
         },
         kind: InlayKind::TypeHint,
         label,
-        tooltip: pat
-            .name()
-            .map(|it| it.syntax().text_range())
-            .map(|it| InlayTooltip::HoverRanged(file_id, it)),
+        hover_trigger: pat.name().map(|it| it.syntax().text_range()).map(RangeOrOffset::Range),
     });
 
     Some(())
@@ -894,7 +873,7 @@ fn should_hide_param_name_hint(
     // These are to be tested in the `parameter_hint_heuristics` test
     // hide when:
     // - the parameter name is a suffix of the function's name
-    // - the argument is a qualified constructing or call expression where the qualifier is an ADT
+    // - the argument is an enum whose name is equal to the parameter
     // - exact argument<->parameter match(ignoring leading underscore) or parameter is a prefix/suffix
     //   of argument with _ splitting it off
     // - param starts with `ra_fixture`
@@ -915,10 +894,10 @@ fn should_hide_param_name_hint(
     };
     let fn_name = fn_name.as_deref();
     is_param_name_suffix_of_fn_name(param_name, callable, fn_name)
+        || is_enum_name_similar_to_param_name(sema, argument, param_name)
         || is_argument_similar_to_param_name(argument, param_name)
         || param_name.starts_with("ra_fixture")
         || (callable.n_params() == 1 && is_obvious_param(param_name))
-        || is_adt_constructor_similar_to_param_name(sema, argument, param_name)
 }
 
 fn is_argument_similar_to_param_name(argument: &ast::Expr, param_name: &str) -> bool {
@@ -974,43 +953,17 @@ fn is_param_name_suffix_of_fn_name(
     }
 }
 
-fn is_adt_constructor_similar_to_param_name(
+fn is_enum_name_similar_to_param_name(
     sema: &Semantics<RootDatabase>,
     argument: &ast::Expr,
     param_name: &str,
 ) -> bool {
-    let path = match argument {
-        ast::Expr::CallExpr(c) => c.expr().and_then(|e| match e {
-            ast::Expr::PathExpr(p) => p.path(),
-            _ => None,
-        }),
-        ast::Expr::PathExpr(p) => p.path(),
-        ast::Expr::RecordExpr(r) => r.path(),
-        _ => return false,
-    };
-    let path = match path {
-        Some(it) => it,
-        None => return false,
-    };
-    (|| match sema.resolve_path(&path)? {
-        hir::PathResolution::Def(hir::ModuleDef::Adt(_)) => {
-            Some(to_lower_snake_case(&path.segment()?.name_ref()?.text()) == param_name)
+    match sema.type_of_expr(argument).and_then(|t| t.original.as_adt()) {
+        Some(hir::Adt::Enum(e)) => {
+            to_lower_snake_case(&e.name(sema.db).to_smol_str()) == param_name
         }
-        hir::PathResolution::Def(hir::ModuleDef::Function(_) | hir::ModuleDef::Variant(_)) => {
-            if to_lower_snake_case(&path.segment()?.name_ref()?.text()) == param_name {
-                return Some(true);
-            }
-            let qual = path.qualifier()?;
-            match sema.resolve_path(&qual)? {
-                hir::PathResolution::Def(hir::ModuleDef::Adt(_)) => {
-                    Some(to_lower_snake_case(&qual.segment()?.name_ref()?.text()) == param_name)
-                }
-                _ => None,
-            }
-        }
-        _ => None,
-    })()
-    .unwrap_or(false)
+        _ => false,
+    }
 }
 
 fn get_string_representation(expr: &ast::Expr) -> Option<String> {
@@ -1335,6 +1288,7 @@ fn main() {
                //^^ self  ^^^^ param
     Test::from_syntax(
         FileId {},
+      //^^^^^^^^^ file_id
         "impl".into(),
       //^^^^^^^^^^^^^ name
         None,
@@ -2058,11 +2012,8 @@ fn main() {
                         range: 147..172,
                         kind: ChainingHint,
                         label: "B",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 147..172,
                             ),
                         ),
@@ -2071,11 +2022,8 @@ fn main() {
                         range: 147..154,
                         kind: ChainingHint,
                         label: "A",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 147..154,
                             ),
                         ),
@@ -2129,11 +2077,8 @@ fn main() {
                         range: 143..190,
                         kind: ChainingHint,
                         label: "C",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 143..190,
                             ),
                         ),
@@ -2142,11 +2087,8 @@ fn main() {
                         range: 143..179,
                         kind: ChainingHint,
                         label: "B",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 143..179,
                             ),
                         ),
@@ -2185,11 +2127,8 @@ fn main() {
                         range: 246..283,
                         kind: ChainingHint,
                         label: "B<X<i32, bool>>",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 246..283,
                             ),
                         ),
@@ -2198,11 +2137,8 @@ fn main() {
                         range: 246..265,
                         kind: ChainingHint,
                         label: "A<X<i32, bool>>",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 246..265,
                             ),
                         ),
@@ -2243,11 +2179,8 @@ fn main() {
                         range: 174..241,
                         kind: ChainingHint,
                         label: "impl Iterator<Item = ()>",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 174..241,
                             ),
                         ),
@@ -2256,11 +2189,8 @@ fn main() {
                         range: 174..224,
                         kind: ChainingHint,
                         label: "impl Iterator<Item = ()>",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 174..224,
                             ),
                         ),
@@ -2269,11 +2199,8 @@ fn main() {
                         range: 174..206,
                         kind: ChainingHint,
                         label: "impl Iterator<Item = ()>",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 174..206,
                             ),
                         ),
@@ -2282,11 +2209,8 @@ fn main() {
                         range: 174..189,
                         kind: ChainingHint,
                         label: "&mut MyIter",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 174..189,
                             ),
                         ),
@@ -2324,11 +2248,8 @@ fn main() {
                         range: 124..130,
                         kind: TypeHint,
                         label: "Struct",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 124..130,
                             ),
                         ),
@@ -2337,11 +2258,8 @@ fn main() {
                         range: 145..185,
                         kind: ChainingHint,
                         label: "Struct",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 145..185,
                             ),
                         ),
@@ -2350,11 +2268,8 @@ fn main() {
                         range: 145..168,
                         kind: ChainingHint,
                         label: "Struct",
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
+                        hover_trigger: Some(
+                            Range(
                                 145..168,
                             ),
                         ),
@@ -2363,14 +2278,7 @@ fn main() {
                         range: 222..228,
                         kind: ParameterHint,
                         label: "self",
-                        tooltip: Some(
-                            HoverOffset(
-                                FileId(
-                                    0,
-                                ),
-                                42,
-                            ),
-                        ),
+                        hover_trigger: None,
                     },
                 ]
             "#]],
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index 0d87f4fcfa..071da8097c 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -81,7 +81,7 @@ pub use crate::{
     highlight_related::{HighlightRelatedConfig, HighlightedRange},
     hover::{HoverAction, HoverConfig, HoverDocFormat, HoverGotoTypeData, HoverResult},
     inlay_hints::{
-        InlayHint, InlayHintsConfig, InlayKind, InlayTooltip, LifetimeElisionHints, ReborrowHints,
+        InlayHint, InlayHintsConfig, InlayKind, LifetimeElisionHints, RangeOrOffset, ReborrowHints,
     },
     join_lines::JoinLinesConfig,
     markup::Markup,
diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs
index 93255705be..ace1d455c4 100644
--- a/crates/project-model/src/workspace.rs
+++ b/crates/project-model/src/workspace.rs
@@ -389,14 +389,10 @@ impl ProjectWorkspace {
 
     pub fn to_crate_graph(
         &self,
-        dummy_replace: &FxHashMap<Box<str>, Box<[Box<str>]>>,
-        load_proc_macro: &mut dyn FnMut(&AbsPath, &[Box<str>]) -> Vec<ProcMacro>,
+        load_proc_macro: &mut dyn FnMut(&str, &AbsPath) -> Vec<ProcMacro>,
         load: &mut dyn FnMut(&AbsPath) -> Option<FileId>,
     ) -> CrateGraph {
         let _p = profile::span("ProjectWorkspace::to_crate_graph");
-        let load_proc_macro = &mut |crate_name: &_, path: &_| {
-            load_proc_macro(path, dummy_replace.get(crate_name).map(|it| &**it).unwrap_or_default())
-        };
 
         let mut crate_graph = match self {
             ProjectWorkspace::Json { project, sysroot, rustc_cfg } => project_json_to_crate_graph(
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index 490aef50f3..4243af25ff 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -66,8 +66,7 @@ pub fn load_workspace(
     };
 
     let crate_graph = ws.to_crate_graph(
-        &Default::default(),
-        &mut |path: &AbsPath, _| load_proc_macro(proc_macro_client.as_ref(), path, &[]),
+        &mut |_, path: &AbsPath| load_proc_macro(proc_macro_client.as_ref(), path, &[]),
         &mut |path: &AbsPath| {
             let contents = loader.load_sync(path);
             let path = vfs::VfsPath::from(path.to_path_buf());
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index afa83e6206..304254c3e2 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -59,7 +59,7 @@ config_data! {
 
         /// Warm up caches on project load.
         cachePriming_enable: bool = "true",
-        /// How many worker threads to handle priming caches. The default `0` means to pick automatically.
+        /// How many worker threads to to handle priming caches. The default `0` means to pick automatically.
         cachePriming_numThreads: ParallelCachePrimingNumThreads = "0",
 
         /// Automatically refresh project info via `cargo metadata` on
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 261c02816d..510b37bb6f 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -1344,7 +1344,12 @@ pub(crate) fn handle_inlay_hints(
             .inlay_hints(&inlay_hints_config, file_id, Some(range))?
             .into_iter()
             .map(|it| {
-                to_proto::inlay_hint(&snap, &line_index, inlay_hints_config.render_colons, it)
+                to_proto::inlay_hint(
+                    &line_index,
+                    &params.text_document,
+                    inlay_hints_config.render_colons,
+                    it,
+                )
             })
             .collect(),
     ))
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index c2a521bbf5..ed8c24acd1 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -319,8 +319,13 @@ impl GlobalState {
         // Create crate graph from all the workspaces
         let crate_graph = {
             let proc_macro_client = self.proc_macro_client.as_ref();
-            let mut load_proc_macro = move |path: &AbsPath, dummy_replace: &_| {
-                load_proc_macro(proc_macro_client, path, dummy_replace)
+            let dummy_replacements = self.config.dummy_replacements();
+            let mut load_proc_macro = move |crate_name: &str, path: &AbsPath| {
+                load_proc_macro(
+                    proc_macro_client,
+                    path,
+                    dummy_replacements.get(crate_name).map(|v| &**v).unwrap_or_default(),
+                )
             };
 
             let vfs = &mut self.vfs.write().0;
@@ -342,11 +347,7 @@ impl GlobalState {
 
             let mut crate_graph = CrateGraph::default();
             for ws in self.workspaces.iter() {
-                crate_graph.extend(ws.to_crate_graph(
-                    self.config.dummy_replacements(),
-                    &mut load_proc_macro,
-                    &mut load,
-                ));
+                crate_graph.extend(ws.to_crate_graph(&mut load_proc_macro, &mut load));
             }
             crate_graph
         };
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index f91ab6ea79..6817090a8b 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -415,8 +415,8 @@ pub(crate) fn signature_help(
 }
 
 pub(crate) fn inlay_hint(
-    snap: &GlobalStateSnapshot,
     line_index: &LineIndex,
+    text_document: &lsp_types::TextDocumentIdentifier,
     render_colons: bool,
     inlay_hint: InlayHint,
 ) -> lsp_types::InlayHint {
@@ -472,33 +472,20 @@ pub(crate) fn inlay_hint(
             | InlayKind::ClosingBraceHint => None,
         },
         text_edits: None,
-        data: (|| match inlay_hint.tooltip {
-            Some(ide::InlayTooltip::HoverOffset(file_id, offset)) => {
-                let uri = url(snap, file_id);
-                let line_index = snap.file_line_index(file_id).ok()?;
-
-                let text_document = lsp_types::TextDocumentIdentifier { uri };
-                to_value(lsp_ext::InlayHintResolveData {
-                    text_document,
-                    position: lsp_ext::PositionOrRange::Position(position(&line_index, offset)),
-                })
-                .ok()
-            }
-            Some(ide::InlayTooltip::HoverRanged(file_id, text_range)) => {
-                let uri = url(snap, file_id);
-                let text_document = lsp_types::TextDocumentIdentifier { uri };
-                let line_index = snap.file_line_index(file_id).ok()?;
-                to_value(lsp_ext::InlayHintResolveData {
-                    text_document,
-                    position: lsp_ext::PositionOrRange::Range(range(&line_index, text_range)),
-                })
-                .ok()
-            }
-            _ => None,
-        })(),
-        tooltip: Some(match inlay_hint.tooltip {
-            Some(ide::InlayTooltip::String(s)) => lsp_types::InlayHintTooltip::String(s),
-            _ => lsp_types::InlayHintTooltip::String(inlay_hint.label),
+        tooltip: Some(lsp_types::InlayHintTooltip::String(inlay_hint.label)),
+        data: inlay_hint.hover_trigger.map(|range_or_offset| {
+            to_value(lsp_ext::InlayHintResolveData {
+                text_document: text_document.clone(),
+                position: match range_or_offset {
+                    ide::RangeOrOffset::Offset(offset) => {
+                        lsp_ext::PositionOrRange::Position(position(line_index, offset))
+                    }
+                    ide::RangeOrOffset::Range(text_range) => {
+                        lsp_ext::PositionOrRange::Range(range(line_index, text_range))
+                    }
+                },
+            })
+            .unwrap()
         }),
     }
 }
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc
index 30722af08c..d8585ffb1d 100644
--- a/docs/user/generated_config.adoc
+++ b/docs/user/generated_config.adoc
@@ -11,7 +11,7 @@ Warm up caches on project load.
 [[rust-analyzer.cachePriming.numThreads]]rust-analyzer.cachePriming.numThreads (default: `0`)::
 +
 --
-How many worker threads to handle priming caches. The default `0` means to pick automatically.
+How many worker threads to to handle priming caches. The default `0` means to pick automatically.
 --
 [[rust-analyzer.cargo.autoreload]]rust-analyzer.cargo.autoreload (default: `true`)::
 +
diff --git a/editors/code/package.json b/editors/code/package.json
index e81dfff278..02899b6d17 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -388,7 +388,7 @@
                     "type": "boolean"
                 },
                 "rust-analyzer.cachePriming.numThreads": {
-                    "markdownDescription": "How many worker threads to handle priming caches. The default `0` means to pick automatically.",
+                    "markdownDescription": "How many worker threads to to handle priming caches. The default `0` means to pick automatically.",
                     "default": 0,
                     "type": "number",
                     "minimum": 0,


Test patch:
diff --git a/crates/project-model/src/tests.rs b/crates/project-model/src/tests.rs
index 3d089b61b5..e72903e55f 100644
--- a/crates/project-model/src/tests.rs
+++ b/crates/project-model/src/tests.rs
@@ -88,7 +88,7 @@ fn rooted_project_json(data: ProjectJsonData) -> ProjectJson {
 }
 
 fn to_crate_graph(project_workspace: ProjectWorkspace) -> CrateGraph {
-    project_workspace.to_crate_graph(&Default::default(), &mut |_, _| Vec::new(), &mut {
+    project_workspace.to_crate_graph(&mut |_, _| Vec::new(), &mut {
         let mut counter = 0;
         move |_path| {
             counter += 1;