diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-07-26 11:04:46 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2024-07-29 14:55:40 +0000 |
commit | 9de294a6848ede43833b9e225e3df56b4b3e5194 (patch) | |
tree | 5ca89257f6db771b2554428e14c939b84ae50317 /gcc | |
parent | c83b22a6932240194879ea7d9e783a4c0daf1b79 (diff) | |
download | gcc-9de294a6848ede43833b9e225e3df56b4b3e5194.zip gcc-9de294a6848ede43833b9e225e3df56b4b3e5194.tar.gz gcc-9de294a6848ede43833b9e225e3df56b4b3e5194.tar.bz2 |
ffi-polonius: Remove usage of extern types.
This will allow us to revert our dependency on extern types, which would
help our godbolt build as well as our various builders.
gcc/rust/ChangeLog:
* checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: Remove extern
type feature.
* checks/errors/borrowck/ffi-polonius/src/lib.rs: Define FFIVector
per the nomicon's recommendation
https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs | 11 | ||||
-rw-r--r-- | gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs index 5740271..7e839f0 100644 --- a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs +++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs @@ -30,11 +30,16 @@ // ``` include!("gccrs_ffi_generated.rs"); +use std::marker::{PhantomData, PhantomPinned}; + use crate::GccrsAtom; -// Using opqaue types -extern "C" { - pub type FFIVector; +// We define an opaque C type per the nomicon's recommendation: +// https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs +#[repr(C)] +pub struct FFIVector { + _empty: [u8; 0], + marker: PhantomData<(*mut u8, PhantomPinned)>, } impl<T1, T2> Into<(GccrsAtom, GccrsAtom)> for Pair<T1, T2> diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs index 1bcb89c..e254238 100644 --- a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs +++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs @@ -16,8 +16,6 @@ // along with GCC; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -#![feature(extern_types)] - mod gccrs_ffi; use gccrs_ffi::FFIVector; |