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

Fix Rust cosmetic pass removing trailing units #517

Merged
merged 2 commits into from
Jan 9, 2025
Merged

Conversation

R1kM
Copy link
Collaborator

@R1kM R1kM commented Jan 8, 2025

Slight refinement of the nanopass removing trailing units in the Rust backend.
Consider the following code

let x: u32 = 0;
()

With the previous version, the nanopass would have rewritten this code into 0, leading to typechecking failures in Rust.

This PR tweaks the pass to only perform the rewriting when the previous expression has type unit.

@msprotz
Copy link
Contributor

msprotz commented Jan 8, 2025

Alternatively, you could rewrite into let _x: u32 = 0; because you know for sure that it is unused. (If it doesn't already start with _).

I'm fine with either. Thanks!

@R1kM R1kM enabled auto-merge January 9, 2025 09:37
@R1kM R1kM merged commit 7f45831 into master Jan 9, 2025
2 checks passed
@R1kM R1kM deleted the afromher_rust branch January 9, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants