Skip to content

Commit 784379e

Browse files
committed
wip
1 parent b64e5b3 commit 784379e

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

crates/ide-completion/src/context/analysis.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,16 @@ fn classify_name_ref(
884884
};
885885
let make_path_kind_type = |ty: ast::Type| {
886886
let location = type_location(ty.syntax());
887+
if let Some(p) = ty.syntax().parent() {
888+
if ast::GenericArg::can_cast(p.kind()) || ast::GenericArgList::can_cast(p.kind()) {
889+
if let Some(p) = p.parent().and_then(|p| p.parent()) {
890+
if let Some(segment) = ast::PathSegment::cast(p) {
891+
let path = segment.parent_path().top_path();
892+
dbg!(sema.resolve_path(&path));
893+
}
894+
}
895+
}
896+
}
887897
PathKind::Type { location: location.unwrap_or(TypeLocation::Other) }
888898
};
889899

crates/ide-completion/src/tests/type_pos.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,3 +719,40 @@ pub struct S;
719719
"#]],
720720
)
721721
}
722+
723+
#[test]
724+
fn completes_const_and_type_generics_separately() {
725+
check(
726+
r#"
727+
struct Foo;
728+
const X: usize = 0;
729+
mod foo {
730+
fn foo<T>() {}
731+
}
732+
fn main() {
733+
self::foo::foo::<F$0>();
734+
}
735+
"#,
736+
expect![[r#"
737+
st Foo
738+
bt u32
739+
kw crate::
740+
kw self::
741+
"#]],
742+
);
743+
check(
744+
r#"
745+
struct Foo;
746+
const X: usize = 0;
747+
fn foo<const X: usize>() {}
748+
fn main() {
749+
foo::<F$0>();
750+
}
751+
"#,
752+
expect![[r#"
753+
ct X
754+
kw crate::
755+
kw self::
756+
"#]],
757+
);
758+
}

0 commit comments

Comments
 (0)