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

create_exception macro triggers unexpected_cfgs lint in nightly build #4743

Closed
stinodego opened this issue Nov 29, 2024 · 4 comments
Closed
Labels

Comments

@stinodego
Copy link

stinodego commented Nov 29, 2024

Bug Description

At Polars we have just updated our toolchain to nightly-2024-11-29. This version includes an update to the unexpected_cfgs check that also checks external macros. See rust-lang/rust#132577

This seems to indicate the macro "leaves ineffective cfgs in the users code".

Not exactly sure what the fix should be here, but I figured I'd report it.

Steps to Reproduce

  1. Set toolchain to nightly-2024-11-29
  2. Set up some minimal code with the pyo3::create_exception macro.
  3. Run cargo build

Backtrace

error: unexpected `cfg` condition value: `gil-refs`
   --> /home/stijn/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.22.6/src/exceptions.rs:34:15
    |
19  |   macro_rules! impl_exception_boilerplate {
    |   --------------------------------------- in this expansion of `$crate::impl_exception_boilerplate!` (#2)
...
34  |           #[cfg(feature = "gil-refs")]
    |                 ^^^^^^^^^^^^^^^^^^^^
...
242 |   macro_rules! create_exception {
    |   ----------------------------- in this expansion of `create_exception!` (#1)
...
248 |           $crate::impl_exception_boilerplate!($name);
    |           ------------------------------------------ in this macro invocation (#2)

Your operating system and version

Ubuntu 24.04.1

Your Python version (python --version)

Python 3.12.2

Your Rust version (rustc --version)

rustc 1.85.0-nightly (a2545fd6f 2024-11-28)

Your PyO3 version

0.22

How did you install python? Did you use a virtualenv?

pyenv
yes I am using a virtual environment

Additional Info

My current workaround is to use #![allow(unexpected_cfgs)] at the top of my exceptions.rs module.

@davidhewitt
Copy link
Member

Which patch version are you using? This should be fixed since 0.22.4, please try updating? (Was done in #4589 but I missed a CHANGELOG entry.)

@davidhewitt
Copy link
Member

EDIT: I see your code says 0.22.6, will investigate...

@davidhewitt
Copy link
Member

Ah, no I take that back, I see the #[cfg] switch inside the macro on 0.22.6. We fixed a similar problem in 0.22.4 but not this one.

Is it possible for you to update to 0.23? It is definitely fixed on main and I am unenthusiastic about sending another patch for the 0.22 series, particularly for a lint 😢

@stinodego
Copy link
Author

Thanks for looking into it! We will switch to 0.23 soon enough, so I'll keep our workaround until then. No problem at all.

Good to know it's fixed on main! I'll close this then.

@stinodego stinodego closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2024
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