mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
add completions to show only traits in trait impl
statement
This commit is contained in:
parent
cf8733353d
commit
0209c28136
2 changed files with 28 additions and 0 deletions
|
@ -184,6 +184,16 @@ pub(crate) fn complete_type_path(
|
|||
}
|
||||
}
|
||||
}
|
||||
TypeLocation::ImplTrait => {
|
||||
acc.add_nameref_keywords_with_colon(ctx);
|
||||
ctx.process_all_names(&mut |name, def, doc_aliases| {
|
||||
let is_trait = matches!(def, ScopeDef::ModuleDef(hir::ModuleDef::Trait(_)));
|
||||
if is_trait {
|
||||
acc.add_path_resolution(ctx, path_ctx, name, def, doc_aliases);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
|
|
|
@ -989,3 +989,21 @@ fn foo<'a>() { S::<'static, F$0, _, _>; }
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn complete_traits_on_impl_trait_block() {
|
||||
check(
|
||||
r#"
|
||||
trait Foo {}
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl $0 for Bar { }"#,
|
||||
expect![[r#"
|
||||
tt Foo
|
||||
tt Trait
|
||||
kw crate::
|
||||
kw self::
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue