From 4ef1d533bd26876125199208349701c2369c965c Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 1 Jul 2020 19:24:39 +0200 Subject: [PATCH] ItemTree: Lower fields despite invalid type --- crates/ra_hir_def/src/item_tree/lower.rs | 2 +- crates/ra_hir_ty/src/tests.rs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 5149dd141ff..06743d7fce2 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -211,7 +211,7 @@ fn lower_record_fields(&mut self, fields: &ast::RecordFieldDefList) -> IdRange Option { let name = field.name()?.as_name(); let visibility = self.lower_visibility(field); - let type_ref = self.lower_type_ref(&field.ascribed_type()?); + let type_ref = self.lower_type_ref_opt(field.ascribed_type()); let res = Field { name, type_ref, visibility }; Some(res) } diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 9084c3bed2c..eeac34d1405 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -507,6 +507,30 @@ fn new(val: u32) -> Self { assert_snapshot!(diagnostics, @r###""###); } +#[test] +fn no_such_field_with_type_macro() { + let diagnostics = TestDB::with_files( + r" + macro_rules! Type { + () => { u32 }; + } + + struct Foo { + bar: Type![], + } + impl Foo { + fn new() -> Self { + Foo { bar: 0 } + } + } + ", + ) + .diagnostics() + .0; + + assert_snapshot!(diagnostics, @r###""###); +} + #[test] fn missing_record_pat_field_diagnostic() { let diagnostics = TestDB::with_files(