Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check cfg to catch feature typos #12091

Closed
BD103 opened this issue Feb 24, 2024 · 2 comments · Fixed by #12103
Closed

Check cfg to catch feature typos #12091

BD103 opened this issue Feb 24, 2024 · 2 comments · Fixed by #12103
Labels
A-Build-System Related to build systems or continuous integration C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@BD103
Copy link
Member

BD103 commented Feb 24, 2024

Nightly Rust has added support for -Zcheck-cfg, which will show a warning if there is a #[cfg(...) for a nonexistant feature / cfg.

While not possible to add this to CI because it is currently nightly-only, it can be run locally to catch all current typos.

Please read this comment on how to use -Zcheck-cfg. Once you follow the setup, run:

cargo +nightly check -Zcheck-cfg --workspace

I found a few warnings related to missing features, but I currently don't have the time to work on it today.

@BD103 BD103 added D-Trivial Nice and easy! A great choice to get started with Bevy C-Code-Quality A section of code that is hard to understand or change labels Feb 24, 2024
@alice-i-cecile alice-i-cecile added the A-Build-System Related to build systems or continuous integration label Feb 24, 2024
@alice-i-cecile
Copy link
Member

We can actually add this to CI: we run some checks on nightly already :)

@eerii
Copy link
Contributor

eerii commented Feb 24, 2024

I'm working on removing the warnings and adding the check to the CI. I'll make a pr in a bit once it is ready!

github-merge-queue bot pushed a commit that referenced this issue Feb 25, 2024
# Objective

- Add the new `-Zcheck-cfg` checks to catch more warnings
- Fixes #12091

## Solution

- Create a new `cfg-check` to the CI that runs `cargo check -Zcheck-cfg
--workspace` using cargo nightly (and fails if there are warnings)
- Fix all warnings generated by the new check

---

## Changelog

- Remove all redundant imports
- Fix cfg wasm32 targets
- Add 3 dead code exceptions (should StandardColor be unused?)
- Convert ios_simulator to a feature (I'm not sure if this is the right
way to do it, but the check complained before)

## Migration Guide

No breaking changes

---------

Co-authored-by: Alice Cecile <[email protected]>
msvbg pushed a commit to msvbg/bevy that referenced this issue Feb 26, 2024
# Objective

- Add the new `-Zcheck-cfg` checks to catch more warnings
- Fixes bevyengine#12091

## Solution

- Create a new `cfg-check` to the CI that runs `cargo check -Zcheck-cfg
--workspace` using cargo nightly (and fails if there are warnings)
- Fix all warnings generated by the new check

---

## Changelog

- Remove all redundant imports
- Fix cfg wasm32 targets
- Add 3 dead code exceptions (should StandardColor be unused?)
- Convert ios_simulator to a feature (I'm not sure if this is the right
way to do it, but the check complained before)

## Migration Guide

No breaking changes

---------

Co-authored-by: Alice Cecile <[email protected]>
msvbg pushed a commit to msvbg/bevy that referenced this issue Feb 26, 2024
# Objective

- Add the new `-Zcheck-cfg` checks to catch more warnings
- Fixes bevyengine#12091

## Solution

- Create a new `cfg-check` to the CI that runs `cargo check -Zcheck-cfg
--workspace` using cargo nightly (and fails if there are warnings)
- Fix all warnings generated by the new check

---

## Changelog

- Remove all redundant imports
- Fix cfg wasm32 targets
- Add 3 dead code exceptions (should StandardColor be unused?)
- Convert ios_simulator to a feature (I'm not sure if this is the right
way to do it, but the check complained before)

## Migration Guide

No breaking changes

---------

Co-authored-by: Alice Cecile <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Build-System Related to build systems or continuous integration C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants