Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/ide/src/inlay_hints/param_name.rs15
1 files changed, 5 insertions, 10 deletions
diff --git a/crates/ide/src/inlay_hints/param_name.rs b/crates/ide/src/inlay_hints/param_name.rs
index 20e8aca849..fb50c49a3a 100644
--- a/crates/ide/src/inlay_hints/param_name.rs
+++ b/crates/ide/src/inlay_hints/param_name.rs
@@ -30,28 +30,23 @@ pub(super) fn hints(
.filter_map(|(p, 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 p.source(sema.db)?.value.as_ref() {
+ let source = p.source(sema.db)?;
+ let (param_name, name_syntax) = match source.value.as_ref() {
Either::Left(pat) => (pat.name()?, pat.name()),
Either::Right(param) => match param.pat()? {
ast::Pat::IdentPat(it) => (it.name()?, it.name()),
_ => return None,
},
};
+ // make sure the file is cached so we can map out of macros
+ sema.parse_or_expand(source.file_id);
Some((name_syntax, param_name, arg, range))
})
.filter(|(_, param_name, arg, _)| {
!should_hide_param_name_hint(sema, &callable, &param_name.text(), arg)
})
.map(|(param, param_name, _, FileRange { range, .. })| {
- let mut linked_location = 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 sema.source(f).is_some() {
- linked_location = sema.original_range_opt(name.syntax());
- }
- }
- }
+ let linked_location = param.and_then(|name| sema.original_range_opt(name.syntax()));
let colon = if config.render_colons { ":" } else { "" };
let label =