From 3c4a4c6ae9f62c960ba118b6e1941ba006d221d7 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 20 Jan 2019 18:08:25 +0100 Subject: Fix panic on inferring field access on an enum --- crates/ra_hir/src/ty/tests.rs | 14 ++++++++++++++ .../ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 06e32df59..5aa24a29b 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -507,6 +507,20 @@ fn test() -> i128 { ); } +#[test] +fn no_panic_on_field_of_enum() { + check_inference( + r#" +enum X {} + +fn test(x: X) { + x.some_field; +} +"#, + "no_panic_on_field_of_enum.txt", + ); +} + fn infer(content: &str) -> String { let (db, _, file_id) = MockDatabase::with_single_file(content); let source_file = db.source_file(file_id); diff --git a/crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt b/crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt new file mode 100644 index 000000000..4dca0b7f4 --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt @@ -0,0 +1,4 @@ +[20; 21) 'x': X +[26; 47) '{ ...eld; }': () +[32; 33) 'x': X +[32; 44) 'x.some_field': [unknown] -- cgit v1.2.3