Skip to content

Fix Rust cosmetic pass removing trailing units#517

Merged
R1kM merged 2 commits intomasterfrom
afromher_rust
Jan 9, 2025
Merged

Fix Rust cosmetic pass removing trailing units#517
R1kM merged 2 commits intomasterfrom
afromher_rust

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