diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 5424e6bb1..eeac34d14 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -28,7 +28,6 @@ use ra_syntax::{ | |||
28 | SyntaxNode, | 28 | SyntaxNode, |
29 | }; | 29 | }; |
30 | use stdx::format_to; | 30 | use stdx::format_to; |
31 | use test_utils::extract_annotations; | ||
32 | 31 | ||
33 | use crate::{ | 32 | use crate::{ |
34 | db::HirDatabase, display::HirDisplay, infer::TypeMismatch, test_db::TestDB, InferenceResult, Ty, | 33 | db::HirDatabase, display::HirDisplay, infer::TypeMismatch, test_db::TestDB, InferenceResult, Ty, |
@@ -49,9 +48,7 @@ fn check_types_source_code(ra_fixture: &str) { | |||
49 | fn check_types_impl(ra_fixture: &str, display_source: bool) { | 48 | fn check_types_impl(ra_fixture: &str, display_source: bool) { |
50 | let db = TestDB::with_files(ra_fixture); | 49 | let db = TestDB::with_files(ra_fixture); |
51 | let mut checked_one = false; | 50 | let mut checked_one = false; |
52 | for file_id in db.all_files() { | 51 | for (file_id, annotations) in db.extract_annotations() { |
53 | let text = db.parse(file_id).syntax_node().to_string(); | ||
54 | let annotations = extract_annotations(&text); | ||
55 | for (range, expected) in annotations { | 52 | for (range, expected) in annotations { |
56 | let ty = type_at_range(&db, FileRange { file_id, range }); | 53 | let ty = type_at_range(&db, FileRange { file_id, range }); |
57 | let actual = if display_source { | 54 | let actual = if display_source { |
@@ -511,6 +508,30 @@ fn no_such_field_with_feature_flag_diagnostics_on_struct_fields() { | |||
511 | } | 508 | } |
512 | 509 | ||
513 | #[test] | 510 | #[test] |
511 | fn no_such_field_with_type_macro() { | ||
512 | let diagnostics = TestDB::with_files( | ||
513 | r" | ||
514 | macro_rules! Type { | ||
515 | () => { u32 }; | ||
516 | } | ||
517 | |||
518 | struct Foo { | ||
519 | bar: Type![], | ||
520 | } | ||
521 | impl Foo { | ||
522 | fn new() -> Self { | ||
523 | Foo { bar: 0 } | ||
524 | } | ||
525 | } | ||
526 | ", | ||
527 | ) | ||
528 | .diagnostics() | ||
529 | .0; | ||
530 | |||
531 | assert_snapshot!(diagnostics, @r###""###); | ||
532 | } | ||
533 | |||
534 | #[test] | ||
514 | fn missing_record_pat_field_diagnostic() { | 535 | fn missing_record_pat_field_diagnostic() { |
515 | let diagnostics = TestDB::with_files( | 536 | let diagnostics = TestDB::with_files( |
516 | r" | 537 | r" |