diff options
Diffstat (limited to 'crates/ra_ide/src/diagnostics.rs')
-rw-r--r-- | crates/ra_ide/src/diagnostics.rs | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 8cb0700b9..05fb799d6 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs | |||
@@ -348,8 +348,10 @@ mod tests { | |||
348 | ); | 348 | ); |
349 | } | 349 | } |
350 | 350 | ||
351 | fn check_apply_diagnostic_fix(before: &str, after: &str) { | 351 | fn check_apply_diagnostic_fix(ra_fixture_before: &str, ra_fixture_after: &str) { |
352 | let (analysis, file_id) = single_file(before); | 352 | let ra_fixture_after = &trim_indent(ra_fixture_after); |
353 | let (analysis, file_id) = single_file(ra_fixture_before); | ||
354 | let before = analysis.file_text(file_id).unwrap(); | ||
353 | let diagnostic = analysis.diagnostics(file_id).unwrap().pop().unwrap(); | 355 | let diagnostic = analysis.diagnostics(file_id).unwrap().pop().unwrap(); |
354 | let mut fix = diagnostic.fix.unwrap(); | 356 | let mut fix = diagnostic.fix.unwrap(); |
355 | let edit = fix.source_change.source_file_edits.pop().unwrap().edit; | 357 | let edit = fix.source_change.source_file_edits.pop().unwrap().edit; |
@@ -358,7 +360,7 @@ mod tests { | |||
358 | edit.apply(&mut actual); | 360 | edit.apply(&mut actual); |
359 | actual | 361 | actual |
360 | }; | 362 | }; |
361 | assert_eq_text!(after, &actual); | 363 | assert_eq_text!(ra_fixture_after, &actual); |
362 | } | 364 | } |
363 | 365 | ||
364 | /// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics | 366 | /// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics |
@@ -571,10 +573,9 @@ mod tests { | |||
571 | 573 | ||
572 | impl Expr { | 574 | impl Expr { |
573 | fn new_bin(lhs: Box<Expr>, rhs: Box<Expr>) -> Expr { | 575 | fn new_bin(lhs: Box<Expr>, rhs: Box<Expr>) -> Expr { |
574 | Expr::Bin { <|> } | 576 | Expr::Bin { } |
575 | } | 577 | } |
576 | } | 578 | } |
577 | |||
578 | "; | 579 | "; |
579 | let after = r" | 580 | let after = r" |
580 | enum Expr { | 581 | enum Expr { |
@@ -583,10 +584,9 @@ mod tests { | |||
583 | 584 | ||
584 | impl Expr { | 585 | impl Expr { |
585 | fn new_bin(lhs: Box<Expr>, rhs: Box<Expr>) -> Expr { | 586 | fn new_bin(lhs: Box<Expr>, rhs: Box<Expr>) -> Expr { |
586 | Expr::Bin { lhs: (), rhs: () <|> } | 587 | Expr::Bin { lhs: (), rhs: () } |
587 | } | 588 | } |
588 | } | 589 | } |
589 | |||
590 | "; | 590 | "; |
591 | check_apply_diagnostic_fix(before, after); | 591 | check_apply_diagnostic_fix(before, after); |
592 | } | 592 | } |
@@ -709,7 +709,7 @@ mod tests { | |||
709 | [ | 709 | [ |
710 | Diagnostic { | 710 | Diagnostic { |
711 | message: "Missing structure fields:\n- b\n", | 711 | message: "Missing structure fields:\n- b\n", |
712 | range: 224..233, | 712 | range: 127..136, |
713 | severity: Error, | 713 | severity: Error, |
714 | fix: Some( | 714 | fix: Some( |
715 | Fix { | 715 | Fix { |
@@ -855,22 +855,22 @@ fn main() { | |||
855 | fn test_add_field_from_usage() { | 855 | fn test_add_field_from_usage() { |
856 | check_apply_diagnostic_fix( | 856 | check_apply_diagnostic_fix( |
857 | r" | 857 | r" |
858 | fn main() { | 858 | fn main() { |
859 | Foo { bar: 3, baz: false}; | 859 | Foo { bar: 3, baz: false}; |
860 | } | 860 | } |
861 | struct Foo { | 861 | struct Foo { |
862 | bar: i32 | 862 | bar: i32 |
863 | } | 863 | } |
864 | ", | 864 | ", |
865 | r" | 865 | r" |
866 | fn main() { | 866 | fn main() { |
867 | Foo { bar: 3, baz: false}; | 867 | Foo { bar: 3, baz: false}; |
868 | } | 868 | } |
869 | struct Foo { | 869 | struct Foo { |
870 | bar: i32, | 870 | bar: i32, |
871 | baz: bool | 871 | baz: bool |
872 | } | 872 | } |
873 | ", | 873 | ", |
874 | ) | 874 | ) |
875 | } | 875 | } |
876 | } | 876 | } |