mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-28 19:27:30 +03:00
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
```
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user