Skip to content

Commit f7c51a8

Browse files
committed
Update tests for underspecified errors in message sends
1 parent 4e64c1a commit f7c51a8

9 files changed

+82
-81
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//! Test underspecified msg_send_id! errors.
2+
use icrate::Foundation::NSString;
3+
use objc2::msg_send_id;
4+
use objc2::rc::Id;
5+
6+
fn main() {
7+
let obj: &NSString;
8+
let _: Result<Id<NSString>, _> = unsafe { msg_send_id![obj, error: _] };
9+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0282]: type annotations needed
2+
--> ui/msg_send_id_underspecified_error1.rs
3+
|
4+
| let _: Result<Id<NSString>, _> = unsafe { msg_send_id![obj, error: _] };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
6+
7+
error[E0283]: type annotations needed
8+
--> ui/msg_send_id_underspecified_error1.rs
9+
|
10+
| let _: Result<Id<NSString>, _> = unsafe { msg_send_id![obj, error: _] };
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for raw pointer `*mut _`
12+
|
13+
= note: multiple `impl`s satisfying `*mut _: RefEncode` found in the `objc2` crate:
14+
- impl RefEncode for *mut c_void;
15+
- impl<T> RefEncode for *mut T
16+
where T: RefEncode, T: ?Sized;
17+
= note: required for `*mut *mut _` to implement `Encode`
18+
note: required by a bound in `send_message_id_error`
19+
--> $WORKSPACE/crates/objc2/src/__macro_helpers/msg_send_id.rs
20+
|
21+
| unsafe fn send_message_id_error<A, E, R>(obj: T, sel: Sel, args: A) -> Result<R, Id<E>>
22+
| --------------------- required by a bound in this associated function
23+
| where
24+
| *mut *mut E: Encode,
25+
| ^^^^^^ required by this bound in `MsgSendId::send_message_id_error`
26+
= note: this error originates in the macro `$crate::__msg_send_id_helper` which comes from the expansion of the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info)
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
//! Test underspecified msg_send! errors.
1+
//! Test underspecified msg_send_id! errors.
22
use icrate::Foundation::{NSError, NSString};
33
use objc2::msg_send_id;
44
use objc2::rc::Id;
55

66
fn main() {
77
let obj: &NSString;
8-
let _: Result<Id<_>, Id<NSError>> = unsafe { msg_send_id![obj, a: _] };
8+
let _: Result<_, Id<NSError>> = unsafe { msg_send_id![obj, error: _] };
99
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error[E0282]: type annotations needed
2+
--> ui/msg_send_id_underspecified_error2.rs
3+
|
4+
| let _: Result<_, Id<NSError>> = unsafe { msg_send_id![obj, error: _] };
5+
| ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//! Test underspecified msg_send_id! errors.
2+
use icrate::Foundation::NSString;
3+
use objc2::msg_send_id;
4+
5+
fn main() {
6+
let obj: &NSString;
7+
let _: Result<_, _> = unsafe { msg_send_id![obj, error: _] };
8+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0282]: type annotations needed
2+
--> ui/msg_send_id_underspecified_error3.rs
3+
|
4+
| let _: Result<_, _> = unsafe { msg_send_id![obj, error: _] };
5+
| ^^^^^^^^^^^^ cannot infer type
6+
7+
error[E0283]: type annotations needed
8+
--> ui/msg_send_id_underspecified_error3.rs
9+
|
10+
| let _: Result<_, _> = unsafe { msg_send_id![obj, error: _] };
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for raw pointer `*mut _`
12+
|
13+
= note: multiple `impl`s satisfying `*mut _: RefEncode` found in the `objc2` crate:
14+
- impl RefEncode for *mut c_void;
15+
- impl<T> RefEncode for *mut T
16+
where T: RefEncode, T: ?Sized;
17+
= note: required for `*mut *mut _` to implement `Encode`
18+
note: required by a bound in `send_message_id_error`
19+
--> $WORKSPACE/crates/objc2/src/__macro_helpers/msg_send_id.rs
20+
|
21+
| unsafe fn send_message_id_error<A, E, R>(obj: T, sel: Sel, args: A) -> Result<R, Id<E>>
22+
| --------------------- required by a bound in this associated function
23+
| where
24+
| *mut *mut E: Encode,
25+
| ^^^^^^ required by this bound in `MsgSendId::send_message_id_error`
26+
= note: this error originates in the macro `$crate::__msg_send_id_helper` which comes from the expansion of the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info)
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
//! Test underspecified msg_send! errors.
22
use icrate::Foundation::NSString;
3-
use objc2::rc::Id;
4-
use objc2::{msg_send, msg_send_id};
3+
use objc2::msg_send;
54

