aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/tests.rs14
-rw-r--r--crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt4
2 files changed, 18 insertions, 0 deletions
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 {
507 ); 507 );
508} 508}
509 509
510#[test]
511fn no_panic_on_field_of_enum() {
512 check_inference(
513 r#"
514enum X {}
515
516fn test(x: X) {
517 x.some_field;
518}
519"#,
520 "no_panic_on_field_of_enum.txt",
521 );
522}
523
510fn infer(content: &str) -> String { 524fn infer(content: &str) -> String {
511 let (db, _, file_id) = MockDatabase::with_single_file(content); 525 let (db, _, file_id) = MockDatabase::with_single_file(content);
512 let source_file = db.source_file(file_id); 526 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 @@
1[20; 21) 'x': X
2[26; 47) '{ ...eld; }': ()
3[32; 33) 'x': X
4[32; 44) 'x.some_field': [unknown]