diff options
author | Florian Diebold <[email protected]> | 2019-01-20 17:08:25 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-01-20 17:14:19 +0000 |
commit | 3c4a4c6ae9f62c960ba118b6e1941ba006d221d7 (patch) | |
tree | c8a345fb3117a17508e7f31a9f286f62903e7044 /crates/ra_hir/src/ty | |
parent | 1c296d54e3dcc36c1a778873f26035000a352ba2 (diff) |
Fix panic on inferring field access on an enum
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 14 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt | 4 |
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] | ||
511 | fn no_panic_on_field_of_enum() { | ||
512 | check_inference( | ||
513 | r#" | ||
514 | enum X {} | ||
515 | |||
516 | fn test(x: X) { | ||
517 | x.some_field; | ||
518 | } | ||
519 | "#, | ||
520 | "no_panic_on_field_of_enum.txt", | ||
521 | ); | ||
522 | } | ||
523 | |||
510 | fn infer(content: &str) -> String { | 524 | fn 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] | ||