Add const parameter keyword completion
Example
---
```rust
fn foo<c$0>() {}
```
->
```rust
fn foo<const $1: $0>() {}
```
This commit is contained in:
parent
06ee0ef31f
commit
c241ff4089
2 changed files with 28 additions and 1 deletions
|
|
@ -691,6 +691,9 @@ pub(super) fn complete_name(
|
|||
NameKind::RecordField => {
|
||||
field::complete_field_list_record_variant(acc, ctx);
|
||||
}
|
||||
NameKind::TypeParam => {
|
||||
acc.add_keyword_snippet(ctx, "const", "const $1: $0");
|
||||
}
|
||||
NameKind::ConstParam
|
||||
| NameKind::Enum
|
||||
| NameKind::MacroDef
|
||||
|
|
@ -700,7 +703,6 @@ pub(super) fn complete_name(
|
|||
| NameKind::Static
|
||||
| NameKind::Struct
|
||||
| NameKind::Trait
|
||||
| NameKind::TypeParam
|
||||
| NameKind::Union
|
||||
| NameKind::Variant => (),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1510,3 +1510,28 @@ fn foo<T>() {
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fn_generic_params_const_param_snippet() {
|
||||
check_edit("const", "fn foo<c$0>() {}", "fn foo<const $1: $0>() {}");
|
||||
check_edit("const", "fn foo<T, c$0>() {}", "fn foo<T, const $1: $0>() {}");
|
||||
check(
|
||||
r#"
|
||||
fn foo<T: $0>() {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
kw crate::
|
||||
kw self::
|
||||
"#]],
|
||||
);
|
||||
check(
|
||||
r#"
|
||||
fn foo<const N: $0>() {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
bt u32 u32
|
||||
kw crate::
|
||||
kw self::
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue