ci: register cargo-clippy cfg to silence objc 0.2.7 macro warnings#231
Closed
paravozz wants to merge 1 commit intoRustAudio:masterfrom
Closed
ci: register cargo-clippy cfg to silence objc 0.2.7 macro warnings#231paravozz wants to merge 1 commit intoRustAudio:masterfrom
paravozz wants to merge 1 commit intoRustAudio:masterfrom
Conversation
The `objc` 0.2.7 crate emits `#[cfg(feature = "cargo-clippy")]` inside the body of its `msg_send!` / `class!` / `sel_impl!` macros. Because macros expand at the call site, the cfg lands in baseview's own compilation unit (and any consumer's), where `cargo`'s default `--cap-lints=allow` for registry dependencies does not apply. CI's `RUSTFLAGS=-D warnings` then promotes the resulting `unexpected_cfgs` lint to a hard error, breaking macOS builds with 100+ identical errors per `msg_send!` site. Register the cfg as expected via `cargo:rustc-check-cfg` from a new `build.rs` so rustc no longer flags it during baseview's lint pass. Verified locally: with the build script in place, `RUSTFLAGS=-D warnings cargo build --workspace --all-targets --all-features` (and the equivalent test / doc invocations) all exit 0 on macOS; without it, the same commands fail with the upstream errors. Refs RustAudio#229.
This was referenced Apr 24, 2026
Author
|
Superseded by #232, which fixes the same lint failure at the source (full migration to |
Member
|
This is kind of a strange approach to fixing this. I would rather just silence the warning (#233). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
objc0.2.7 crate'smsg_send!/class!/sel_impl!macros emit#[cfg(feature = "cargo-clippy")]in their expansion. Because macros expand at the call site, the cfg lands in baseview's own compilation unit, wherecargo's default--cap-lints=allowfor registry dependencies does not apply. CI'sRUSTFLAGS=-D warningsthen promotes the resultingunexpected_cfgslint to a hard error: 100+ identical errors permsg_send!site, breaking the macOS job.Fix
Three lines in a new
build.rsregistering the cfg as expected:This tells rustc that
feature = "cargo-clippy"is a valid cfg expectation in baseview's own translation unit, so the lint stops firing during baseview's compilation. Dependencies are unaffected.Why this works (macro-expansion specifics)
Trace from a failing build, slightly trimmed:
The error fires while compiling baseview, not
objc. Cargo's--cap-lints=allowflag only applies to the dep's own translation unit; macros that the dep exports drag the offending cfg into the consumer's compilation, where--cap-lintsdoesn't help.cargo:rustc-check-cfgfrom baseview'sbuild.rsregisters the expected cfg specifically in baseview's lint pass, which is exactly where the warning lands.Verified locally
On macOS 15 (Apple Silicon), stable Rust:
RUSTFLAGS="-D warnings" cargo build --workspace --all-targetsRUSTFLAGS="-D warnings" cargo build --workspace --all-targets --all-featuresRUSTFLAGS="-D warnings" cargo test --workspace --all-targets --all-features --no-runRUSTDOCFLAGS="-D warnings" cargo doc --examples --all-features --no-depsMirrors the failing CI workflow exactly.
Relation to the longer-term fixes
Pure CI unblock; does not address the root cause. The proper fixes (publish
objc0.2.8 with #SSheldon/rust-objc#125's merged fix, or migrate baseview toobjc2) remain orthogonal to this PR and can be pursued on their own timelines. This is just to keep the macOS job green in the meantime so other PRs (e.g. #228) can merge.