Skip to content

Commit d1b8176

Browse files
author
bors-servo
authored
Auto merge of #342 - SSheldon:backport_0.18.5, r=jdm
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.
2 parents 8ffba8a + 6c0c58a commit d1b8176

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

cocoa/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "cocoa"
44
description = "Bindings to Cocoa for OS X"
55
homepage = "https://github.com/servo/core-foundation-rs"
66
repository = "https://github.com/servo/core-foundation-rs"
7-
version = "0.18.4"
7+
version = "0.18.5"
88
authors = ["The Servo Project Developers"]
99
license = "MIT / Apache-2.0"
1010

cocoa/src/appkit.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ pub trait NSPasteboard: Sized {
541541

542542
impl NSPasteboard for id {
543543
unsafe fn releaseGlobally(self) {
544-
msg_send![self, releaseGlobally];
544+
msg_send![self, releaseGlobally]
545545
}
546546

547547
unsafe fn clearContents(self) -> NSInteger {
@@ -2881,7 +2881,7 @@ impl NSButton for id {
28812881
msg_send![self, initWithFrame:frameRect]
28822882
}
28832883
unsafe fn setBezelStyle_(self, style: NSBezelStyle) {
2884-
msg_send![self, setBezelStyle:style];
2884+
msg_send![self, setBezelStyle:style]
28852885
}
28862886
unsafe fn setTitle_(self, title: id /* (NSString*) */) {
28872887
msg_send![self, setTitle:title]
@@ -3486,10 +3486,10 @@ impl NSTextField for id {
34863486
msg_send![self, initWithFrame:frameRect]
34873487
}
34883488
unsafe fn setEditable_(self, editable: BOOL) {
3489-
msg_send![self, setEditable:editable];
3489+
msg_send![self, setEditable:editable]
34903490
}
34913491
unsafe fn setStringValue_(self, label: id) {
3492-
msg_send![self, setStringValue:label];
3492+
msg_send![self, setStringValue:label]
34933493
}
34943494
}
34953495

cocoa/src/quartzcore.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ impl CALayer {
889889
#[inline]
890890
pub fn set_should_rasterize(&self, flag: bool) {
891891
unsafe {
892-
msg_send![self.id(), setShouldRasterize:(flag as BOOL)];
892+
msg_send![self.id(), setShouldRasterize:(flag as BOOL)]
893893
}
894894
}
895895

@@ -1459,7 +1459,7 @@ impl CARenderer {
14591459
Some(ref layer) => layer.id(),
14601460
None => nil,
14611461
};
1462-
msg_send![self.id(), setLayer:layer];
1462+
msg_send![self.id(), setLayer:layer]
14631463
}
14641464
}
14651465

cocoa/tests/foundation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ mod foundation {
100100
let mut_components: id = msg_send![components, mutableCopy];
101101
let mut iter = mut_components.iter();
102102
iter.next();
103-
msg_send![mut_components, removeObjectAtIndex:1];
103+
let () = msg_send![mut_components, removeObjectAtIndex:1];
104104
iter.next();
105105
}
106106
}

0 commit comments

Comments
 (0)