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

Automatically emit rustc-check-cfg directives for AutoCfg #70

Merged
merged 6 commits into from
Sep 27, 2024

Conversation

Techcable
Copy link
Contributor

This avoids the unexpected_cfgs lint for any of the configs emitted by AutoCfg methods.
This lint is new in Rust 1.80: https://blog.rust-lang.org/2024/05/06/check-cfg.html

This adds a emit_possibility method to mirror the emit method.
Calling emit manually does not call emit_possibility.

Fixes issue #64

Copy link
Owner

@cuviper cuviper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

It would be nice to have a full test of this in CI, but it would need a real crate to get Cargo etc. to use it. If you're up for it, I'd create one or more nested crates under ci/ that exercise this, probably denying unexpected_cfgs with both positive and negative cases. Then invoke those in the CI workflow, not recursive cargo test or anything. :)

src/lib.rs Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Techcable added a commit to Techcable/autocfg that referenced this pull request Sep 19, 2024
@Techcable
Copy link
Contributor Author

I have verified that commit 027f73a makes ci/verify-check-cfg work on rust 1.0

@cuviper
Copy link
Owner

cuviper commented Sep 26, 2024

Curious, the CI failure looks like a compiler race condition that's unlikely to be caused by your change. I can't reproduce it locally though...

@cuviper
Copy link
Owner

cuviper commented Sep 26, 2024

Oh, that was #65, but this is the first time I've seen it here in CI.

Copy link
Owner

@cuviper cuviper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting minor tweaks for older versions in that CI crate.

ci/verify-check-cfg/Cargo.toml Show resolved Hide resolved
ci/verify-check-cfg/src/main.rs Show resolved Hide resolved
Techcable and others added 6 commits September 26, 2024 17:45
This avoids the `unexpected_cfgs` lint for any of the configs emitted by AutoCfg methods.
This lint is new in Rust 1.80: <https://blog.rust-lang.org/2024/05/06/check-cfg.html>

This adds a `emit_possibility` method to mirror the `emit` method.
Calling `emit` manually does not call `emit_possibility`.

Fixes issue cuviper#64
Misisng link and incorrect `cargo:cargo:...` prefix
I can't use rust 1.0 on my computer (M1 Mac),
so I am relying on CI to check this.
@cuviper cuviper merged commit 8af60ec into cuviper:master Sep 27, 2024
24 checks passed
@Techcable
Copy link
Contributor Author

Thank you! 😁

schneems added a commit to schneems/fs-err that referenced this pull request Oct 17, 2024
There is a bug in the current CI suite with autocfg that was fixed in cuviper/autocfg#70 (autocfg 1.4+).  

Rust 1.80 introduced a new lint that was causing the build to fail on CI. I deleted the lockfile and reinstalled and that fixed the issue.

Previously the failure on CI looked like this:

```
Run actions-rs/cargo@v1
/home/runner/.cargo/bin/cargo test
 Downloading crates ...
  Downloaded itoa v1.0.[9](https://github.com/andrewhickman/fs-err/actions/runs/11391081315/job/31694081963?pr=61#step:6:10)
  Downloaded serde v1.0.192
  Downloaded ryu v1.0.15
  Downloaded serde_json v1.0.[10](https://github.com/andrewhickman/fs-err/actions/runs/11391081315/job/31694081963?pr=61#step:6:11)0
   Compiling serde v1.0.192
   Compiling serde_json v1.0.100
   Compiling ryu v1.0.15
   Compiling itoa v1.0.9
warning: unexpected `cfg` condition name: `rustc_1_63`
  --> src/path.rs:16:[11](https://github.com/andrewhickman/fs-err/actions/runs/11391081315/job/31694081963?pr=61#step:6:12)
   |
16 |     #[cfg(rustc_1_63)]
   |           ^^^^^^^^^^
   |
   = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `fmt_debug`, `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(rustc_1_63)'] }
   = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(rustc_1_63)");` 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
   = note: `#[warn(unexpected_cfgs)]` on by default
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants