Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd compiler warning #1340

Open
ccleve opened this issue Oct 17, 2023 · 7 comments
Open

Odd compiler warning #1340

ccleve opened this issue Oct 17, 2023 · 7 comments
Labels

Comments

@ccleve
Copy link
Contributor

ccleve commented Oct 17, 2023

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.

@workingjubilee
Copy link
Member

That's... odd. What version of rustc are you using?

@ccleve
Copy link
Contributor Author

ccleve commented Oct 17, 2023 via email

@workingjubilee
Copy link
Member

It looks like Rust examines the fields recursively and sometimes forgets to check locality.

@workingjubilee
Copy link
Member

Just to clarify, that's pgrx_pg_sys::Relation which is a *mut pgrx_pg_sys::RelationData, right?

@workingjubilee
Copy link
Member

Reported as rust-lang/rust#116831

@ccleve
Copy link
Contributor Author

ccleve commented Oct 17, 2023 via email

@ccleve
Copy link
Contributor Author

ccleve commented Oct 17, 2023

The workaround, for now, is to put

#![allow(improper_ctypes)]

in lib.rs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants