Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf42e55d

Browse files
committed
Enable linked locations for closure param inlay hints
1 parent4b3d7f6 commitf42e55d

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

‎src/tools/rust-analyzer/crates/ide/src/inlay_hints/param_name.rs‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,23 @@ pub(super) fn hints(
3030
.filter_map(|(p, arg)|{
3131
// Only annotate hints for expressions that exist in the original file
3232
let range = sema.original_range_opt(arg.syntax())?;
33-
let(param_name, name_syntax) =match p.source(sema.db)?.value.as_ref(){
33+
let source = p.source(sema.db)?;
34+
let(param_name, name_syntax) =match source.value.as_ref(){
3435
Either::Left(pat) =>(pat.name()?, pat.name()),
3536
Either::Right(param) =>match param.pat()?{
3637
ast::Pat::IdentPat(it) =>(it.name()?, it.name()),
3738
_ =>returnNone,
3839
},
3940
};
41+
// make sure the file is cached so we can map out of macros
42+
sema.parse_or_expand(source.file_id);
4043
Some((name_syntax, param_name, arg, range))
4144
})
4245
.filter(|(_, param_name, arg, _)|{
4346
!should_hide_param_name_hint(sema,&callable,&param_name.text(), arg)
4447
})
4548
.map(|(param, param_name, _,FileRange{ range, ..})|{
46-
letmut linked_location =None;
47-
ifletSome(name) = param{
48-
iflet hir::CallableKind::Function(f) = callable.kind(){
49-
// assert the file is cached so we can map out of macros
50-
if sema.source(f).is_some(){
51-
linked_location = sema.original_range_opt(name.syntax());
52-
}
53-
}
54-
}
49+
let linked_location = param.and_then(|name| sema.original_range_opt(name.syntax()));
5550

5651
let colon =if config.render_colons{":"}else{""};
5752
let label =

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp