aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/doc_tests/generated.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/doc_tests/generated.rs')
-rw-r--r--crates/ra_assists/src/doc_tests/generated.rs526
1 files changed, 526 insertions, 0 deletions
diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs
new file mode 100644
index 000000000..1bee76f59
--- /dev/null
+++ b/crates/ra_assists/src/doc_tests/generated.rs
@@ -0,0 +1,526 @@
1//! Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`
2
3use super::check;
4
5#[test]
6fn doctest_add_derive() {
7 check(
8 "add_derive",
9 r#####"
10struct Point {
11 x: u32,
12 y: u32,<|>
13}
14"#####,
15 r#####"
16#[derive()]
17struct Point {
18 x: u32,
19 y: u32,
20}
21"#####,
22 )
23}
24
25#[test]
26fn doctest_add_explicit_type() {
27 check(
28 "add_explicit_type",
29 r#####"
30fn main() {
31 let x<|> = 92;
32}
33"#####,
34 r#####"
35fn main() {
36 let x: i32 = 92;
37}
38"#####,
39 )
40}
41
42#[test]
43fn doctest_add_hash() {
44 check(
45 "add_hash",
46 r#####"
47fn main() {
48 r#"Hello,<|> World!"#;
49}
50"#####,
51 r#####"
52fn main() {
53 r##"Hello, World!"##;
54}
55"#####,
56 )
57}
58
59#[test]
60fn doctest_add_impl() {
61 check(
62 "add_impl",
63 r#####"
64struct Ctx<T: Clone> {
65 data: T,<|>
66}
67"#####,
68 r#####"
69struct Ctx<T: Clone> {
70 data: T,
71}
72
73impl<T: Clone> Ctx<T> {
74
75}
76"#####,
77 )
78}
79
80#[test]
81fn doctest_add_impl_default_members() {
82 check(
83 "add_impl_default_members",
84 r#####"
85trait T {
86 Type X;
87 fn foo(&self);
88 fn bar(&self) {}
89}
90
91impl T for () {
92 Type X = ();
93 fn foo(&self) {}<|>
94
95}
96"#####,
97 r#####"
98trait T {
99 Type X;
100 fn foo(&self);
101 fn bar(&self) {}
102}
103
104impl T for () {
105 Type X = ();
106 fn foo(&self) {}
107 fn bar(&self) {}
108
109}
110"#####,
111 )
112}
113
114#[test]
115fn doctest_add_impl_missing_members() {
116 check(
117 "add_impl_missing_members",
118 r#####"
119trait T {
120 Type X;
121 fn foo(&self);
122 fn bar(&self) {}
123}
124
125impl T for () {<|>
126
127}
128"#####,
129 r#####"
130trait T {
131 Type X;
132 fn foo(&self);
133 fn bar(&self) {}
134}
135
136impl T for () {
137 fn foo(&self) { unimplemented!() }
138
139}
140"#####,
141 )
142}
143
144#[test]
145fn doctest_add_import() {
146 check(
147 "add_import",
148 r#####"
149fn process(map: std::collections::<|>HashMap<String, String>) {}
150"#####,
151 r#####"
152use std::collections::HashMap;
153
154fn process(map: HashMap<String, String>) {}
155"#####,
156 )
157}
158
159#[test]
160fn doctest_apply_demorgan() {
161 check(
162 "apply_demorgan",
163 r#####"
164fn main() {
165 if x != 4 ||<|> !y {}
166}
167"#####,
168 r#####"
169fn main() {
170 if !(x == 4 && y) {}
171}
172"#####,
173 )
174}
175
176#[test]
177fn doctest_change_visibility() {
178 check(
179 "change_visibility",
180 r#####"
181<|>fn frobnicate() {}
182"#####,
183 r#####"
184pub(crate) fn frobnicate() {}
185"#####,
186 )
187}
188
189#[test]
190fn doctest_convert_to_guarded_return() {
191 check(
192 "convert_to_guarded_return",
193 r#####"
194fn main() {
195 <|>if cond {
196 foo();
197 bar();
198 }
199}
200"#####,
201 r#####"
202fn main() {
203 if !cond {
204 return;
205 }
206 foo();
207 bar();
208}
209"#####,
210 )
211}
212
213#[test]
214fn doctest_fill_match_arms() {
215 check(
216 "fill_match_arms",
217 r#####"
218enum Action { Move { distance: u32 }, Stop }
219
220fn handle(action: Action) {
221 match action {
222 <|>
223 }
224}
225"#####,
226 r#####"
227enum Action { Move { distance: u32 }, Stop }
228
229fn handle(action: Action) {
230 match action {
231 Action::Move { distance } => (),
232 Action::Stop => (),
233 }
234}
235"#####,
236 )
237}
238
239#[test]
240fn doctest_flip_binexpr() {
241 check(
242 "flip_binexpr",
243 r#####"
244fn main() {
245 let _ = 90 +<|> 2;
246}
247"#####,
248 r#####"
249fn main() {
250 let _ = 2 + 90;
251}
252"#####,
253 )
254}
255
256#[test]
257fn doctest_flip_comma() {
258 check(
259 "flip_comma",
260 r#####"
261fn main() {
262 ((1, 2),<|> (3, 4));
263}
264"#####,
265 r#####"
266fn main() {
267 ((3, 4), (1, 2));
268}
269"#####,
270 )
271}
272
273#[test]
274fn doctest_flip_trait_bound() {
275 check(
276 "flip_trait_bound",
277 r#####"
278fn foo<T: Clone +<|> Copy>() { }
279"#####,
280 r#####"
281fn foo<T: Copy + Clone>() { }
282"#####,
283 )
284}
285
286#[test]
287fn doctest_inline_local_variable() {
288 check(
289 "inline_local_variable",
290 r#####"
291fn main() {
292 let x<|> = 1 + 2;
293 x * 4;
294}
295"#####,
296 r#####"
297fn main() {
298 (1 + 2) * 4;
299}
300"#####,
301 )
302}
303
304#[test]
305fn doctest_introduce_variable() {
306 check(
307 "introduce_variable",
308 r#####"
309fn main() {
310 <|>(1 + 2)<|> * 4;
311}
312"#####,
313 r#####"
314fn main() {
315 let var_name = (1 + 2);
316 var_name * 4;
317}
318"#####,
319 )
320}
321
322#[test]
323fn doctest_make_raw_string() {
324 check(
325 "make_raw_string",
326 r#####"
327fn main() {
328 "Hello,<|> World!";
329}
330"#####,
331 r#####"
332fn main() {
333 r#"Hello, World!"#;
334}
335"#####,
336 )
337}
338
339#[test]
340fn doctest_make_usual_string() {
341 check(
342 "make_usual_string",
343 r#####"
344fn main() {
345 r#"Hello,<|> "World!""#;
346}
347"#####,
348 r#####"
349fn main() {
350 "Hello, \"World!\"";
351}
352"#####,
353 )
354}
355
356#[test]
357fn doctest_merge_match_arms() {
358 check(
359 "merge_match_arms",
360 r#####"
361enum Action { Move { distance: u32 }, Stop }
362
363fn handle(action: Action) {
364 match action {
365 <|>Action::Move(..) => foo(),
366 Action::Stop => foo(),
367 }
368}
369"#####,
370 r#####"
371enum Action { Move { distance: u32 }, Stop }
372
373fn handle(action: Action) {
374 match action {
375 Action::Move(..) | Action::Stop => foo(),
376 }
377}
378"#####,
379 )
380}
381
382#[test]
383fn doctest_move_arm_cond_to_match_guard() {
384 check(
385 "move_arm_cond_to_match_guard",
386 r#####"
387enum Action { Move { distance: u32 }, Stop }
388
389fn handle(action: Action) {
390 match action {
391 Action::Move { distance } => <|>if distance > 10 { foo() },
392 _ => (),
393 }
394}
395"#####,
396 r#####"
397enum Action { Move { distance: u32 }, Stop }
398
399fn handle(action: Action) {
400 match action {
401 Action::Move { distance } if distance > 10 => foo(),
402 _ => (),
403 }
404}
405"#####,
406 )
407}
408
409#[test]
410fn doctest_move_bounds_to_where_clause() {
411 check(
412 "move_bounds_to_where_clause",
413 r#####"
414fn apply<T, U, <|>F: FnOnce(T) -> U>(f: F, x: T) -> U {
415 f(x)
416}
417"#####,
418 r#####"
419fn apply<T, U, F>(f: F, x: T) -> U where F: FnOnce(T) -> U {
420 f(x)
421}
422"#####,
423 )
424}
425
426#[test]
427fn doctest_move_guard_to_arm_body() {
428 check(
429 "move_guard_to_arm_body",
430 r#####"
431enum Action { Move { distance: u32 }, Stop }
432
433fn handle(action: Action) {
434 match action {
435 Action::Move { distance } <|>if distance > 10 => foo(),
436 _ => (),
437 }
438}
439"#####,
440 r#####"
441enum Action { Move { distance: u32 }, Stop }
442
443fn handle(action: Action) {
444 match action {
445 Action::Move { distance } => if distance > 10 { foo() },
446 _ => (),
447 }
448}
449"#####,
450 )
451}
452
453#[test]
454fn doctest_remove_dbg() {
455 check(
456 "remove_dbg",
457 r#####"
458fn main() {
459 <|>dbg!(92);
460}
461"#####,
462 r#####"
463fn main() {
464 92;
465}
466"#####,
467 )
468}
469
470#[test]
471fn doctest_remove_hash() {
472 check(
473 "remove_hash",
474 r#####"
475fn main() {
476 r#"Hello,<|> World!"#;
477}
478"#####,
479 r#####"
480fn main() {
481 r"Hello, World!";
482}
483"#####,
484 )
485}
486
487#[test]
488fn doctest_replace_if_let_with_match() {
489 check(
490 "replace_if_let_with_match",
491 r#####"
492enum Action { Move { distance: u32 }, Stop }
493
494fn handle(action: Action) {
495 <|>if let Action::Move { distance } = action {
496 foo(distance)
497 } else {
498 bar()
499 }
500}
501"#####,
502 r#####"
503enum Action { Move { distance: u32 }, Stop }
504
505fn handle(action: Action) {
506 match action {
507 Action::Move { distance } => foo(distance),
508 _ => bar(),
509 }
510}
511"#####,
512 )
513}
514
515#[test]
516fn doctest_split_import() {
517 check(
518 "split_import",
519 r#####"
520use std::<|>collections::HashMap;
521"#####,
522 r#####"
523use std::{collections::HashMap};
524"#####,
525 )
526}