Odd compiler warning
I just upgraded to v0.11.0 from 0.10.something. I now get this compiler warning:
warning: `extern` block uses type `NodeTag`, which is not FFI-safe
--> src/cfuncs/bindings.rs:11:16
|
11 | index: Relation,
| ^^^^^^^^ not FFI-safe
|
= note: this enum is non-exhaustive
= note: `#[warn(improper_ctypes)]` on by default
on this code:
extern "C" {
pub fn rdb_read_page(
index: Relation,
blkno: u32,
lock_type: ::std::os::raw::c_int,
pg_buffer: *mut u32,
) -> *mut ::std::os::raw::c_char;
}
This points to a function I wrote in C to read/write pages in an index relation.
This warning is a bit odd, because NodeTag doesn't appear in the method signature and I don't know why Relation would not be ffi-safe.
I've been using this code successfully for quite a while now.
That's... odd. What version of rustc are you using?
rustc 1.72.1 (d5c2e9c34 2023-09-13)
Just now, I did a rustup update to 1.73. Same error.
On Mon, Oct 16, 2023 at 8:11 PM Jubilee @.***> wrote:
That's... odd. What version of rustc are you using?
— Reply to this email directly, view it on GitHub https://github.com/pgcentralfoundation/pgrx/issues/1340#issuecomment-1765498848, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAITHKUPVRE6H4IBBLAUI2LX7XLMBAVCNFSM6AAAAAA6C7HFSCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRVGQ4TQOBUHA . You are receiving this because you authored the thread.Message ID: @.***>
It looks like Rust examines the fields recursively and sometimes forgets to check locality.
Just to clarify, that's pgrx_pg_sys::Relation which is a *mut pgrx_pg_sys::RelationData, right?
Reported as https://github.com/rust-lang/rust/issues/116831
It says "use crate::pg_sys::Relation;" at the top of the file. Hover over it in CLion and it says:
pgrx_pg_sys::include::pg16 pub type Relation = *mut RelationData
On Mon, Oct 16, 2023 at 10:14 PM Jubilee @.***> wrote:
Just to clarify, that's pgrx_pg_sys::Relation which is a *mut pgrx_pg_sys::RelationData, right?
— Reply to this email directly, view it on GitHub https://github.com/pgcentralfoundation/pgrx/issues/1340#issuecomment-1765595030, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAITHKXO5GLPVZRMYELDYXTX7XZXXAVCNFSM6AAAAAA6C7HFSCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRVGU4TKMBTGA . You are receiving this because you authored the thread.Message ID: @.***>
The workaround, for now, is to put
#![allow(improper_ctypes)]
in lib.rs.