You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For whatever reason, using #[pyclass] from a separate module file (i.e. not in the lib.rs root file), requires the extern_prelude feature to be enabled in lib.rs, though it's not entirely clear why this is.
The error message is quite confusing, so if it can't be fixed, it might be worth documenting the fix somewhere. True, the compiler error does tell you to enable the feature, but it's unclear that the feature must be enabled in the root file as opposed to in the file generating the error. Googling for extern_prelude gives almost no explanation of this error, but it seems like it has to do with the use of something like pyo3::prelude::blah outside of a use statement. I'm guessing that happens somewhere in what the #[pyclass] macro expands to.
Reproducing
cargo new --lib eprelude && cd eprelude
Cargo.toml:
[package]
name = "eprelude"version = "0.1.0"authors = ["Author <author@domain.biz>"]
[dependencies.pyo3]
version = "0.5.0-alpha.1"
lib.rs:
#![feature(specialization)]// Including this feature here fixes the problem:// #![feature(extern_prelude)]externcrate pyo3;pubmod foo;
foo.rs:
use pyo3::prelude::{pyclass};#[pyclass]pubstructFoo{}
The text was updated successfully, but these errors were encountered:
For whatever reason, using
#[pyclass]
from a separate module file (i.e. not in thelib.rs
root file), requires theextern_prelude
feature to be enabled inlib.rs
, though it's not entirely clear why this is.The error message is quite confusing, so if it can't be fixed, it might be worth documenting the fix somewhere. True, the compiler error does tell you to enable the feature, but it's unclear that the feature must be enabled in the root file as opposed to in the file generating the error. Googling for
extern_prelude
gives almost no explanation of this error, but it seems like it has to do with the use of something likepyo3::prelude::blah
outside of ause
statement. I'm guessing that happens somewhere in what the#[pyclass]
macro expands to.Reproducing
cargo new --lib eprelude && cd eprelude
Cargo.toml:
lib.rs:
foo.rs:
The text was updated successfully, but these errors were encountered: