Skip to content

Commit 4ef1d53

Browse files
author
Jonas Schievink
committed
ItemTree: Lower fields despite invalid type
1 parent ad1a0e6 commit 4ef1d53

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

crates/ra_hir_def/src/item_tree/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl Ctx {
211211
fn lower_record_field(&mut self, field: &ast::RecordFieldDef) -> Option<Field> {
212212
let name = field.name()?.as_name();
213213
let visibility = self.lower_visibility(field);
214-
let type_ref = self.lower_type_ref(&field.ascribed_type()?);
214+
let type_ref = self.lower_type_ref_opt(field.ascribed_type());
215215
let res = Field { name, type_ref, visibility };
216216
Some(res)
217217
}

crates/ra_hir_ty/src/tests.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,30 @@ fn no_such_field_with_feature_flag_diagnostics_on_struct_fields() {
507507
assert_snapshot!(diagnostics, @r###""###);
508508
}
509509

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+
510534
#[test]
511535
fn missing_record_pat_field_diagnostic() {
512536
let diagnostics = TestDB::with_files(

0 commit comments

Comments
 (0)