From 49fab593ad7d91e82ec9b4a5642ec736045a365c Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Fri, 4 Mar 2022 16:24:13 -0500 Subject: [PATCH] show variadic args in hover function signature --- crates/hir/src/display.rs | 5 +++++ crates/ide/src/hover/tests.rs | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs index d411b9d71b1..b7ea42236ee 100644 --- a/crates/hir/src/display.rs +++ b/crates/hir/src/display.rs @@ -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` for async fns. diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index 9d516fdd6fc..e7fad48080d 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -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(