gccrs: Implement compilation of `#[repr(transparent)]` structs
Adds support for compiling Rust structs marked with `#[repr(transparent)]`.
This commit implements the necessary code generation logic for Rust structs annotated with #[repr(transparent)]. This attribute allows a struct with a single field to have the same memory representation as that field, enabling seamless interoperability with C-compatible types. The changes cover compilation of field access and struct construction for these types.
In Details
The gccrs backend now correctly compiles Rust types marked with #[repr(transparent)]. This involves specific handling in CompileExpr for field access (compile_transparent_field_access) and struct initialization (visit (HIR::StructExprStructFields)), ensuring that the generated code treats these types as their single constituent field for layout and access purposes. The typing of these ADTs is also adjusted in TyTyResolveCompile.
- `#[repr(transparent)]` attribute
- A Rust attribute that indicates a struct or enum with a single field should have the same memory layout and ABI as that single field. This is commonly used for creating newtypes that are FFI-compatible with C types.
- ABI
- Application Binary Interface. Defines how low-level code (like compiled functions and data structures) interacts at the binary level, including calling conventions, data layout, and system calls. Important for interoperability between different languages or compiled components.
- ADT
- Algebraic Data Type. A type formed by combining other types using sums (enums) and products (structs). Rust's structs and enums are ADTs.
- field access
- The operation of retrieving or modifying the value of a member (field) within a struct or object.