Skip to content

transpile: Use convert_cast in operators.rs#1703

Merged
kkysen merged 2 commits intoimmunant:masterfrom
Rua:operators-convert-cast
Apr 3, 2026
Merged

transpile: Use convert_cast in operators.rs#1703
kkysen merged 2 commits intoimmunant:masterfrom
Rua:operators-convert-cast

Conversation

@Rua
Copy link
Copy Markdown
Contributor

@Rua Rua commented Mar 28, 2026

The various edge cases in these bits of code were essentially duplicating what convert_cast was doing, but worse and easier to miss. So this just reuses the more robust logic that convert_cast already has for this.

Copy link
Copy Markdown
Contributor

@kkysen kkysen left a 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 before/after snapshot tests for this, too? Note that if the before test fails to compile, we can now handle that with a .expect_compile_error(true).

@Rua Rua force-pushed the operators-convert-cast branch 4 times, most recently from d55032c to c80f39c Compare March 31, 2026 09:46
@Rua
Copy link
Copy Markdown
Contributor Author

Rua commented Mar 31, 2026

I added a test to bool.c, which was added in #1693. So this PR now depends on that one.

@Rua Rua force-pushed the operators-convert-cast branch 2 times, most recently from 059a175 to be1db28 Compare March 31, 2026 19:19
Comment thread c2rust-transpile/tests/snapshots/bool.c Outdated
@Rua Rua force-pushed the operators-convert-cast branch from be1db28 to 5024fba Compare March 31, 2026 21:04
@kkysen kkysen merged commit 9169379 into immunant:master Apr 3, 2026
11 checks passed
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.

transpile: Compound assignment with unsigned RHS sometimes casts twice |= operator on bool results in invalid Rust being generated

2 participants