From 9dd22a627526c85afc1652d18582c565798c2c7e Mon Sep 17 00:00:00 2001 From: Steven Sheldon Date: Wed, 16 Oct 2019 07:54:51 -0700 Subject: [PATCH 1/2] Fixes so the compiler can infer msg_send! return types Currently, due to a quirk in Rust's type inference interacting with the structure of the msg_send! macro, a () return type will be inferred when the compiler cannot otherwise determine the return type. This behavior is expected to change, and in the future could resolve to a ! return type, which results in undefined behavior. Linting has previously been added for this in rust-lang/rust#39216, but it did not catch these cases due to SSheldon/rust-objc#62. An upcoming version of objc will be fixed to stop hiding these errors, at which point they will become compile errors. This change fixes these errors and allows cocoa to compile with the fixed version of objc. (cherry picked from commit 0a1b0d6f1bbe5a3e60903a9416543e408d8581c5) --- cocoa/src/appkit.rs | 8 ++++---- cocoa/src/quartzcore.rs | 4 ++-- cocoa/tests/foundation.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cocoa/src/appkit.rs b/cocoa/src/appkit.rs index fbc07235f..883983bd8 100644 --- a/cocoa/src/appkit.rs +++ b/cocoa/src/appkit.rs @@ -541,7 +541,7 @@ pub trait NSPasteboard: Sized { impl NSPasteboard for id { unsafe fn releaseGlobally(self) { - msg_send![self, releaseGlobally]; + msg_send![self, releaseGlobally] } unsafe fn clearContents(self) -> NSInteger { @@ -2881,7 +2881,7 @@ impl NSButton for id { msg_send![self, initWithFrame:frameRect] } unsafe fn setBezelStyle_(self, style: NSBezelStyle) { - msg_send![self, setBezelStyle:style]; + msg_send![self, setBezelStyle:style] } unsafe fn setTitle_(self, title: id /* (NSString*) */) { msg_send![self, setTitle:title] @@ -3486,10 +3486,10 @@ impl NSTextField for id { msg_send![self, initWithFrame:frameRect] } unsafe fn setEditable_(self, editable: BOOL) { - msg_send![self, setEditable:editable]; + msg_send![self, setEditable:editable] } unsafe fn setStringValue_(self, label: id) { - msg_send![self, setStringValue:label]; + msg_send![self, setStringValue:label] } } diff --git a/cocoa/src/quartzcore.rs b/cocoa/src/quartzcore.rs index e139147d4..5a63f4acd 100644 --- a/cocoa/src/quartzcore.rs +++ b/cocoa/src/quartzcore.rs @@ -889,7 +889,7 @@ impl CALayer { #[inline] pub fn set_should_rasterize(&self, flag: bool) { unsafe { - msg_send![self.id(), setShouldRasterize:(flag as BOOL)]; + msg_send![self.id(), setShouldRasterize:(flag as BOOL)] } } @@ -1459,7 +1459,7 @@ impl CARenderer { Some(ref layer) => layer.id(), None => nil, }; - msg_send![self.id(), setLayer:layer]; + msg_send![self.id(), setLayer:layer] } } diff --git a/cocoa/tests/foundation.rs b/cocoa/tests/foundation.rs index 80ba68085..f1be8705d 100644 --- a/cocoa/tests/foundation.rs +++ b/cocoa/tests/foundation.rs @@ -100,7 +100,7 @@ mod foundation { let mut_components: id = msg_send![components, mutableCopy]; let mut iter = mut_components.iter(); iter.next(); - msg_send![mut_components, removeObjectAtIndex:1]; + let () = msg_send![mut_components, removeObjectAtIndex:1]; iter.next(); } } From 6c0c58a5625f55bc42c0211b5bd54037fd3f40a7 Mon Sep 17 00:00:00 2001 From: Steven Sheldon Date: Wed, 16 Oct 2019 08:00:15 -0700 Subject: [PATCH 2/2] Update cocoa version to 0.18.5 --- cocoa/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocoa/Cargo.toml b/cocoa/Cargo.toml index e1fba6e66..f81773a1a 100644 --- a/cocoa/Cargo.toml +++ b/cocoa/Cargo.toml @@ -4,7 +4,7 @@ name = "cocoa" description = "Bindings to Cocoa for OS X" homepage = "https://github.com/servo/core-foundation-rs" repository = "https://github.com/servo/core-foundation-rs" -version = "0.18.4" +version = "0.18.5" authors = ["The Servo Project Developers"] license = "MIT / Apache-2.0"