diff options
| author | Max Heller <max.a.heller@gmail.com> | 2023-07-29 15:23:35 -0400 |
|---|---|---|
| committer | Max Heller <max.a.heller@gmail.com> | 2023-07-29 15:23:35 -0400 |
| commit | 784379eb796deb3c799473093f59555eb8cf17f1 (patch) | |
| tree | 19919e9b46d1a67262ec837122fe8d6d59a96b8d | |
| parent | b64e5b3919b24bc784f36248e6e1f921ee7bb71b (diff) | |
| download | rust-784379eb796deb3c799473093f59555eb8cf17f1.tar.gz rust-784379eb796deb3c799473093f59555eb8cf17f1.zip | |
wip
| -rw-r--r-- | crates/ide-completion/src/context/analysis.rs | 10 | ||||
| -rw-r--r-- | crates/ide-completion/src/tests/type_pos.rs | 37 |
2 files changed, 47 insertions, 0 deletions
diff --git a/crates/ide-completion/src/context/analysis.rs b/crates/ide-completion/src/context/analysis.rs index 3ea50659030..4f5266051be 100644 --- a/crates/ide-completion/src/context/analysis.rs +++ b/crates/ide-completion/src/context/analysis.rs @@ -884,6 +884,16 @@ fn classify_name_ref( }; let make_path_kind_type = |ty: ast::Type| { let location = type_location(ty.syntax()); + if let Some(p) = ty.syntax().parent() { + if ast::GenericArg::can_cast(p.kind()) || ast::GenericArgList::can_cast(p.kind()) { + if let Some(p) = p.parent().and_then(|p| p.parent()) { + if let Some(segment) = ast::PathSegment::cast(p) { + let path = segment.parent_path().top_path(); + dbg!(sema.resolve_path(&path)); + } + } + } + } PathKind::Type { location: location.unwrap_or(TypeLocation::Other) } }; diff --git a/crates/ide-completion/src/tests/type_pos.rs b/crates/ide-completion/src/tests/type_pos.rs index 8cb1ff4a125..4869ac17ad9 100644 --- a/crates/ide-completion/src/tests/type_pos.rs +++ b/crates/ide-completion/src/tests/type_pos.rs @@ -719,3 +719,40 @@ pub struct S; "#]], ) } + +#[test] +fn completes_const_and_type_generics_separately() { + check( + r#" +struct Foo; +const X: usize = 0; +mod foo { + fn foo<T>() {} +} +fn main() { + self::foo::foo::<F$0>(); +} +"#, + expect![[r#" + st Foo + bt u32 + kw crate:: + kw self:: + "#]], + ); + check( + r#" +struct Foo; +const X: usize = 0; +fn foo<const X: usize>() {} +fn main() { + foo::<F$0>(); +} +"#, + expect![[r#" + ct X + kw crate:: + kw self:: + "#]], + ); +} |
