show variadic args in hover function signature

This commit is contained in:
Andy Russell 2022-03-04 16:24:13 -05:00
parent 908c17bfa6
commit 49fab593ad
No known key found for this signature in database
GPG Key ID: BE2221033EDBC374
2 changed files with 29 additions and 0 deletions

View File

@ -86,6 +86,11 @@ fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
// The former will ignore lifetime arguments currently.
type_ref.hir_fmt(f)?;
}
if data.is_varargs() {
write!(f, ", ...")?;
}
write!(f, ")")?;
// `FunctionData::ret_type` will be `::core::future::Future<Output = ...>` for async fns.

View File

@ -1757,6 +1757,30 @@ fn foo(&self)
);
}
#[test]
fn test_hover_variadic_function() {
check(
r#"
extern "C" {
pub fn foo(bar: i32, ...) -> i32;
}
fn main() { let foo_test = unsafe { fo$0o(1, 2, 3); } }
"#,
expect![[r#"
*foo*
```rust
test
```
```rust
pub unsafe fn foo(bar: i32, ...) -> i32
```
"#]],
);
}
#[test]
fn test_hover_trait_has_impl_action() {
check_actions(