65
fn main() {
76
let obj: &NSString;
8-
let _: Result<(), _> = unsafe { msg_send![obj, a: _] };
9-
10-
let _: Result<_, _> = unsafe { msg_send_id![obj, b: _] };
11-
let _: Result<Id<NSString>, _> = unsafe { msg_send_id![obj, c: _] };
12-
let _: Result<Id<NSString>, Id<_>> = unsafe { msg_send_id![obj, d: _] };
7+
let _: Result<(), _> = unsafe { msg_send![obj, error: _] };
138
}
Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error[E0282]: type annotations needed
22
--> ui/msg_send_underspecified_error.rs
33
|
4-
| let _: Result<Id<NSString>, Id<_>> = unsafe { msg_send_id![obj, d: _] };
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
4+
| let _: Result<(), _> = unsafe { msg_send![obj, error: _] };
5+
| ^^^^^^^^^^^^^ cannot infer type
66

77
error[E0283]: type annotations needed
88
--> ui/msg_send_underspecified_error.rs
99
|
10-
| let _: Result<(), _> = unsafe { msg_send![obj, a: _] };
11-
| ^^^^^^^^^^^^^^^^^^^^ cannot infer type for raw pointer `*mut _`
10+
| let _: Result<(), _> = unsafe { msg_send![obj, error: _] };
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for raw pointer `*mut _`
1212
|
1313
= note: multiple `impl`s satisfying `*mut _: RefEncode` found in the `objc2` crate:
1414
- impl RefEncode for *mut c_void;
@@ -24,66 +24,3 @@ note: required by a bound in `send_message_error`
2424
| *mut *mut E: Encode,
2525
| ^^^^^^ required by this bound in `MsgSend::send_message_error`
2626
= note: this error originates in the macro `$crate::__msg_send_helper` which comes from the expansion of the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info)
27-
28-
error[E0283]: type annotations needed
29-
--> ui/msg_send_underspecified_error.rs
30-
|
31-
| let _: Result<_, _> = unsafe { msg_send_id![obj, b: _] };
32-
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for raw pointer `*mut _`
33-
|
34-
= note: multiple `impl`s satisfying `*mut _: RefEncode` found in the `objc2` crate:
35-
- impl RefEncode for *mut c_void;
36-
- impl<T> RefEncode for *mut T
37-
where T: RefEncode, T: ?Sized;
38-
= note: required for `*mut *mut _` to implement `Encode`
39-
note: required by a bound in `send_message_id_error`
40-
--> $WORKSPACE/crates/objc2/src/__macro_helpers/msg_send_id.rs
41-
|
42-
| unsafe fn send_message_id_error<A, E, R>(obj: T, sel: Sel, args: A) -> Result<R, Id<E>>
43-
| --------------------- required by a bound in this associated function
44-
| where
45-
| *mut *mut E: Encode,
46-
| ^^^^^^ required by this bound in `MsgSendId::send_message_id_error`
47-
= note: this error originates in the macro `$crate::__msg_send_id_helper` which comes from the expansion of the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info)
48-
49-
error[E0283]: type annotations needed
50-
--> ui/msg_send_underspecified_error.rs
51-
|
52-
| let _: Result<Id<NSString>, _> = unsafe { msg_send_id![obj, c: _] };
53-
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for raw pointer `*mut _`
54-
|
55-
= note: multiple `impl`s satisfying `*mut _: RefEncode` found in the `objc2` crate:
56-
- impl RefEncode for *mut c_void;
57-
- impl<T> RefEncode for *mut T
58-
where T: RefEncode, T: ?Sized;
59-
= note: required for `*mut *mut _` to implement `Encode`
60-
note: required by a bound in `send_message_id_error`
61-
--> $WORKSPACE/crates/objc2/src/__macro_helpers/msg_send_id.rs
62-
|
63-
| unsafe fn send_message_id_error<A, E, R>(obj: T, sel: Sel, args: A) -> Result<R, Id<E>>
64-
| --------------------- required by a bound in this associated function
65-
| where
66-
| *mut *mut E: Encode,
67-
| ^^^^^^ required by this bound in `MsgSendId::send_message_id_error`
68-
= note: this error originates in the macro `$crate::__msg_send_id_helper` which comes from the expansion of the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info)
69-
70-
error[E0283]: type annotations needed
71-
--> ui/msg_send_underspecified_error.rs
72-
|
73-
| let _: Result<Id<NSString>, Id<_>> = unsafe { msg_send_id![obj, d: _] };
74-
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for raw pointer `*mut _`
75-
|
76-
= note: multiple `impl`s satisfying `*mut _: RefEncode` found in the `objc2` crate:
77-
- impl RefEncode for *mut c_void;
78-
- impl<T> RefEncode for *mut T
79-
where T: RefEncode, T: ?Sized;
80-
= note: required for `*mut *mut _` to implement `Encode`
81-
note: required by a bound in `send_message_id_error`
82-
--> $WORKSPACE/crates/objc2/src/__macro_helpers/msg_send_id.rs
83-
|
84-
| unsafe fn send_message_id_error<A, E, R>(obj: T, sel: Sel, args: A) -> Result<R, Id<E>>
85-
| --------------------- required by a bound in this associated function
86-
| where
87-
| *mut *mut E: Encode,
88-
| ^^^^^^ required by this bound in `MsgSendId::send_message_id_error`
89-
= note: this error originates in the macro `$crate::__msg_send_id_helper` which comes from the expansion of the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info)

crates/test-ui/ui/msg_send_underspecified_error2.stderr

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)