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
@ -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 New Issue
Block a user