aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_assists/src/tests.rs2
-rw-r--r--crates/ra_assists/src/tests/generated.rs76
-rw-r--r--xtask/src/codegen.rs2
-rw-r--r--xtask/src/codegen/gen_assists_docs.rs4
-rw-r--r--xtask/tests/tidy-tests/main.rs2
5 files changed, 44 insertions, 42 deletions
diff --git a/crates/ra_assists/src/tests.rs b/crates/ra_assists/src/tests.rs
index 97744904a..483e11931 100644
--- a/crates/ra_assists/src/tests.rs
+++ b/crates/ra_assists/src/tests.rs
@@ -1,3 +1,5 @@
1mod generated;
2
1use std::sync::Arc; 3use std::sync::Arc;
2 4
3use hir::Semantics; 5use hir::Semantics;
diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs
index 6696cc832..7d35fa284 100644
--- a/crates/ra_assists/src/tests/generated.rs
+++ b/crates/ra_assists/src/tests/generated.rs
@@ -1,10 +1,10 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen` 1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2 2
3use super::check; 3use super::check_doc_test;
4 4
5#[test] 5#[test]
6fn doctest_add_custom_impl() { 6fn doctest_add_custom_impl() {
7 check( 7 check_doc_test(
8 "add_custom_impl", 8 "add_custom_impl",
9 r#####" 9 r#####"
10#[derive(Deb<|>ug, Display)] 10#[derive(Deb<|>ug, Display)]
@@ -23,7 +23,7 @@ impl Debug for S {
23 23
24#[test] 24#[test]
25fn doctest_add_derive() { 25fn doctest_add_derive() {
26 check( 26 check_doc_test(
27 "add_derive", 27 "add_derive",
28 r#####" 28 r#####"
29struct Point { 29struct Point {
@@ -43,7 +43,7 @@ struct Point {
43 43
44#[test] 44#[test]
45fn doctest_add_explicit_type() { 45fn doctest_add_explicit_type() {
46 check( 46 check_doc_test(
47 "add_explicit_type", 47 "add_explicit_type",
48 r#####" 48 r#####"
49fn main() { 49fn main() {
@@ -60,7 +60,7 @@ fn main() {
60 60
61#[test] 61#[test]
62fn doctest_add_function() { 62fn doctest_add_function() {
63 check( 63 check_doc_test(
64 "add_function", 64 "add_function",
65 r#####" 65 r#####"
66struct Baz; 66struct Baz;
@@ -87,7 +87,7 @@ fn bar(arg: &str, baz: Baz) {
87 87
88#[test] 88#[test]
89fn doctest_add_hash() { 89fn doctest_add_hash() {
90 check( 90 check_doc_test(
91 "add_hash", 91 "add_hash",
92 r#####" 92 r#####"
93fn main() { 93fn main() {
@@ -104,7 +104,7 @@ fn main() {
104 104
105#[test] 105#[test]
106fn doctest_add_impl() { 106fn doctest_add_impl() {
107 check( 107 check_doc_test(
108 "add_impl", 108 "add_impl",
109 r#####" 109 r#####"
110struct Ctx<T: Clone> { 110struct Ctx<T: Clone> {
@@ -125,7 +125,7 @@ impl<T: Clone> Ctx<T> {
125 125
126#[test] 126#[test]
127fn doctest_add_impl_default_members() { 127fn doctest_add_impl_default_members() {
128 check( 128 check_doc_test(
129 "add_impl_default_members", 129 "add_impl_default_members",
130 r#####" 130 r#####"
131trait Trait { 131trait Trait {
@@ -159,7 +159,7 @@ impl Trait for () {
159 159
160#[test] 160#[test]
161fn doctest_add_impl_missing_members() { 161fn doctest_add_impl_missing_members() {
162 check( 162 check_doc_test(
163 "add_impl_missing_members", 163 "add_impl_missing_members",
164 r#####" 164 r#####"
165trait Trait<T> { 165trait Trait<T> {
@@ -191,7 +191,7 @@ impl Trait<u32> for () {
191 191
192#[test] 192#[test]
193fn doctest_add_new() { 193fn doctest_add_new() {
194 check( 194 check_doc_test(
195 "add_new", 195 "add_new",
196 r#####" 196 r#####"
197struct Ctx<T: Clone> { 197struct Ctx<T: Clone> {
@@ -213,7 +213,7 @@ impl<T: Clone> Ctx<T> {
213 213
214#[test] 214#[test]
215fn doctest_apply_demorgan() { 215fn doctest_apply_demorgan() {
216 check( 216 check_doc_test(
217 "apply_demorgan", 217 "apply_demorgan",
218 r#####" 218 r#####"
219fn main() { 219fn main() {
@@ -230,7 +230,7 @@ fn main() {
230 230
231#[test] 231#[test]
232fn doctest_auto_import() { 232fn doctest_auto_import() {
233 check( 233 check_doc_test(
234 "auto_import", 234 "auto_import",
235 r#####" 235 r#####"
236fn main() { 236fn main() {
@@ -251,7 +251,7 @@ pub mod std { pub mod collections { pub struct HashMap { } } }
251 251
252#[test] 252#[test]
253fn doctest_change_visibility() { 253fn doctest_change_visibility() {
254 check( 254 check_doc_test(
255 "change_visibility", 255 "change_visibility",
256 r#####" 256 r#####"
257<|>fn frobnicate() {} 257<|>fn frobnicate() {}
@@ -264,7 +264,7 @@ pub(crate) fn frobnicate() {}
264 264
265#[test] 265#[test]
266fn doctest_convert_to_guarded_return() { 266fn doctest_convert_to_guarded_return() {
267 check( 267 check_doc_test(
268 "convert_to_guarded_return", 268 "convert_to_guarded_return",
269 r#####" 269 r#####"
270fn main() { 270fn main() {
@@ -288,7 +288,7 @@ fn main() {
288 288
289#[test] 289#[test]
290fn doctest_fill_match_arms() { 290fn doctest_fill_match_arms() {
291 check( 291 check_doc_test(
292 "fill_match_arms", 292 "fill_match_arms",
293 r#####" 293 r#####"
294enum Action { Move { distance: u32 }, Stop } 294enum Action { Move { distance: u32 }, Stop }
@@ -314,7 +314,7 @@ fn handle(action: Action) {
314 314
315#[test] 315#[test]
316fn doctest_flip_binexpr() { 316fn doctest_flip_binexpr() {
317 check( 317 check_doc_test(
318 "flip_binexpr", 318 "flip_binexpr",
319 r#####" 319 r#####"
320fn main() { 320fn main() {
@@ -331,7 +331,7 @@ fn main() {
331 331
332#[test] 332#[test]
333fn doctest_flip_comma() { 333fn doctest_flip_comma() {
334 check( 334 check_doc_test(
335 "flip_comma", 335 "flip_comma",
336 r#####" 336 r#####"
337fn main() { 337fn main() {
@@ -348,7 +348,7 @@ fn main() {
348 348
349#[test] 349#[test]
350fn doctest_flip_trait_bound() { 350fn doctest_flip_trait_bound() {
351 check( 351 check_doc_test(
352 "flip_trait_bound", 352 "flip_trait_bound",
353 r#####" 353 r#####"
354fn foo<T: Clone +<|> Copy>() { } 354fn foo<T: Clone +<|> Copy>() { }
@@ -361,7 +361,7 @@ fn foo<T: Copy + Clone>() { }
361 361
362#[test] 362#[test]
363fn doctest_inline_local_variable() { 363fn doctest_inline_local_variable() {
364 check( 364 check_doc_test(
365 "inline_local_variable", 365 "inline_local_variable",
366 r#####" 366 r#####"
367fn main() { 367fn main() {
@@ -379,7 +379,7 @@ fn main() {
379 379
380#[test] 380#[test]
381fn doctest_introduce_variable() { 381fn doctest_introduce_variable() {
382 check( 382 check_doc_test(
383 "introduce_variable", 383 "introduce_variable",
384 r#####" 384 r#####"
385fn main() { 385fn main() {
@@ -397,7 +397,7 @@ fn main() {
397 397
398#[test] 398#[test]
399fn doctest_invert_if() { 399fn doctest_invert_if() {
400 check( 400 check_doc_test(
401 "invert_if", 401 "invert_if",
402 r#####" 402 r#####"
403fn main() { 403fn main() {
@@ -414,7 +414,7 @@ fn main() {
414 414
415#[test] 415#[test]
416fn doctest_make_raw_string() { 416fn doctest_make_raw_string() {
417 check( 417 check_doc_test(
418 "make_raw_string", 418 "make_raw_string",
419 r#####" 419 r#####"
420fn main() { 420fn main() {
@@ -431,7 +431,7 @@ fn main() {
431 431
432#[test] 432#[test]
433fn doctest_make_usual_string() { 433fn doctest_make_usual_string() {
434 check( 434 check_doc_test(
435 "make_usual_string", 435 "make_usual_string",
436 r#####" 436 r#####"
437fn main() { 437fn main() {
@@ -448,7 +448,7 @@ fn main() {
448 448
449#[test] 449#[test]
450fn doctest_merge_imports() { 450fn doctest_merge_imports() {
451 check( 451 check_doc_test(
452 "merge_imports", 452 "merge_imports",
453 r#####" 453 r#####"
454use std::<|>fmt::Formatter; 454use std::<|>fmt::Formatter;
@@ -462,7 +462,7 @@ use std::{fmt::Formatter, io};
462 462
463#[test] 463#[test]
464fn doctest_merge_match_arms() { 464fn doctest_merge_match_arms() {
465 check( 465 check_doc_test(
466 "merge_match_arms", 466 "merge_match_arms",
467 r#####" 467 r#####"
468enum Action { Move { distance: u32 }, Stop } 468enum Action { Move { distance: u32 }, Stop }
@@ -488,7 +488,7 @@ fn handle(action: Action) {
488 488
489#[test] 489#[test]
490fn doctest_move_arm_cond_to_match_guard() { 490fn doctest_move_arm_cond_to_match_guard() {
491 check( 491 check_doc_test(
492 "move_arm_cond_to_match_guard", 492 "move_arm_cond_to_match_guard",
493 r#####" 493 r#####"
494enum Action { Move { distance: u32 }, Stop } 494enum Action { Move { distance: u32 }, Stop }
@@ -515,7 +515,7 @@ fn handle(action: Action) {
515 515
516#[test] 516#[test]
517fn doctest_move_bounds_to_where_clause() { 517fn doctest_move_bounds_to_where_clause() {
518 check( 518 check_doc_test(
519 "move_bounds_to_where_clause", 519 "move_bounds_to_where_clause",
520 r#####" 520 r#####"
521fn apply<T, U, <|>F: FnOnce(T) -> U>(f: F, x: T) -> U { 521fn apply<T, U, <|>F: FnOnce(T) -> U>(f: F, x: T) -> U {
@@ -532,7 +532,7 @@ fn apply<T, U, F>(f: F, x: T) -> U where F: FnOnce(T) -> U {
532 532
533#[test] 533#[test]
534fn doctest_move_guard_to_arm_body() { 534fn doctest_move_guard_to_arm_body() {
535 check( 535 check_doc_test(
536 "move_guard_to_arm_body", 536 "move_guard_to_arm_body",
537 r#####" 537 r#####"
538enum Action { Move { distance: u32 }, Stop } 538enum Action { Move { distance: u32 }, Stop }
@@ -559,7 +559,7 @@ fn handle(action: Action) {
559 559
560#[test] 560#[test]
561fn doctest_remove_dbg() { 561fn doctest_remove_dbg() {
562 check( 562 check_doc_test(
563 "remove_dbg", 563 "remove_dbg",
564 r#####" 564 r#####"
565fn main() { 565fn main() {
@@ -576,7 +576,7 @@ fn main() {
576 576
577#[test] 577#[test]
578fn doctest_remove_hash() { 578fn doctest_remove_hash() {
579 check( 579 check_doc_test(
580 "remove_hash", 580 "remove_hash",
581 r#####" 581 r#####"
582fn main() { 582fn main() {
@@ -593,7 +593,7 @@ fn main() {
593 593
594#[test] 594#[test]
595fn doctest_remove_mut() { 595fn doctest_remove_mut() {
596 check( 596 check_doc_test(
597 "remove_mut", 597 "remove_mut",
598 r#####" 598 r#####"
599impl Walrus { 599impl Walrus {
@@ -610,7 +610,7 @@ impl Walrus {
610 610
611#[test] 611#[test]
612fn doctest_reorder_fields() { 612fn doctest_reorder_fields() {
613 check( 613 check_doc_test(
614 "reorder_fields", 614 "reorder_fields",
615 r#####" 615 r#####"
616struct Foo {foo: i32, bar: i32}; 616struct Foo {foo: i32, bar: i32};
@@ -625,7 +625,7 @@ const test: Foo = Foo {foo: 1, bar: 0}
625 625
626#[test] 626#[test]
627fn doctest_replace_if_let_with_match() { 627fn doctest_replace_if_let_with_match() {
628 check( 628 check_doc_test(
629 "replace_if_let_with_match", 629 "replace_if_let_with_match",
630 r#####" 630 r#####"
631enum Action { Move { distance: u32 }, Stop } 631enum Action { Move { distance: u32 }, Stop }
@@ -653,7 +653,7 @@ fn handle(action: Action) {
653 653
654#[test] 654#[test]
655fn doctest_replace_let_with_if_let() { 655fn doctest_replace_let_with_if_let() {
656 check( 656 check_doc_test(
657 "replace_let_with_if_let", 657 "replace_let_with_if_let",
658 r#####" 658 r#####"
659enum Option<T> { Some(T), None } 659enum Option<T> { Some(T), None }
@@ -679,7 +679,7 @@ fn compute() -> Option<i32> { None }
679 679
680#[test] 680#[test]
681fn doctest_replace_qualified_name_with_use() { 681fn doctest_replace_qualified_name_with_use() {
682 check( 682 check_doc_test(
683 "replace_qualified_name_with_use", 683 "replace_qualified_name_with_use",
684 r#####" 684 r#####"
685fn process(map: std::collections::<|>HashMap<String, String>) {} 685fn process(map: std::collections::<|>HashMap<String, String>) {}
@@ -694,7 +694,7 @@ fn process(map: HashMap<String, String>) {}
694 694
695#[test] 695#[test]
696fn doctest_replace_unwrap_with_match() { 696fn doctest_replace_unwrap_with_match() {
697 check( 697 check_doc_test(
698 "replace_unwrap_with_match", 698 "replace_unwrap_with_match",
699 r#####" 699 r#####"
700enum Result<T, E> { Ok(T), Err(E) } 700enum Result<T, E> { Ok(T), Err(E) }
@@ -718,7 +718,7 @@ fn main() {
718 718
719#[test] 719#[test]
720fn doctest_split_import() { 720fn doctest_split_import() {
721 check( 721 check_doc_test(
722 "split_import", 722 "split_import",
723 r#####" 723 r#####"
724use std::<|>collections::HashMap; 724use std::<|>collections::HashMap;
@@ -731,7 +731,7 @@ use std::{collections::HashMap};
731 731
732#[test] 732#[test]
733fn doctest_unwrap_block() { 733fn doctest_unwrap_block() {
734 check( 734 check_doc_test(
735 "unwrap_block", 735 "unwrap_block",
736 r#####" 736 r#####"
737fn foo() { 737fn foo() {
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs
index 0e4dcb95a..b4907f4b2 100644
--- a/xtask/src/codegen.rs
+++ b/xtask/src/codegen.rs
@@ -27,7 +27,7 @@ const AST_NODES: &str = "crates/ra_syntax/src/ast/generated/nodes.rs";
27const AST_TOKENS: &str = "crates/ra_syntax/src/ast/generated/tokens.rs"; 27const AST_TOKENS: &str = "crates/ra_syntax/src/ast/generated/tokens.rs";
28 28
29const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; 29const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers";
30const ASSISTS_TESTS: &str = "crates/ra_assists/src/doc_tests/generated.rs"; 30const ASSISTS_TESTS: &str = "crates/ra_assists/src/tests/generated.rs";
31const ASSISTS_DOCS: &str = "docs/user/assists.md"; 31const ASSISTS_DOCS: &str = "docs/user/assists.md";
32 32
33#[derive(Debug, PartialEq, Eq, Clone, Copy)] 33#[derive(Debug, PartialEq, Eq, Clone, Copy)]
diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs
index 31d606535..4bd6b5f0c 100644
--- a/xtask/src/codegen/gen_assists_docs.rs
+++ b/xtask/src/codegen/gen_assists_docs.rs
@@ -101,14 +101,14 @@ fn collect_assists() -> Result<Vec<Assist>> {
101} 101}
102 102
103fn generate_tests(assists: &[Assist], mode: Mode) -> Result<()> { 103fn generate_tests(assists: &[Assist], mode: Mode) -> Result<()> {
104 let mut buf = String::from("use super::check;\n"); 104 let mut buf = String::from("use super::check_doc_test;\n");
105 105
106 for assist in assists.iter() { 106 for assist in assists.iter() {
107 let test = format!( 107 let test = format!(
108 r######" 108 r######"
109#[test] 109#[test]
110fn doctest_{}() {{ 110fn doctest_{}() {{
111 check( 111 check_doc_test(
112 "{}", 112 "{}",
113r#####" 113r#####"
114{}"#####, r#####" 114{}"#####, r#####"
diff --git a/xtask/tests/tidy-tests/main.rs b/xtask/tests/tidy-tests/main.rs
index 3213c4dfa..a3c2e37d1 100644
--- a/xtask/tests/tidy-tests/main.rs
+++ b/xtask/tests/tidy-tests/main.rs
@@ -24,7 +24,7 @@ fn check_todo(path: &Path, text: &str) {
24 // This file itself is whitelisted since this test itself contains matches. 24 // This file itself is whitelisted since this test itself contains matches.
25 "tests/cli.rs", 25 "tests/cli.rs",
26 // Some of our assists generate `todo!()` so those files are whitelisted. 26 // Some of our assists generate `todo!()` so those files are whitelisted.
27 "doc_tests/generated.rs", 27 "tests/generated.rs",
28 "handlers/add_missing_impl_members.rs", 28 "handlers/add_missing_impl_members.rs",
29 "handlers/add_function.rs", 29 "handlers/add_function.rs",
30 // To support generating `todo!()` in assists, we have `expr_todo()` in ast::make. 30 // To support generating `todo!()` in assists, we have `expr_todo()` in ast::make.