@@ -17,65 +17,242 @@ fn clone() {
17
17
}
18
18
19
19
const TESTS : & [ ( & str , & str ) ] = & [
20
- ( "clone!( => move || {})" ,
21
- "If you have nothing to clone, no need to use this macro!" ) ,
22
- ( "clone!(|| {})" ,
23
- "If you have nothing to clone, no need to use this macro!" ) ,
24
- ( "clone!(|a, b| {})" ,
25
- "If you have nothing to clone, no need to use this macro!" ) ,
26
- ( "clone!(@weak a, @weak b => |x| {})" ,
27
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
28
- ( "clone!(@weak a, @weak b => || {})" ,
29
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
30
- ( "clone!(@weak a, @weak b => |x| println!(\" a\" ))" ,
31
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
32
- ( "clone!(@weak a, @weak b => || println!(\" a\" ))" ,
33
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
34
- ( "clone!(@weak a => |x| {})" ,
35
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
36
- ( "clone!(@weak a => || {})" ,
37
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
38
- ( "clone!(@weak a => |x| println!(\" a\" ))" ,
39
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
40
- ( "clone!(@weak a => || println!(\" a\" ))" ,
41
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
42
- ( "clone!(@strong self => move |x| {})" ,
43
- "Can't use `self` as variable name. Try storing it in a temporary variable or rename it using `as`." ) ,
44
- ( "clone!(@strong self.v => move |x| {})" ,
45
- "`self.v`: Field accesses are not allowed as is, you must rename it!" ) ,
46
- ( "clone!(@weak v => @default-return false, || {})" ,
47
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
48
- ( "clone!(@weak v => @default-return false, || println!(\" a\" ))" ,
49
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
50
- ( "clone!(@weak v => @default-return false, |bla| {})" ,
51
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
52
- ( "clone!(@weak v => @default-return false, |bla| println!(\" a\" ))" ,
53
- "Closure needs to be \" moved\" so please add `move` before closure" ) ,
54
- ( "clone!(@weak v => default-return false, move || {})" ,
55
- "Missing `@` before `default-return`" ) ,
56
- ( "clone!(@weak v => @default-return false move || {})" ,
57
- "Expected `,` after `@default-return false`, found `,`" ) ,
58
- ( "clone!(@yolo v => move || {})" ,
59
- "Unknown keyword `yolo`, only `weak`, `weak-allow-none`, `to-owned` and `strong` are allowed" ) ,
60
- ( "clone!(v => move || {})" ,
61
- "Unexpected ident `v`: you need to specify if this is a weak or a strong clone." ) ,
62
- ( "clone!(@strong v => {println!(\" foo\" );})" ,
63
- "Missing `move` and closure declaration" ) ,
64
- ( "clone!(@strong v, @default-return lol => move || {println!(\" foo\" );})" ,
65
- "`@default-return` should be after `=>`" ) ,
66
- ( "clone!(@default-return lol, @strong v => move || {println!(\" foo\" );})" ,
67
- "`@default-return` should be after `=>`" ) ,
20
+ (
21
+ "clone!( => move || {})" ,
22
+ "If you have nothing to clone, no need to use this macro!" ,
23
+ ) ,
24
+ (
25
+ "clone!(|| {})" ,
26
+ "If you have nothing to clone, no need to use this macro!" ,
27
+ ) ,
28
+ (
29
+ "clone!(|a, b| {})" ,
30
+ "If you have nothing to clone, no need to use this macro!" ,
31
+ ) ,
32
+ (
33
+ "clone!(@weak a, @weak b => |x| {})" ,
34
+ r#"error: Closure needs to be "moved" so please add `move` before closure
35
+ --> test_3.rs:1:86
36
+ |
37
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak a, @weak b => |x| {}); }
38
+ | ^"# ,
39
+ ) ,
40
+ (
41
+ "clone!(@weak a, @weak b => || {})" ,
42
+ r#"error: Closure needs to be "moved" so please add `move` before closure
43
+ --> test_4.rs:1:86
44
+ |
45
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak a, @weak b => || {}); }
46
+ | ^"# ,
47
+ ) ,
48
+ (
49
+ "clone!(@weak a, @weak b => |x| println!(\" a\" ))" ,
50
+ r#"error: Closure needs to be "moved" so please add `move` before closure
51
+ --> test_5.rs:1:86
52
+ |
53
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak a, @weak b => |x| println!("a")); }
54
+ | ^"# ,
55
+ ) ,
56
+ (
57
+ "clone!(@weak a, @weak b => || println!(\" a\" ))" ,
58
+ r#"error: Closure needs to be "moved" so please add `move` before closure
59
+ --> test_6.rs:1:86
60
+ |
61
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak a, @weak b => || println!("a")); }
62
+ | ^"# ,
63
+ ) ,
64
+ (
65
+ "clone!(@weak a => |x| {})" ,
66
+ r#"error: Closure needs to be "moved" so please add `move` before closure
67
+ --> test_7.rs:1:77
68
+ |
69
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak a => |x| {}); }
70
+ | ^"# ,
71
+ ) ,
72
+ (
73
+ "clone!(@weak a => || {})" ,
74
+ r#"error: Closure needs to be "moved" so please add `move` before closure
75
+ --> test_8.rs:1:77
76
+ |
77
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak a => || {}); }
78
+ | ^"# ,
79
+ ) ,
80
+ (
81
+ "clone!(@weak a => |x| println!(\" a\" ))" ,
82
+ r#"error: Closure needs to be "moved" so please add `move` before closure
83
+ --> test_9.rs:1:77
84
+ |
85
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak a => |x| println!("a")); }
86
+ | ^"# ,
87
+ ) ,
88
+ (
89
+ "clone!(@weak a => || println!(\" a\" ))" ,
90
+ r#"error: Closure needs to be "moved" so please add `move` before closure
91
+ --> test_10.rs:1:77
92
+ |
93
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak a => || println!("a")); }
94
+ | ^"# ,
95
+ ) ,
96
+ (
97
+ "clone!(@strong self => move |x| {})" ,
98
+ r#"error: Can't use `self` as variable name. Try storing it in a temporary variable or rename it using `as`.
99
+ --> test_11.rs:1:74
100
+ |
101
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@strong self => move |x| {}); }
102
+ | ^^^^
103
+ "# ,
104
+ ) ,
105
+ (
106
+ "clone!(@strong self.v => move |x| {})" ,
107
+ r#"error: `self.v`: Field accesses are not allowed as is, you must rename it!
108
+ --> test_12.rs:1:79
109
+ |
110
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@strong self.v => move |x| {}); }
111
+ | ^
112
+ "# ,
113
+ ) ,
114
+ (
115
+ "clone!(@weak v => @default-return false, || {})" ,
116
+ r#"error: Closure needs to be "moved" so please add `move` before closure
117
+ --> test_13.rs:1:100
118
+ |
119
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak v => @default-return false, || {}); }
120
+ | ^"# ,
121
+ ) ,
122
+ (
123
+ "clone!(@weak v => @default-return false, || println!(\" a\" ))" ,
124
+ r#"error: Closure needs to be "moved" so please add `move` before closure
125
+ --> test_14.rs:1:100
126
+ |
127
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak v => @default-return false, || println!("a")); }
128
+ | ^"# ,
129
+ ) ,
130
+ (
131
+ "clone!(@weak v => @default-return false, |bla| {})" ,
132
+ r#"error: Closure needs to be "moved" so please add `move` before closure
133
+ --> test_15.rs:1:100
134
+ |
135
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak v => @default-return false, |bla| {}); }
136
+ | ^
137
+ "# ,
138
+ ) ,
139
+ (
140
+ "clone!(@weak v => @default-return false, |bla| println!(\" a\" ))" ,
141
+ r#"error: Closure needs to be "moved" so please add `move` before closure
142
+ --> test_16.rs:1:100
143
+ |
144
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak v => @default-return false, |bla| println!("a")); }
145
+ | ^
146
+ "# ,
147
+ ) ,
148
+ (
149
+ "clone!(@weak v => default-return false, move || {})" ,
150
+ r#"error: Missing `@` before `default-return`
151
+ --> test_17.rs:1:77
152
+ |
153
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak v => default-return false, move || {}); }
154
+ | ^^^^^^^
155
+ "# ,
156
+ ) ,
157
+ (
158
+ "clone!(@weak v => @default-return false move || {})" ,
159
+ r#"error: Expected `,` after `@default-return false`, found `move`
160
+ --> test_18.rs:1:99
161
+ |
162
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@weak v => @default-return false move || {}); }
163
+ | ^^^^
164
+ "# ,
165
+ ) ,
166
+ (
167
+ "clone!(@yolo v => move || {})" ,
168
+ r#"error: Unknown keyword `yolo`, only `weak`, `weak-allow-none`, `to-owned` and `strong` are allowed
169
+ --> test_19.rs:1:67
170
+ |
171
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@yolo v => move || {}); }
172
+ | ^^^^
173
+ "# ,
174
+ ) ,
175
+ (
176
+ "clone!(v => move || {})" ,
177
+ r#"error: Unexpected ident `v`: you need to specify if this is a weak or a strong clone.
178
+ --> test_20.rs:1:66
179
+ |
180
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(v => move || {}); }
181
+ | ^
182
+ "# ,
183
+ ) ,
184
+ (
185
+ "clone!(@strong v => {println!(\" foo\" );})" ,
186
+ r#"error: Missing `move` and closure declaration
187
+ --> test_21.rs:1:79
188
+ |
189
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@strong v => {println!("foo");}); }
190
+ | ^^^^^^^^^^^^^^^^^^
191
+ "# ,
192
+ ) ,
193
+ (
194
+ "clone!(@strong v, @default-return lol => move || {println!(\" foo\" );})" ,
195
+ r#"error: `@default-return` should be after `=>`
196
+ --> test_22.rs:1:78
197
+ |
198
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@strong v, @default-return lol => move || {println!("foo");}); }
199
+ | ^^^^^^^
200
+ "# ,
201
+ ) ,
202
+ (
203
+ "clone!(@default-return lol, @strong v => move || {println!(\" foo\" );})" ,
204
+ r#"error: `@default-return` should be after `=>`
205
+ --> test_23.rs:1:67
206
+ |
207
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@default-return lol, @strong v => move || {println!("foo");}); }
208
+ | ^^^^^^^
209
+ "# ,
210
+ ) ,
68
211
// The async part!
69
- ( "clone!(@strong v => async || {println!(\" foo\" );})" ,
70
- "Expected `move` after `async`, found `|`" ) ,
71
- ( "clone!(@strong v => async {println!(\" foo\" );})" ,
72
- "Expected `move` after `async`, found `{`" ) ,
73
- ( "clone!(@strong v => move || async {println!(\" foo\" );})" ,
74
- "Expected `move` after `async`, found `{`" ) ,
75
- ( "clone!(@strong v => move || async println!(\" foo\" );)" ,
76
- "Expected `move` after `async`, found `println`" ) ,
77
- ( "clone!(@strong v => move || async move println!(\" foo\" );)" ,
78
- "Expected block after `| async move`" ) ,
212
+ (
213
+ "clone!(@strong v => async || {println!(\" foo\" );})" ,
214
+ r#"error: Expected `move` after `async`, found `|`
215
+ --> test_24.rs:1:85
216
+ |
217
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@strong v => async || {println!("foo");}); }
218
+ | ^"# ,
219
+ ) ,
220
+ (
221
+ "clone!(@strong v => async {println!(\" foo\" );})" ,
222
+ r#"error: Expected `move` after `async`, found `{`
223
+ --> test_25.rs:1:85
224
+ |
225
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@strong v => async {println!("foo");}); }
226
+ | ^^^^^^^^^^^^^^^^^^
227
+ "# ,
228
+ ) ,
229
+ (
230
+ "clone!(@strong v => move || async {println!(\" foo\" );})" ,
231
+ r#"error: Expected `move` after `async`, found `{`
232
+ --> test_26.rs:1:93
233
+ |
234
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@strong v => move || async {println!("foo");}); }
235
+ | ^^^^^^^^^^^^^^^^^^
236
+ "# ,
237
+ ) ,
238
+ (
239
+ "clone!(@strong v => move || async println!(\" foo\" );)" ,
240
+ r#"error: Expected `move` after `async`, found `println`
241
+ --> test_27.rs:1:93
242
+ |
243
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@strong v => move || async println!("foo");); }
244
+ | ^^^^^^^
245
+ "# ,
246
+ ) ,
247
+ (
248
+ "clone!(@strong v => move || async move println!(\" foo\" );)" ,
249
+ r#"error: Expected block after `| async move`
250
+ --> test_28.rs:1:98
251
+ |
252
+ 1 | fn main() { use glib::clone; let v = std::rc::Rc::new(1); clone!(@strong v => move || async move println!("foo");); }
253
+ | ^^^^^^^
254
+ "# ,
255
+ ) ,
79
256
] ;
80
257
81
258
#[ test]
0 commit comments