From fcd9c36f3bd88748d760b893cd0fd00c8a199f3a Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Wed, 1 Apr 2026 11:09:56 +0800 Subject: [PATCH] fix: Fix param inlayHints on empty expr and comma Example --- ```rust pub fn test(a: i32, b: i32, c: i32) {} fn main() { test(, 2,); test(, , 3); } ``` **Before this PR** ```rust test(, 2,); //^ a test(, , 3); //^ a ``` **After this PR** ```rust test(, 2,); //^ b test(, , 3); //^ c ``` --- .../crates/ide/src/inlay_hints/param_name.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/param_name.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/param_name.rs index 08588bbed090..8dddf9d37e4f 100644 --- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/param_name.rs +++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/param_name.rs @@ -37,8 +37,9 @@ pub(super) fn hints( let hints = callable .params() .into_iter() - .zip(arg_list.args()) + .zip(arg_list.args_maybe_empty()) .filter_map(|(p, arg)| { + let arg = arg?; // Only annotate hints for expressions that exist in the original file let range = sema.original_range_opt(arg.syntax())?; if range.file_id != file_id { @@ -561,6 +562,19 @@ fn main() { ) } + #[test] + fn param_name_hints_show_after_empty_arg() { + check_params( + r#"pub fn test(a: i32, b: i32, c: i32) {} +fn main() { + test(, 2,); + //^ b + test(, , 3); + //^ c +}"#, + ) + } + #[test] fn function_call_parameter_hint() { check_params(