c2rust-refactor: Structurally match types more conservatively by comparing visibility#1474
Merged
Merged
Conversation
0dc6b18 to
baf7b17
Compare
…aring visibility
This fixes issues where reorganize_definitions would match
internal structure definitions like statvfs against
the types in libc which keep some fields as private:
pub struct statvfs {
pub f_bsize: c_ulong,
pub f_frsize: c_ulong,
pub f_blocks: crate::fsblkcnt_t,
pub f_bfree: crate::fsblkcnt_t,
pub f_bavail: crate::fsblkcnt_t,
pub f_files: crate::fsfilcnt_t,
pub f_ffree: crate::fsfilcnt_t,
pub f_favail: crate::fsfilcnt_t,
pub f_fsid: c_ulong,
pub f_flag: c_ulong,
pub f_namemax: c_ulong,
__f_spare: [c_int; 6],
}
baf7b17 to
20d4fb7
Compare
fw-immunant
approved these changes
Nov 25, 2025
Contributor
fw-immunant
left a comment
There was a problem hiding this comment.
I was initially wondering how we translate definitions from libc into types that have some private fields when afaik c2rust always emits all fields as public. But I realize you mean that c2rust-refactor was comparing transpiled structs with definitions from the actual libc crate, which is not transpiled.
LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes issues where reorganize_definitions would match internal structure definitions like statvfs against the types in libc which keep some fields as private: