From fc76052495997c6fb6ded38f146c72c3220f2b90 Mon Sep 17 00:00:00 2001 From: Arnaud VERSINI Date: Mon, 2 Feb 2026 16:25:00 +0100 Subject: [PATCH] rust : use repr(transparent) when we should Change-Id: Iaf8334aa8d83c170454dffc8438395a395246938 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198557 Reviewed-by: Arnaud Versini Tested-by: Jenkins --- codemaker/source/rustmaker/rustproduce.cxx | 1 + rust_uno/src/core/any.rs | 1 + rust_uno/src/core/oustring.rs | 1 + rust_uno/src/core/sequence.rs | 1 + rust_uno/src/core/type.rs | 1 + 5 files changed, 5 insertions(+) diff --git a/codemaker/source/rustmaker/rustproduce.cxx b/codemaker/source/rustmaker/rustproduce.cxx index b6da46888a16..88e2d21002bd 100644 --- a/codemaker/source/rustmaker/rustproduce.cxx +++ b/codemaker/source/rustmaker/rustproduce.cxx @@ -613,6 +613,7 @@ void RustProducer::generateInterfaceWrapper( .endLine() .beginLine() .append("#[allow(non_camel_case_types)]") + .append("#[repr(transparent)]") .endLine() .beginLine() .append("pub struct ") diff --git a/rust_uno/src/core/any.rs b/rust_uno/src/core/any.rs index 7e307239720b..90b4273a29ff 100644 --- a/rust_uno/src/core/any.rs +++ b/rust_uno/src/core/any.rs @@ -34,6 +34,7 @@ use crate::ffi::uno_any::*; /// /// Any provides a safe, memory-managed interface to LibreOffice's native /// any type. It automatically handles reference counting and memory cleanup. +#[repr(transparent)] pub struct Any { inner: uno_Any, } diff --git a/rust_uno/src/core/oustring.rs b/rust_uno/src/core/oustring.rs index 23433330490e..3d25c8f644d9 100644 --- a/rust_uno/src/core/oustring.rs +++ b/rust_uno/src/core/oustring.rs @@ -36,6 +36,7 @@ use crate::ffi::sal_types::*; /// OUString provides a safe, memory-managed interface to LibreOffice's native /// string type. It automatically handles reference counting and memory cleanup, /// and provides conversions to/from standard Rust string types. +#[repr(transparent)] pub struct OUString { inner: NonNull, } diff --git a/rust_uno/src/core/sequence.rs b/rust_uno/src/core/sequence.rs index f9d8a237b0a2..2fe75666f392 100644 --- a/rust_uno/src/core/sequence.rs +++ b/rust_uno/src/core/sequence.rs @@ -37,6 +37,7 @@ use std::ptr::NonNull; /// /// Sequence provides a safe, memory-managed interface to LibreOffice's native /// Sequence type. It automatically handles reference counting and memory cleanup. +#[repr(transparent)] pub struct Sequence { inner: NonNull, } diff --git a/rust_uno/src/core/type.rs b/rust_uno/src/core/type.rs index 21363952ddcf..a86c0c3e837e 100644 --- a/rust_uno/src/core/type.rs +++ b/rust_uno/src/core/type.rs @@ -54,6 +54,7 @@ use std::ptr; /// )); /// ``` #[allow(non_snake_case)] // _pType follows FFI naming conventions +#[repr(transparent)] pub struct Type { /// C typelib reference pointer _pType: *mut typelib_TypeDescriptionReference,