cfg_aliases icon indicating copy to clipboard operation
cfg_aliases copied to clipboard

fix: only emit `rustc-check-cfg` on Rust 1.77.0 or newer

Open ErichDonGubler opened this issue 1 year ago • 6 comments

ErichDonGubler avatar Aug 13 '24 07:08 ErichDonGubler

I was on the fence about whether we should check the Rust version and asked about that in https://github.com/katharostech/cfg_aliases/issues/7#issuecomment-2102192587, but @ogoffart and @Urgau were of the opinion that it probably wasn't necessary to do the check.

If we do the check, I think we can do it like in this comment https://github.com/katharostech/cfg_aliases/issues/7#issuecomment-2101789162, like the semver crate, instead of adding another dependency, since it's just a tiny function necessary to parse the version.

If this is something that WGPU needs, then I think we should just do the check, but I'd like to give the opportunity for comments before merging.

zicklag avatar Aug 13 '24 13:08 zicklag

WGPU could just wait until its MSRV is high enough to avoid warnings, and then upgrade. There aren't other features from this crate that we consume, so 🤷🏻‍♂️ I wouldn't be devastated if this PR were simply closed.

ErichDonGubler avatar Aug 13 '24 14:08 ErichDonGubler

Pro this change:

  • hides warning for people trying to compile the directly dependent crate with an old version of rust

Cons:

  • adds a dependency, that calls rustc to know the version, making the build a tiny bit slower.

One could argue that the build time is probably negligible.

But on the other hand, these warnings are only shown for some old version of rustc, they are not shown for dependencies (i.e, if someone use wgpu from crates.io, they won't see the warnings because of the caps-lint) and cargo warnings can't be turned into error on the CI.

ogoffart avatar Aug 27 '24 11:08 ogoffart

For now I'm leaning towards just leaving this be in favor of keeping this crate as 100% minimal and "guilt-free" as possible, but I don't have strong opinions on this change, so if anybody feels that this should definitely be done, feel free to comment and we'll get it fixed.

zicklag avatar Sep 05 '24 16:09 zicklag

Hi, I'm getting

warning: unexpected `cfg` condition name: `my_cfg_name`
    --> redis/src/my_code.rs:1653:23
     |
1653 |                 #[cfg(my_cfg_name)]
     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = 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(my_cfg_name)'] }
     = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(my_cfg_name)");` to the top of the `build.rs`
     = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

warning: `redis` (lib) generated 10 warnings

when using rustc 1.86.0 to compile a library crate. It's not that bad, because the fix is in the warning, but it still would be nice if it was avoided.

nihohit avatar Apr 15 '25 18:04 nihohit

@nihohit I opened #13 to discuss that. It appears to be a different issue.

zicklag avatar Apr 16 '25 14:04 zicklag