mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Merge #6008
6008: inline parameters for a function description r=jonas-schievink a=bnjjj close #6002 Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
commit
37f3b9ca2a
2 changed files with 30 additions and 1 deletions
|
@ -730,4 +730,26 @@ fn f() {}
|
|||
expect![[""]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_function() {
|
||||
check(
|
||||
r#"
|
||||
fn foo(
|
||||
a: i32,
|
||||
b: i32
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
fn main() {
|
||||
fo<|>
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo(…) fn foo(a: i32, b: i32)
|
||||
fn main() fn main()
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,14 @@ pub(crate) fn function_declaration(node: &ast::Fn) -> String {
|
|||
format_to!(buf, "{}", type_params);
|
||||
}
|
||||
if let Some(param_list) = node.param_list() {
|
||||
format_to!(buf, "{}", param_list);
|
||||
let params: Vec<String> = param_list
|
||||
.self_param()
|
||||
.into_iter()
|
||||
.map(|self_param| self_param.to_string())
|
||||
.chain(param_list.params().map(|param| param.to_string()))
|
||||
.collect();
|
||||
// Useful to inline parameters
|
||||
format_to!(buf, "({})", params.join(", "));
|
||||
}
|
||||
if let Some(ret_type) = node.ret_type() {
|
||||
if ret_type.ty().is_some() {
|
||||
|
|
Loading…
Reference in a new issue