Skip to content

#[cfg(unknown_option = "...") should produce a warning #39370

Closed
@Wilfred

Description

@Wilfred

The rust reference https://doc.rust-lang.org/reference.html#conditional-compilation states:

contains a string that can be checked against (#[cfg(bar = "baz")]). Currently, only compiler-defined configuration options can have the latter form.

Given that there's a fixed list of options, could rustc warn on invalid options? The following code compiles with no warnings:

#[cfg(i_dont_exist = "foo")]
extern crate bar;

fn main() {
}

This caught me out today when I wrote target = "macos" rather than target_os = "macos".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions