mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-02 10:04:23 +00:00
Auto merge of #14110 - dqkqd:auto-completion-for-missing-body, r=Veykril
Add completion for function without body Fix #13802
This commit is contained in:
commit
313a48057a
@ -675,10 +675,10 @@ fn classify_name_ref(
|
||||
{
|
||||
if let Some(item) = ast::Item::cast(n) {
|
||||
let is_inbetween = match &item {
|
||||
ast::Item::Const(it) => it.body().is_none(),
|
||||
ast::Item::Const(it) => it.body().is_none() && it.semicolon_token().is_none(),
|
||||
ast::Item::Enum(it) => it.variant_list().is_none(),
|
||||
ast::Item::ExternBlock(it) => it.extern_item_list().is_none(),
|
||||
ast::Item::Fn(it) => it.body().is_none(),
|
||||
ast::Item::Fn(it) => it.body().is_none() && it.semicolon_token().is_none(),
|
||||
ast::Item::Impl(it) => it.assoc_item_list().is_none(),
|
||||
ast::Item::Module(it) => {
|
||||
it.item_list().is_none() && it.semicolon_token().is_none()
|
||||
@ -688,7 +688,7 @@ fn classify_name_ref(
|
||||
it.field_list().is_none() && it.semicolon_token().is_none()
|
||||
}
|
||||
ast::Item::Trait(it) => it.assoc_item_list().is_none(),
|
||||
ast::Item::TypeAlias(it) => it.ty().is_none(),
|
||||
ast::Item::TypeAlias(it) => it.ty().is_none() && it.semicolon_token().is_none(),
|
||||
ast::Item::Union(it) => it.record_field_list().is_none(),
|
||||
_ => false,
|
||||
};
|
||||
|
@ -214,6 +214,57 @@ fn in_trait_assoc_item_list() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn in_trait_assoc_fn_missing_body() {
|
||||
check(
|
||||
r#"trait Foo { fn function(); $0 }"#,
|
||||
expect![[r#"
|
||||
ma makro!(…) macro_rules! makro
|
||||
md module
|
||||
kw const
|
||||
kw crate::
|
||||
kw fn
|
||||
kw self::
|
||||
kw type
|
||||
kw unsafe
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn in_trait_assoc_const_missing_body() {
|
||||
check(
|
||||
r#"trait Foo { const CONST: (); $0 }"#,
|
||||
expect![[r#"
|
||||
ma makro!(…) macro_rules! makro
|
||||
md module
|
||||
kw const
|
||||
kw crate::
|
||||
kw fn
|
||||
kw self::
|
||||
kw type
|
||||
kw unsafe
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn in_trait_assoc_type_aliases_missing_ty() {
|
||||
check(
|
||||
r#"trait Foo { type Type; $0 }"#,
|
||||
expect![[r#"
|
||||
ma makro!(…) macro_rules! makro
|
||||
md module
|
||||
kw const
|
||||
kw crate::
|
||||
kw fn
|
||||
kw self::
|
||||
kw type
|
||||
kw unsafe
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn in_trait_impl_assoc_item_list() {
|
||||
check(
|
||||
|
Loading…
Reference in New Issue
Block a user