Skip to content

Commit 9351cf4

Browse files
committed
Add UI test for creation of generic types
1 parent 19d3df3 commit 9351cf4

File tree

2 files changed

+186
-0
lines changed

2 files changed

+186
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//! Test output of creating `NSArray` from a non-`Message` type.
2+
use icrate::Foundation::{NSArray, NSObject};
3+
use objc2::rc::Id;
4+
5+
fn main() {
6+
let _: Id<NSArray<i32>> = NSArray::new();
7+
let _: Id<NSArray<Id<NSObject>>> = NSArray::from_slice(&[&NSObject::new()]);
8+
}
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
error[E0277]: the trait bound `i32: Message` is not satisfied
2+
--> ui/nsarray_not_message.rs
3+
|
4+
| let _: Id<NSArray<i32>> = NSArray::new();
5+
| ^^^^^^^^^^^^^^^^ the trait `Message` is not implemented for `i32`
6+
|
7+
= help: the following other types implement trait `Message`:
8+
Exception
9+
ProtocolObject<P>
10+
AnyObject
11+
NSArray<ObjectType>
12+
NSMutableArray<ObjectType>
13+
NSDictionary<KeyType, ObjectType>
14+
NSMutableDictionary<KeyType, ObjectType>
15+
NSSet<ObjectType>
16+
and $N others
17+
note: required by a bound in `NSArray`
18+
--> $WORKSPACE/crates/icrate/src/generated/Foundation/../../fixes/Foundation/generics.rs
19+
|
20+
| / __inner_extern_class!(
21+
| | #[derive(PartialEq, Eq, Hash)]
22+
| | #[cfg(feature = "Foundation_NSArray")]
23+
| | pub struct NSArray<ObjectType: Message = AnyObject> {
24+
| | ------- required by a bound in this struct
25+
... |
26+
| | }
27+
| | );
28+
| |_^ required by this bound in `NSArray`
29+
= note: this error originates in the macro `__inner_extern_class` (in Nightly builds, run with -Z macro-backtrace for more info)
30+
31+
error[E0277]: the trait bound `Id<NSObject>: Message` is not satisfied
32+
--> ui/nsarray_not_message.rs
33+
|
34+
| let _: Id<NSArray<Id<NSObject>>> = NSArray::from_slice(&[&NSObject::new()]);
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Message` is not implemented for `Id<NSObject>`
36+
|
37+
= help: the following other types implement trait `Message`:
38+
Exception
39+
ProtocolObject<P>
40+
AnyObject
41+
NSArray<ObjectType>
42+
NSMutableArray<ObjectType>
43+
NSDictionary<KeyType, ObjectType>
44+
NSMutableDictionary<KeyType, ObjectType>
45+
NSSet<ObjectType>
46+
and $N others
47+
note: required by a bound in `NSArray`
48+
--> $WORKSPACE/crates/icrate/src/generated/Foundation/../../fixes/Foundation/generics.rs
49+
|
50+
| / __inner_extern_class!(
51+
| | #[derive(PartialEq, Eq, Hash)]
52+
| | #[cfg(feature = "Foundation_NSArray")]
53+
| | pub struct NSArray<ObjectType: Message = AnyObject> {
54+
| | ------- required by a bound in this struct
55+
... |
56+
| | }
57+
| | );
58+
| |_^ required by this bound in `NSArray`
59+
= note: this error originates in the macro `__inner_extern_class` (in Nightly builds, run with -Z macro-backtrace for more info)
60+
61+
error[E0277]: the trait bound `i32: Message` is not satisfied
62+
--> ui/nsarray_not_message.rs
63+
|
64+
| let _: Id<NSArray<i32>> = NSArray::new();
65+
| ^^^^^^^^^^^^ the trait `Message` is not implemented for `i32`
66+
|
67+
= help: the following other types implement trait `Message`:
68+
Exception
69+
ProtocolObject<P>
70+
AnyObject
71+
NSArray<ObjectType>
72+
NSMutableArray<ObjectType>
73+
NSDictionary<KeyType, ObjectType>
74+
NSMutableDictionary<KeyType, ObjectType>
75+
NSSet<ObjectType>
76+
and $N others
77+
note: required by a bound in `Foundation::__NSArray::<impl NSArray<ObjectType>>::new`
78+
--> $WORKSPACE/crates/icrate/src/generated/Foundation/NSArray.rs
79+
|
80+
| / extern_methods!(
81+
| | /// Methods declared on superclass `NSObject`
82+
| | #[cfg(feature = "Foundation_NSArray")]
83+
| | unsafe impl<ObjectType: Message> NSArray<ObjectType> {
84+
| | #[method_id(@__retain_semantics New new)]
85+
| | pub fn new() -> Id<Self>;
86+
| | --- required by a bound in this associated function
87+
| | }
88+
| | );
89+
| |_^ required by this bound in `Foundation::__NSArray::<impl NSArray<ObjectType>>::new`
90+
= note: this error originates in the macro `extern_methods` (in Nightly builds, run with -Z macro-backtrace for more info)
91+
92+
error[E0277]: the trait bound `i32: Message` is not satisfied
93+
--> ui/nsarray_not_message.rs
94+
|
95+
| let _: Id<NSArray<i32>> = NSArray::new();
96+
| ^^^^^^^ the trait `Message` is not implemented for `i32`
97+
|
98+
= help: the following other types implement trait `Message`:
99+
Exception
100+
ProtocolObject<P>
101+
AnyObject
102+
NSArray<ObjectType>
103+
NSMutableArray<ObjectType>
104+
NSDictionary<KeyType, ObjectType>
105+
NSMutableDictionary<KeyType, ObjectType>
106+
NSSet<ObjectType>
107+
and $N others
108+
note: required by a bound in `NSArray`
109+
--> $WORKSPACE/crates/icrate/src/generated/Foundation/../../fixes/Foundation/generics.rs
110+
|
111+
| / __inner_extern_class!(
112+
| | #[derive(PartialEq, Eq, Hash)]
113+
| | #[cfg(feature = "Foundation_NSArray")]
114+
| | pub struct NSArray<ObjectType: Message = AnyObject> {
115+
| | ------- required by a bound in this struct
116+
... |
117+
| | }
118+
| | );
119+
| |_^ required by this bound in `NSArray`
120+
= note: this error originates in the macro `__inner_extern_class` (in Nightly builds, run with -Z macro-backtrace for more info)
121+
122+
error[E0277]: the trait bound `Id<NSObject>: ClassType` is not satisfied
123+
--> ui/nsarray_not_message.rs
124+
|
125+
| let _: Id<NSArray<Id<NSObject>>> = NSArray::from_slice(&[&NSObject::new()]);
126+
| ------------------- ^^^^^^^^^^^^^^^^^^^ the trait `ClassType` is not implemented for `Id<NSObject>`
127+
| |
128+
| required by a bound introduced by this call
129+
|
130+
= help: the following other types implement trait `ClassType`:
131+
NSArray<ObjectType>
132+
NSMutableArray<ObjectType>
133+
NSDictionary<KeyType, ObjectType>
134+
NSMutableDictionary<KeyType, ObjectType>
135+
NSSet<ObjectType>
136+
NSMutableSet<ObjectType>
137+
NSEnumerator<ObjectType>
138+
NSAppleEventDescriptor
139+
and $N others
140+
= note: required for `Id<NSObject>` to implement `IsRetainable`
141+
note: required by a bound in `icrate::Foundation::array::<impl NSArray<T>>::from_slice`
142+
--> $WORKSPACE/crates/icrate/src/generated/Foundation/../../additions/Foundation/array.rs
143+
|
144+
| pub fn from_slice(slice: &[&T]) -> Id<Self>
145+
| ---------- required by a bound in this associated function
146+
| where
147+
| T: IsRetainable,
148+
| ^^^^^^^^^^^^ required by this bound in `icrate::Foundation::array::<impl NSArray<T>>::from_slice`
149+
150+
error[E0277]: the trait bound `Id<NSObject>: Message` is not satisfied
151+
--> ui/nsarray_not_message.rs
152+
|
153+
| let _: Id<NSArray<Id<NSObject>>> = NSArray::from_slice(&[&NSObject::new()]);
154+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Message` is not implemented for `Id<NSObject>`
155+
|
156+
= help: the following other types implement trait `Message`:
157+
Exception
158+
ProtocolObject<P>
159+
AnyObject
160+
NSArray<ObjectType>
161+
NSMutableArray<ObjectType>
162+
NSDictionary<KeyType, ObjectType>
163+
NSMutableDictionary<KeyType, ObjectType>
164+
NSSet<ObjectType>
165+
and $N others
166+
note: required by a bound in `NSArray`
167+
--> $WORKSPACE/crates/icrate/src/generated/Foundation/../../fixes/Foundation/generics.rs
168+
|
169+
| / __inner_extern_class!(
170+
| | #[derive(PartialEq, Eq, Hash)]
171+
| | #[cfg(feature = "Foundation_NSArray")]
172+
| | pub struct NSArray<ObjectType: Message = AnyObject> {
173+
| | ------- required by a bound in this struct
174+
... |
175+
| | }
176+
| | );
177+
| |_^ required by this bound in `NSArray`
178+
= note: this error originates in the macro `__inner_extern_class` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)