support const params

This commit is contained in:
Jeroen Vannevel 2022-01-07 01:09:32 +00:00
parent b6201051b2
commit 734193bc23

View File

@ -80,7 +80,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<(
let number_of_arguments = generics let number_of_arguments = generics
.iter() .iter()
.filter(|param| match param { .filter(|param| match param {
hir::GenericParam::TypeParam(_) => true, hir::GenericParam::TypeParam(_) | hir::GenericParam::ConstParam(_) => true,
_ => false, _ => false,
}) })
.count(); .count();
@ -361,6 +361,25 @@ fn make<'a, T, A>(t: T, a: A) {}
fn main() { fn main() {
make::<${0:_,_}>(5, 2); make::<${0:_,_}>(5, 2);
} }
"#,
);
}
#[test]
fn add_turbo_fish_function_const_parameter() {
check_assist(
add_turbo_fish,
r#"
fn make<T, const N: usize>(t: T) {}
fn main() {
make$0(3);
}
"#,
r#"
fn make<T, const N: usize>(t: T) {}
fn main() {
make::<${0:_,_}>(3);
}
"#, "#,
); );
} }