Skip to content

Commit

Permalink
Auto merge of #342 - SSheldon:backport_0.18.5, r=jdm
Browse files Browse the repository at this point in the history
Fixes so the compiler can infer msg_send! return types (backport to 0.18)

This is a backport of #340 onto the 0.18 release.

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.
  • Loading branch information
bors-servo committed Oct 17, 2019
2 parents 8ffba8a + 6c0c58a commit d1b8176
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cocoa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 4 additions & 4 deletions cocoa/src/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
}
}

Expand Down
4 changes: 2 additions & 2 deletions cocoa/src/quartzcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
}
}

Expand Down Expand Up @@ -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]
}
}

Expand Down
2 changes: 1 addition & 1 deletion cocoa/tests/foundation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down

0 comments on commit d1b8176

Please sign in to comment.