diff options
Diffstat (limited to 'crates/ra_assists/src/tests')
-rw-r--r-- | crates/ra_assists/src/tests/generated.rs | 68 |
1 files changed, 55 insertions, 13 deletions
diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 972dbd251..250e56a69 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs | |||
@@ -15,7 +15,7 @@ struct S; | |||
15 | struct S; | 15 | struct S; |
16 | 16 | ||
17 | impl Debug for S { | 17 | impl Debug for S { |
18 | 18 | $0 | |
19 | } | 19 | } |
20 | "#####, | 20 | "#####, |
21 | ) | 21 | ) |
@@ -32,7 +32,7 @@ struct Point { | |||
32 | } | 32 | } |
33 | "#####, | 33 | "#####, |
34 | r#####" | 34 | r#####" |
35 | #[derive()] | 35 | #[derive($0)] |
36 | struct Point { | 36 | struct Point { |
37 | x: u32, | 37 | x: u32, |
38 | y: u32, | 38 | y: u32, |
@@ -78,7 +78,7 @@ fn foo() { | |||
78 | } | 78 | } |
79 | 79 | ||
80 | fn bar(arg: &str, baz: Baz) { | 80 | fn bar(arg: &str, baz: Baz) { |
81 | todo!() | 81 | ${0:todo!()} |
82 | } | 82 | } |
83 | 83 | ||
84 | "#####, | 84 | "#####, |
@@ -108,16 +108,16 @@ fn doctest_add_impl() { | |||
108 | "add_impl", | 108 | "add_impl", |
109 | r#####" | 109 | r#####" |
110 | struct Ctx<T: Clone> { | 110 | struct Ctx<T: Clone> { |
111 | data: T,<|> | 111 | data: T,<|> |
112 | } | 112 | } |
113 | "#####, | 113 | "#####, |
114 | r#####" | 114 | r#####" |
115 | struct Ctx<T: Clone> { | 115 | struct Ctx<T: Clone> { |
116 | data: T, | 116 | data: T, |
117 | } | 117 | } |
118 | 118 | ||
119 | impl<T: Clone> Ctx<T> { | 119 | impl<T: Clone> Ctx<T> { |
120 | 120 | $0 | |
121 | } | 121 | } |
122 | "#####, | 122 | "#####, |
123 | ) | 123 | ) |
@@ -150,7 +150,7 @@ trait Trait { | |||
150 | impl Trait for () { | 150 | impl Trait for () { |
151 | Type X = (); | 151 | Type X = (); |
152 | fn foo(&self) {} | 152 | fn foo(&self) {} |
153 | fn bar(&self) {} | 153 | $0fn bar(&self) {} |
154 | 154 | ||
155 | } | 155 | } |
156 | "#####, | 156 | "#####, |
@@ -181,7 +181,7 @@ trait Trait<T> { | |||
181 | 181 | ||
182 | impl Trait<u32> for () { | 182 | impl Trait<u32> for () { |
183 | fn foo(&self) -> u32 { | 183 | fn foo(&self) -> u32 { |
184 | todo!() | 184 | ${0:todo!()} |
185 | } | 185 | } |
186 | 186 | ||
187 | } | 187 | } |
@@ -204,7 +204,7 @@ struct Ctx<T: Clone> { | |||
204 | } | 204 | } |
205 | 205 | ||
206 | impl<T: Clone> Ctx<T> { | 206 | impl<T: Clone> Ctx<T> { |
207 | fn new(data: T) -> Self { Self { data } } | 207 | fn $0new(data: T) -> Self { Self { data } } |
208 | } | 208 | } |
209 | 209 | ||
210 | "#####, | 210 | "#####, |
@@ -212,6 +212,25 @@ impl<T: Clone> Ctx<T> { | |||
212 | } | 212 | } |
213 | 213 | ||
214 | #[test] | 214 | #[test] |
215 | fn doctest_add_turbo_fish() { | ||
216 | check_doc_test( | ||
217 | "add_turbo_fish", | ||
218 | r#####" | ||
219 | fn make<T>() -> T { todo!() } | ||
220 | fn main() { | ||
221 | let x = make<|>(); | ||
222 | } | ||
223 | "#####, | ||
224 | r#####" | ||
225 | fn make<T>() -> T { todo!() } | ||
226 | fn main() { | ||
227 | let x = make::<${0:_}>(); | ||
228 | } | ||
229 | "#####, | ||
230 | ) | ||
231 | } | ||
232 | |||
233 | #[test] | ||
215 | fn doctest_apply_demorgan() { | 234 | fn doctest_apply_demorgan() { |
216 | check_doc_test( | 235 | check_doc_test( |
217 | "apply_demorgan", | 236 | "apply_demorgan", |
@@ -257,7 +276,7 @@ fn doctest_change_return_type_to_result() { | |||
257 | fn foo() -> i32<|> { 42i32 } | 276 | fn foo() -> i32<|> { 42i32 } |
258 | "#####, | 277 | "#####, |
259 | r#####" | 278 | r#####" |
260 | fn foo() -> Result<i32, > { Ok(42i32) } | 279 | fn foo() -> Result<i32, ${0:_}> { Ok(42i32) } |
261 | "#####, | 280 | "#####, |
262 | ) | 281 | ) |
263 | } | 282 | } |
@@ -317,7 +336,7 @@ enum Action { Move { distance: u32 }, Stop } | |||
317 | 336 | ||
318 | fn handle(action: Action) { | 337 | fn handle(action: Action) { |
319 | match action { | 338 | match action { |
320 | Action::Move { distance } => {} | 339 | $0Action::Move { distance } => {} |
321 | Action::Stop => {} | 340 | Action::Stop => {} |
322 | } | 341 | } |
323 | } | 342 | } |
@@ -326,6 +345,29 @@ fn handle(action: Action) { | |||
326 | } | 345 | } |
327 | 346 | ||
328 | #[test] | 347 | #[test] |
348 | fn doctest_fix_visibility() { | ||
349 | check_doc_test( | ||
350 | "fix_visibility", | ||
351 | r#####" | ||
352 | mod m { | ||
353 | fn frobnicate() {} | ||
354 | } | ||
355 | fn main() { | ||
356 | m::frobnicate<|>() {} | ||
357 | } | ||
358 | "#####, | ||
359 | r#####" | ||
360 | mod m { | ||
361 | $0pub(crate) fn frobnicate() {} | ||
362 | } | ||
363 | fn main() { | ||
364 | m::frobnicate() {} | ||
365 | } | ||
366 | "#####, | ||
367 | ) | ||
368 | } | ||
369 | |||
370 | #[test] | ||
329 | fn doctest_flip_binexpr() { | 371 | fn doctest_flip_binexpr() { |
330 | check_doc_test( | 372 | check_doc_test( |
331 | "flip_binexpr", | 373 | "flip_binexpr", |
@@ -401,7 +443,7 @@ fn main() { | |||
401 | "#####, | 443 | "#####, |
402 | r#####" | 444 | r#####" |
403 | fn main() { | 445 | fn main() { |
404 | let var_name = (1 + 2); | 446 | let $0var_name = (1 + 2); |
405 | var_name * 4; | 447 | var_name * 4; |
406 | } | 448 | } |
407 | "#####, | 449 | "#####, |
@@ -722,7 +764,7 @@ fn main() { | |||
722 | let x: Result<i32, i32> = Result::Ok(92); | 764 | let x: Result<i32, i32> = Result::Ok(92); |
723 | let y = match x { | 765 | let y = match x { |
724 | Ok(a) => a, | 766 | Ok(a) => a, |
725 | _ => unreachable!(), | 767 | $0_ => unreachable!(), |
726 | }; | 768 | }; |
727 | } | 769 | } |
728 | "#####, | 770 | "#####, |