Skip to content

Commit f7c2096

Browse files
author
bors-servo
authored
Auto merge of #340 - SSheldon:fix_omitted_ret_types, r=jdm
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.
2 parents c9b0702 + 0a1b0d6 commit f7c2096

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

cocoa/src/appkit.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ pub trait NSPasteboard: Sized {
549549

550550
impl NSPasteboard for id {
551551
unsafe fn releaseGlobally(self) {
552-
msg_send![self, releaseGlobally];
552+
msg_send![self, releaseGlobally]
553553
}
554554

555555
unsafe fn clearContents(self) -> NSInteger {
@@ -1547,11 +1547,11 @@ impl NSWindow for id {
15471547
}
15481548

15491549
unsafe fn setTabbingMode_(self, tabbingMode: NSWindowTabbingMode) {
1550-
msg_send![self, setTabbingMode: tabbingMode];
1550+
msg_send![self, setTabbingMode: tabbingMode]
15511551
}
15521552

15531553
unsafe fn addTabbedWindow_ordered_(self, window: id, ordering_mode: NSWindowOrderingMode) {
1554-
msg_send![self, addTabbedWindow:window ordered: ordering_mode];
1554+
msg_send![self, addTabbedWindow:window ordered: ordering_mode]
15551555
}
15561556

15571557
unsafe fn toggleTabBar_(self, sender: id) {
@@ -2977,7 +2977,7 @@ impl NSButton for id {
29772977
msg_send![self, initWithFrame:frameRect]
29782978
}
29792979
unsafe fn setBezelStyle_(self, style: NSBezelStyle) {
2980-
msg_send![self, setBezelStyle:style];
2980+
msg_send![self, setBezelStyle:style]
29812981
}
29822982
unsafe fn setTitle_(self, title: id /* (NSString*) */) {
29832983
msg_send![self, setTitle:title]
@@ -2990,7 +2990,7 @@ impl NSButton for id {
29902990
}
29912991

29922992
unsafe fn setAction_(self, selector: objc::runtime::Sel /* (Instance method *) */) {
2993-
msg_send![self, setAction:selector];
2993+
msg_send![self, setAction:selector]
29942994
}
29952995
}
29962996

@@ -3589,10 +3589,10 @@ impl NSTextField for id {
35893589
msg_send![self, initWithFrame:frameRect]
35903590
}
35913591
unsafe fn setEditable_(self, editable: BOOL) {
3592-
msg_send![self, setEditable:editable];
3592+
msg_send![self, setEditable:editable]
35933593
}
35943594
unsafe fn setStringValue_(self, label: id) {
3595-
msg_send![self, setStringValue:label];
3595+
msg_send![self, setStringValue:label]
35963596
}
35973597
}
35983598

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)