Skip to content

Commit 37f3b9c

Browse files
bors[bot]bnjjj
andauthored
Merge #6008
6008: inline parameters for a function description r=jonas-schievink a=bnjjj close #6002 Co-authored-by: Benjamin Coenen <[email protected]>
2 parents f514965 + e0f0d93 commit 37f3b9c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

crates/ide/src/completion/complete_qualified_path.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,4 +730,26 @@ fn f() {}
730730
expect![[""]],
731731
);
732732
}
733+
734+
#[test]
735+
fn completes_function() {
736+
check(
737+
r#"
738+
fn foo(
739+
a: i32,
740+
b: i32
741+
) {
742+
743+
}
744+
745+
fn main() {
746+
fo<|>
747+
}
748+
"#,
749+
expect![[r#"
750+
fn foo(…) fn foo(a: i32, b: i32)
751+
fn main() fn main()
752+
"#]],
753+
);
754+
}
733755
}

crates/ide/src/display.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ pub(crate) fn function_declaration(node: &ast::Fn) -> String {
4141
format_to!(buf, "{}", type_params);
4242
}
4343
if let Some(param_list) = node.param_list() {
44-
format_to!(buf, "{}", param_list);
44+
let params: Vec<String> = param_list
45+
.self_param()
46+
.into_iter()
47+
.map(|self_param| self_param.to_string())
48+
.chain(param_list.params().map(|param| param.to_string()))
49+
.collect();
50+
// Useful to inline parameters
51+
format_to!(buf, "({})", params.join(", "));
4552
}
4653
if let Some(ret_type) = node.ret_type() {
4754
if ret_type.ty().is_some() {

0 commit comments

Comments
 (0)