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

Warnings with abi3 #1311

Closed
birkenfeld opened this issue Dec 12, 2020 · 3 comments · Fixed by #1312
Closed

Warnings with abi3 #1311

birkenfeld opened this issue Dec 12, 2020 · 3 comments · Fixed by #1312

Comments

@birkenfeld
Copy link
Member

birkenfeld commented Dec 12, 2020

I'm getting the following warnings when compiling a small test module with rustc nightly, pyo3 master and features ["abi3", "extension-module"]:

warning: static of uninhabited type
   --> /home/gbr/devel/ext/pyo3/src/ffi/object.rs:631:5
    |
631 |     pub static mut PyType_Type: PyTypeObject;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(uninhabited_static)]` on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
    = note: uninhabited statics cannot be initialized, and any access would be an immediate error

warning: static of uninhabited type
   --> /home/gbr/devel/ext/pyo3/src/ffi/object.rs:634:5
    |
634 |     pub static mut PyBaseObject_Type: PyTypeObject;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
    = note: uninhabited statics cannot be initialized, and any access would be an immediate error
@kngwyu
Copy link
Member

kngwyu commented Dec 12, 2020

Thanks, looks like a new warning?
Pointer for anyone curious: rust-lang/rust#74840

@birkenfeld
Copy link
Member Author

Hm, I wonder how one is to refer to external opaque C objects then...

@birkenfeld
Copy link
Member Author

From https://doc.rust-lang.org/nightly/nomicon/ffi.html#representing-opaque-structs (which is linked in the mentioned issue as the current workaround until we have stable extern type) it seems like:

    #[repr(C)]
    pub struct PyTypeObject([u8; 0]);

birkenfeld added a commit to birkenfeld/pyo3 that referenced this issue Dec 12, 2020
After `extern { type ... }` has stabilized for a while, this can
be replaced.  For now, I used a macro since it is much easier to
spot the locations to touch at that time.

fixes PyO3#1311
birkenfeld added a commit to birkenfeld/pyo3 that referenced this issue Dec 12, 2020
After `extern { type ... }` has stabilized for a while, this can
be replaced.  For now, I used a macro since it is much easier to
spot the locations to touch at that time.

fixes PyO3#1311
birkenfeld added a commit to birkenfeld/pyo3 that referenced this issue Dec 12, 2020
After `extern { type ... }` has stabilized for a while, this can
be replaced.  For now, I used a macro since it is much easier to
spot the locations to touch at that time.

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

Successfully merging a pull request may close this issue.

2 participants