Merge #5424
5424: Fix out of bounds panic in active parameter r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
ae41505cad
2 changed files with 20 additions and 0 deletions
|
@ -161,6 +161,10 @@ impl ActiveParameter {
|
||||||
|
|
||||||
let idx = active_parameter?;
|
let idx = active_parameter?;
|
||||||
let mut params = signature.params(sema.db);
|
let mut params = signature.params(sema.db);
|
||||||
|
if !(idx < params.len()) {
|
||||||
|
mark::hit!(too_many_arguments);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
let (pat, ty) = params.swap_remove(idx);
|
let (pat, ty) = params.swap_remove(idx);
|
||||||
let name = pat?.to_string();
|
let name = pat?.to_string();
|
||||||
Some(ActiveParameter { ty, name })
|
Some(ActiveParameter { ty, name })
|
||||||
|
|
|
@ -1159,6 +1159,22 @@ fn go(world: &WorldSnapshot) { go(w<|>) }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn too_many_arguments() {
|
||||||
|
mark::check!(too_many_arguments);
|
||||||
|
check_scores(
|
||||||
|
r#"
|
||||||
|
struct Foo;
|
||||||
|
fn f(foo: &Foo) { f(foo, w<|>) }
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
st Foo []
|
||||||
|
fn f(…) []
|
||||||
|
bn foo []
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn guesses_macro_braces() {
|
fn guesses_macro_braces() {
|
||||||
check_edit(
|
check_edit(
|
||||||
|
|
Loading…
Reference in a new issue