Skip to content
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: Add an assist to extract an expression into a constant #18652

Merged
merged 6 commits into from
Dec 12, 2024

Conversation

Giga-Bowser
Copy link
Contributor

closes #7692

Technically, this will permit some invalid const definitions since, as far as I know, we don't have the ability to properly ensure that an expression can be const evaluated, but I believe that would require a larger overhaul of RA's integration of MIR stuff. Either way, this should be fine for now and does a good job rejecting most of the obviously incorrect definitions.

I could also group these assists if that's desirable, just let me know.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 9, 2024
@Veykril
Copy link
Member

Veykril commented Dec 11, 2024

Technically, this will permit some invalid const definitions since, as far as I know, we don't have the ability to properly ensure that an expression can be const evaluated, but I believe that would require a larger overhaul of RA's integration of MIR stuff. Either way, this should be fine for now and does a good job rejecting most of the obviously incorrect definitions.

That's fine, in that case we do want the assist to be more permissive I think. Its okay for assists to generate semantically invalid code (to a certain degree), its not okay for them to generate broken syntax.

@Veykril
Copy link
Member

Veykril commented Dec 11, 2024

I could also group these assists if that's desirable, just let me know.

This I think we might want to do, grouped together with function extraction, as well as closure extraction, once we have that, as i believe those can trigger on the same selection snippets at times.

@bors
Copy link
Contributor

bors commented Dec 11, 2024

☔ The latest upstream changes (presumably #18657) made this pull request unmergeable. Please resolve the merge conflicts.

@Giga-Bowser
Copy link
Contributor Author

This force-push was just fixing merge conflicts, I will begin working on those suggestions now!

@Veykril Veykril added this pull request to the merge queue Dec 12, 2024
Merged via the queue into rust-lang:master with commit a6c291e Dec 12, 2024
9 checks passed
@Giga-Bowser Giga-Bowser deleted the extract-constant branch December 14, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

‘Extract into constant’ assist
4 participants