mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Count the type parameters only
This commit is contained in:
parent
2fb6f5e46a
commit
b6201051b2
1 changed files with 26 additions and 1 deletions
|
@ -77,7 +77,13 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<(
|
|||
}
|
||||
}
|
||||
|
||||
let number_of_arguments = generics.len();
|
||||
let number_of_arguments = generics
|
||||
.iter()
|
||||
.filter(|param| match param {
|
||||
hir::GenericParam::TypeParam(_) => true,
|
||||
_ => false,
|
||||
})
|
||||
.count();
|
||||
let fish_head = std::iter::repeat("_").take(number_of_arguments).collect::<Vec<_>>().join(",");
|
||||
|
||||
acc.add(
|
||||
|
@ -339,4 +345,23 @@ fn main() {
|
|||
"Add `: _` before assignment operator",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_turbo_fish_function_lifetime_parameter() {
|
||||
check_assist(
|
||||
add_turbo_fish,
|
||||
r#"
|
||||
fn make<'a, T, A>(t: T, a: A) {}
|
||||
fn main() {
|
||||
make$0(5, 2);
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
fn make<'a, T, A>(t: T, a: A) {}
|
||||
fn main() {
|
||||
make::<${0:_,_}>(5, 2);
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue