Skip to content

Commit 9de294a

Browse files
committed
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
1 parent c83b22a commit 9de294a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@
3030
// ```
3131
include!("gccrs_ffi_generated.rs");
3232

33+
use std::marker::{PhantomData, PhantomPinned};
34+
3335
use crate::GccrsAtom;
3436

35-
// Using opqaue types
36-
extern "C" {
37-
pub type FFIVector;
37+
// We define an opaque C type per the nomicon's recommendation:
38+
// https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
39+
#[repr(C)]
40+
pub struct FFIVector {
41+
_empty: [u8; 0],
42+
marker: PhantomData<(*mut u8, PhantomPinned)>,
3843
}
3944

4045
impl<T1, T2> Into<(GccrsAtom, GccrsAtom)> for Pair<T1, T2>

gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// along with GCC; see the file COPYING3. If not see
1717
// <http://www.gnu.org/licenses/>.
1818

19-
#![feature(extern_types)]
20-
2119
mod gccrs_ffi;
2220

2321
use gccrs_ffi::FFIVector;

0 commit comments

Comments
 (0)