Skip to content

create_exception macro triggers unexpected_cfgs lint in nightly build #4743

Closed as not planned
@stinodego

Description

@stinodego

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions