Skip to content

transpile: Factor out more pointer-related functions#1521

Merged
kkysen merged 9 commits intoimmunant:masterfrom
Rua:pointer-casts
Mar 19, 2026
Merged

transpile: Factor out more pointer-related functions#1521
kkysen merged 9 commits intoimmunant:masterfrom
Rua:pointer-casts

Conversation

@Rua
Copy link
Copy Markdown
Contributor

@Rua Rua commented Dec 18, 2025

This factors out functions for two things: casts involving pointers, and null checking. In the case of == and != operators in a non-conditional context (in operators.rs), this also adds special handling for regular pointers, where only function pointers were specially handled previously. This means that

int b = ptr == NULL;

is now translated with the is_null method as well, instead of with the == operator and core::ptr::null.

@Rua Rua force-pushed the pointer-casts branch 2 times, most recently from ff423e5 to 3a55413 Compare January 8, 2026 10:38
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.

By the way, when you do refactoring PRs like this, can you try to split out the pure moves vs. the semantic changes more carefully/fine-grained? It makes it much harder to review when mostly moves are mixed with some other changes (although I'm not sure if there are better ways of viewing the diffs; I tried --color-moved but it doesn't really work usually).

@Rua
Copy link
Copy Markdown
Contributor Author

Rua commented Jan 19, 2026

By the way, when you do refactoring PRs like this, can you try to split out the pure moves vs. the semantic changes more carefully/fine-grained?

How is this now?

@Rua Rua requested a review from kkysen January 23, 2026 13:45
@Rua
Copy link
Copy Markdown
Contributor Author

Rua commented Feb 5, 2026

Does anything else need to be done here?

Comment thread c2rust-transpile/src/translator/mod.rs
Comment thread c2rust-transpile/src/translator/mod.rs
@Rua Rua requested a review from kkysen February 25, 2026 21:59
Comment thread c2rust-transpile/src/translator/pointers.rs Outdated
@Rua Rua requested a review from kkysen February 26, 2026 21:44
Comment thread c2rust-transpile/src/translator/mod.rs Outdated
Comment thread c2rust-transpile/src/translator/operators.rs
Comment thread c2rust-transpile/src/translator/pointers.rs Outdated
Comment thread c2rust-transpile/src/translator/pointers.rs Outdated
Comment thread c2rust-transpile/src/translator/mod.rs
@Rua Rua force-pushed the pointer-casts branch 3 times, most recently from 5e409dd to 750fb81 Compare March 6, 2026 13:39
@Rua Rua requested a review from kkysen March 7, 2026 11:06
@Rua Rua force-pushed the pointer-casts branch 3 times, most recently from a72208c to 133b195 Compare March 18, 2026 13:19
Comment thread c2rust-transpile/src/translator/mod.rs
Comment thread c2rust-transpile/src/translator/operators.rs Outdated
@kkysen
Copy link
Copy Markdown
Contributor

kkysen commented Mar 19, 2026

@Rua, I'm going to force push. I need to untangle some commis. The follow-ups I suggested last time need to go in separate commits because they are separate changes, and they're much harder to review when combined into the same commits that are repeatedly rebased.

@kkysen kkysen force-pushed the pointer-casts branch 2 times, most recently from b6c3f64 to 464371e Compare March 19, 2026 20:26
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.

@Rua, I split up the latter commits more so that each commit does one thing. Let me know if this looks good. I dropped the last commit, b6c3f64, as I think it's cleaner to make new bindings than have a mutable one here. And I fixed the other comments I had just made earlier.

@Rua
Copy link
Copy Markdown
Contributor Author

Rua commented Mar 19, 2026

Yes, looks good.

@kkysen kkysen merged commit c11f9aa into immunant:master Mar 19, 2026
11 checks passed
@Rua Rua deleted the pointer-casts branch March 25, 2026 13:37
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