Rust-SDL2 / rust-sdl2

SDL2 bindings for Rust
MIT License
2.78k stars 474 forks source link

Unexpected `cfg` condition name: `mac_` & `ios_framework` #1436

Open e5f6bd opened 1 month ago

e5f6bd commented 1 month ago

When I compile sdl2-sys crate with the latest stable Rust, I get this kind of error message:

warning: unexpected `cfg` condition name: `ios_framework`
   --> sdl2-sys\build.rs:340:46
    |
340 |                 let use_framework = cfg!(any(ios_framework, feature = "use_ios_framework"));
    |                                              ^^^^^^^^^^^^^
    |
    = help: consider using a Cargo feature instead
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ios_framework)'] }
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
Entire warnings ``` warning: unexpected `cfg` condition name: `mac_framework` --> sdl2-sys\build.rs:333:46 | 333 | let use_framework = cfg!(any(mac_framework, feature = "use_mac_framework")); | ^^^^^^^^^^^^^ | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(mac_framework)'] } = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `ios_framework` --> sdl2-sys\build.rs:340:46 | 340 | let use_framework = cfg!(any(ios_framework, feature = "use_ios_framework")); | ^^^^^^^^^^^^^ | = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ios_framework)'] } = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `mac_framework` --> sdl2-sys\build.rs:357:46 | 357 | let use_framework = cfg!(any(mac_framework, feature = "use_mac_framework")); | ^^^^^^^^^^^^^ | = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(mac_framework)'] } = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `ios_framework` --> sdl2-sys\build.rs:364:46 | 364 | let use_framework = cfg!(any(ios_framework, feature = "use_ios_framework")); | ^^^^^^^^^^^^^ | = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ios_framework)'] } = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `mac_framework` --> sdl2-sys\build.rs:381:46 | 381 | let use_framework = cfg!(any(mac_framework, feature = "use_mac_framework")); | ^^^^^^^^^^^^^ | = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(mac_framework)'] } = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `ios_framework` --> sdl2-sys\build.rs:388:46 | 388 | let use_framework = cfg!(any(ios_framework, feature = "use_ios_framework")); | ^^^^^^^^^^^^^ | = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ios_framework)'] } = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `mac_framework` --> sdl2-sys\build.rs:405:46 | 405 | let use_framework = cfg!(any(mac_framework, feature = "use_mac_framework")); | ^^^^^^^^^^^^^ | = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(mac_framework)'] } = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `ios_framework` --> sdl2-sys\build.rs:412:46 | 412 | let use_framework = cfg!(any(ios_framework, feature = "use_ios_framework")); | ^^^^^^^^^^^^^ | = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ios_framework)'] } = note: see for more information about checking conditional configuration warning: `sdl2-sys` (build script) generated 8 warnings ```

Is there any reason of using a custom cfg attributes, ios_framework and mac_framework? Or is it just a reminicent of good old code that is never used right now? It seems these attributes started to be used at least before 2017 ... (as in b3ee9b2f04c57cc4c75ba47ebfe052ae950b18f6)

e5f6bd commented 1 month ago

Well, I found my browser has a tab showing #588, so it seems I found this issue but forget to further investigate. So I think this attribute is checked intentionally to support --cfg mac_framework. Then I think we should specify lints.rust.unexpected_cfgs.check-cfg as suggested.