mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Show enum variant on Self qualified paths
This commit is contained in:
parent
f3125555a8
commit
943e4faceb
1 changed files with 29 additions and 0 deletions
|
@ -118,6 +118,12 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(Adt::Enum(e)) = ty.as_adt() {
|
||||||
|
for variant in e.variants(ctx.db) {
|
||||||
|
acc.add_enum_variant(ctx, variant, None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let traits_in_scope = ctx.scope.traits_in_scope();
|
let traits_in_scope = ctx.scope.traits_in_scope();
|
||||||
let mut seen = FxHashSet::default();
|
let mut seen = FxHashSet::default();
|
||||||
ty.iterate_path_candidates(ctx.db, krate, &traits_in_scope, None, |_ty, item| {
|
ty.iterate_path_candidates(ctx.db, krate, &traits_in_scope, None, |_ty, item| {
|
||||||
|
@ -752,4 +758,27 @@ fn main() {
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn completes_self_enum() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
enum Foo {
|
||||||
|
Bar,
|
||||||
|
Baz,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Foo {
|
||||||
|
fn foo(self) {
|
||||||
|
Self::<|>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
ev Bar ()
|
||||||
|
ev Baz ()
|
||||||
|
me foo(…) fn foo(self)
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue