Skip to content

fix(build): repair the macOS build#618

Open
fchorney wants to merge 1 commit into
pnn64:mainfrom
fchorney:fc/fix-macos-build
Open

fix(build): repair the macOS build#618
fchorney wants to merge 1 commit into
pnn64:mainfrom
fchorney:fc/fix-macos-build

Conversation

@fchorney

Copy link
Copy Markdown
Contributor

Summary

main does not compile on macOS with stable Rust. Both faults sit inside #[cfg(target_os = "macos")] blocks, which is why CI on the other targets stays green.

Reproduced on a clean worktree at 146d8241, stable rustc 1.96.0, aarch64-apple-darwin. No behaviour change on any target.

1. const fn calling PartialEq (crates/deadlib-renderer/src/window_size.rs)

const fn macos_opengl_low_dpi(backend_type: BackendType, high_dpi: bool) -> bool {
    backend_type == BackendType::OpenGL && !high_dpi
}
error[E0015]: cannot call non-const operator in constant functions

== goes through PartialEq::eq, which is not callable in a const fn on stable (it needs const_trait_impl). Introduced by de4a1c5b.

Fixed with matches!, which pattern-matches instead of calling a trait method, so the function stays const:

matches!(backend_type, BackendType::OpenGL) && !high_dpi

2. Missing trait import (crates/deadsync-shell/src/window.rs)

attributes = attributes.with_disallow_hidpi(!config.high_dpi);
error[E0599]: no method named `with_disallow_hidpi` found for struct `WindowAttributes`

The method exists in winit 0.30.13, but its trait WindowAttributesExtMacOS is not in scope here. The call moved into window.rs during 146d8241 without its import; window_size.rs, where it used to live, still imports the trait. Fixed by importing it, cfg-gated to match the call site.

3. Unused import (crates/deadlib-renderer/src/window_size.rs)

Following from 2, window_size.rs no longer uses WindowAttributesExtMacOS, so on macOS it was an unused import. Dropped.

Testing

cargo check and cargo clippy are clean on macOS with this branch; both fail on main without it. cargo fmt --check clean. The only remaining cargo check warnings are the pre-existing ones in deadsync-audio and deadsync-config.

Noticed while rebasing #616 / #617; those PRs are unaffected by this and do not depend on it.

main does not compile on macOS with stable Rust. Both faults are inside
macOS-only cfg blocks, so CI on other targets stays green.

1. deadlib-renderer window_size.rs: macos_opengl_low_dpi is a const fn that
   compares BackendType with ==, which calls PartialEq::eq. That is not
   callable in a const fn on stable (it needs const_trait_impl), so the crate
   fails with E0015. Use matches! instead: pattern matching needs no trait
   call, and the function stays const.

2. deadsync-shell window.rs: the with_disallow_hidpi call arrived here without
   its trait. WindowAttributesExtMacOS is in scope in window_size.rs, where
   the call used to live, but not in window.rs, so the crate fails with E0599.
   Import the trait, cfg-gated like the call site.

Also drop WindowAttributesExtMacOS from window_size.rs, which no longer uses
it now that the call moved: on macOS it was an unused import.

No behaviour change on any target.
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.

1 participant