Skip to content

Commit

Permalink
Resolve unexpected_cfgs warning
Browse files Browse the repository at this point in the history
    warning: unexpected `cfg` condition name: `no_literal_fromstr`
       --> src/lib.rs:415:15
        |
    415 |     #[cfg(not(no_literal_fromstr))]
        |               ^^^^^^^^^^^^^^^^^^
        |
        = 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`, `windows`
        = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(no_literal_fromstr)");` to the top of the `build.rs`
        = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
        = note: `#[warn(unexpected_cfgs)]` on by default

    warning: unexpected `cfg` condition value: `protocol_feature_paste`
      --> tests/test_attr.rs:33:26
       |
    33 |                 #[cfg(any(feature = "protocol_feature_" $ret:snake, target_pointer_width = "" $width))]
       |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the condition
    ...
    42 |     m!(Paste, 64);
       |     ------------- in this macro invocation
       |
       = note: no expected values for `feature`
       = help: consider adding `protocol_feature_paste` as a feature in `Cargo.toml`
       = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
       = note: `#[warn(unexpected_cfgs)]` on by default
       = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
  • Loading branch information
dtolnay committed May 7, 2024
1 parent cc6803d commit 1edfaae
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ fn main() {
None => return,
};

if version.minor >= 80 {
println!("cargo:rustc-check-cfg=cfg(no_literal_fromstr)");
println!("cargo:rustc-check-cfg=cfg(feature, values(\"protocol_feature_paste\"))");
}

if version.minor < 54 {
// https://github.com/rust-lang/rust/pull/84717
println!("cargo:rustc-cfg=no_literal_fromstr");
Expand Down

0 comments on commit 1edfaae

Please sign in to comment.