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

Does not compile if objc has verify_message feature turned on #655

Open
bryanlarsen opened this issue Jan 23, 2024 · 0 comments
Open

Does not compile if objc has verify_message feature turned on #655

bryanlarsen opened this issue Jan 23, 2024 · 0 comments

Comments

@bryanlarsen
Copy link

bryanlarsen commented Jan 23, 2024

How to reproduce:

create an app that depends on both cocoa-foundation and objc with the "verify_message" feature turned on. cocoa-foundation fails to compile.

Example error (there are dozens very similar):

error[E0277]: the trait bound `*mut *mut Object: Encode` is not satisfied
    --> /Users/blarsen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cocoa-foundation-0.1.2/src/foundation.rs:1588:9
     |
1588 |         msg_send![self, writeToURL:aURL options:mask error:errorPtr]
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |         |
     |         the trait `Encode` is not implemented for `*mut *mut Object`
     |         required by a bound introduced by this call
     |
     = help: the following other types implement trait `Encode`:
               *const Object
               *mut Object
               &'a Object
               &'a mut Object
     = note: required for `(*mut Object, NSDataWritingOptions, *mut *mut Object)` to implement `EncodeArguments`
note: required by a bound in `__send_message`
    --> /Users/blarsen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:186:49
     |
184  | pub unsafe fn send_message<T, A, R>(obj: *const T, sel: Sel, args: A)
     |               ------------ required by a bound in this function
185  |         -> Result<R, MessageError>
186  |         where T: Message, A: MessageArguments + EncodeArguments,
     |                                                 ^^^^^^^^^^^^^^^ required by this bound in `send_message`
     = note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info)

Rationale:

I'm getting a segfault in objc::message::platform::send_unverified in a Tauri application of mine. The interwebs tell me that in this situation I should turn on the "verify_message" flag in objc, which should convert my runtime segfault into a compile time error.

And unfortunately the way rust feature flags work I believe I can't turn it on for some crates and turn it off for cocoa-foundation.

Repro specifics:

x86 Mac, MacOS 12.7.1, Rust 1.73

cargo new foo, replace Cargo.toml with

[package]
name = "foo"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cocoa-foundation = "0.1.2"
objc = {version = "0.2.7", features = [ "verify_message" ]}

and then cargo build.

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

No branches or pull requests

1 participant