Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/tests/diagnostics.rs')
| -rw-r--r-- | crates/hir-ty/src/tests/diagnostics.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/hir-ty/src/tests/diagnostics.rs b/crates/hir-ty/src/tests/diagnostics.rs index def06f2d59..d0d31bf2a5 100644 --- a/crates/hir-ty/src/tests/diagnostics.rs +++ b/crates/hir-ty/src/tests/diagnostics.rs @@ -153,3 +153,28 @@ fn consume() -> Option<()> { "#, ); } + +#[test] +fn method_call_on_field() { + check( + r#" +struct S { + field: fn() -> u32, + field2: u32 +} + +fn main() { + let s = S { field: || 0, field2: 0 }; + s.field(0); + // ^ type: i32 + // ^^^^^^^^^^ type: u32 + s.field2(0); + // ^ type: i32 + // ^^^^^^^^^^^ type: u32 + s.not_a_field(0); + // ^ type: i32 + // ^^^^^^^^^^^^^^^^ type: {unknown} +} +"#, + ); +} |