aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-17 14:45:25 +0100
committerGitHub <[email protected]>2020-07-17 14:45:25 +0100
commitae41505cadc69a4c6caa8f43b7d14a402543f2e8 (patch)
tree8dd4ccf08afb5b1f0576242ba13d1d165c6bb3c3 /crates/ra_ide/src
parent23df3834333a4db1449b2ba52e878ade47d1dfb2 (diff)
parent798f43da502e4b8d52e9b907420708d956faa054 (diff)
Merge #5424
5424: Fix out of bounds panic in active parameter r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/call_info.rs4
-rw-r--r--crates/ra_ide/src/completion/presentation.rs16
2 files changed, 20 insertions, 0 deletions
diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs
index 14980afdd..ff602202f 100644
--- a/crates/ra_ide/src/call_info.rs
+++ b/crates/ra_ide/src/call_info.rs
@@ -161,6 +161,10 @@ impl ActiveParameter {
161 161
162 let idx = active_parameter?; 162 let idx = active_parameter?;
163 let mut params = signature.params(sema.db); 163 let mut params = signature.params(sema.db);
164 if !(idx < params.len()) {
165 mark::hit!(too_many_arguments);
166 return None;
167 }
164 let (pat, ty) = params.swap_remove(idx); 168 let (pat, ty) = params.swap_remove(idx);
165 let name = pat?.to_string(); 169 let name = pat?.to_string();
166 Some(ActiveParameter { ty, name }) 170 Some(ActiveParameter { ty, name })
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs
index c7b74e635..9a94ff476 100644
--- a/crates/ra_ide/src/completion/presentation.rs
+++ b/crates/ra_ide/src/completion/presentation.rs
@@ -1160,6 +1160,22 @@ fn go(world: &WorldSnapshot) { go(w<|>) }
1160 } 1160 }
1161 1161
1162 #[test] 1162 #[test]
1163 fn too_many_arguments() {
1164 mark::check!(too_many_arguments);
1165 check_scores(
1166 r#"
1167struct Foo;
1168fn f(foo: &Foo) { f(foo, w<|>) }
1169"#,
1170 expect![[r#"
1171 st Foo []
1172 fn f(…) []
1173 bn foo []
1174 "#]],
1175 );
1176 }
1177
1178 #[test]
1163 fn guesses_macro_braces() { 1179 fn guesses_macro_braces() {
1164 check_edit( 1180 check_edit(
1165 "vec!", 1181 "vec!",