Skip to content

Unexpected cfgs beginning with nightly-2024-11-20 #309

Closed
@smoelius

Description

@smoelius

Beginning with nightly-2024-11-20 (today), compiling a simple program like this:

#[ctor::ctor]
fn init() {}

produces a warning like this:

warning: unexpected `cfg` condition value: `used_linker`
 --> src/lib.rs:1:1
  |
1 | #[ctor::ctor]
  | ^^^^^^^^^^^^^
  |
  = note: no expected values for `feature`
  = help: consider adding `used_linker` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: `#[warn(unexpected_cfgs)]` on by default
  = note: this warning originates in the attribute macro `ctor::ctor` (in Nightly builds, run with -Z macro-backtrace for more info)

This appears to be the relevant rustc change: rust-lang/rust#132577

My best guess is that these lines are the cause:

rust-ctor/ctor/src/lib.rs

Lines 180 to 181 in fc9cd68

#[cfg_attr(not(feature = "used_linker"), used)]
#[cfg_attr(feature = "used_linker", used(linker))]

Adding used_linker as a feature to the project makes the warning go away, but I suspect this is not the intent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions