New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest type completions for type arguments and constant completions for constant arguments #15383
Conversation
The test failures seem correct given the changes, you'll just have to update their outputs |
check( | ||
r#" | ||
struct Foo; | ||
const X: usize = 0; | ||
fn foo<T, const N: usize>() {} | ||
fn main() { | ||
foo::<_, $0>(); | ||
} | ||
"#, | ||
expect![[r#" | ||
ct CONST | ||
ct X | ||
ma makro!(…) macro_rules! makro | ||
kw crate:: | ||
kw self:: | ||
"#]], | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we actually still want to show the Foo
struct because it could potentially have an associated const taht we want to complete. Its fine to put a FIXME on this for now as to not overload this PR with too many things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we complete associated constants e.g. Foo::X
if they exist but not Foo
itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a FIXME. Also not sure how this should interact with the fact that foo::<usize::MAX>()
is invalid (it should be foo::<{ usize::MAX }>()
). It'd be nice if we could get the completion to suggest { usize::MAX }
instead of just usize
, the latter making less sense if you don't know it has associated constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we complete associated constants e.g.
Foo::X
if they exist but notFoo
itself?
We probably could, likewise for const function calls
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Thanks! |
☀️ Test successful - checks-actions |
When determining completions for generic arguments, suggest only types or only constants if the corresponding generic parameter is a type parameter or constant parameter.
Closes #12568