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
feat: inline const as literal #14925
feat: inline const as literal #14925
Conversation
489d5e0
to
1e803cc
Compare
Interesting assist. Why it's name is limited to string literals? I think the current code works with integers and other kinds of literals without any changes, and with some trivial changes it could support arrays and tuples (supporting structs and enums are a little harder I think) |
That was actually my initial intention, but I decided to scope it to
|
It's fine if this PR only supports
By those, you mean expressions that contains closures? I guess those are theoretically impossible to support. For adt the problem is private fields, unresolved names, names that need to be imported and similar things, so I think it should avoid ADTs. |
579db63
to
ae3be8e
Compare
21d83a5
to
d68d11e
Compare
fn inline_const_as_literal_expr_as_str_lit_not_applicable() { | ||
check_assist_not_applicable( | ||
inline_const_as_literal, | ||
r#" |
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.
Can you also add some negative tests for cases that their type is not supported (adt, closure, ...)?
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.
Absolutely,
Are the newly added tests enough, or should I add more variance to them?
#14947 fixes some of the |
Great! I'll take a look at your comments after work |
d68d11e
to
217d930
Compare
217d930
to
eef716d
Compare
Thanks! |
☀️ Test successful - checks-actions |
Assist: inline_const_as_literal
Evaluate and inline const variable as literal.
->