From e45f476d5691a6a0d994eb6f777bbf291348f93e Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 21 Jan 2019 21:42:19 +0100 Subject: Fix panic trying to get substs on unknown type Fixes #585. --- crates/ra_hir/src/ty/tests.rs | 16 ++++++++++++++++ crates/ra_hir/src/ty/tests/data/bug_585.txt | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 crates/ra_hir/src/ty/tests/data/bug_585.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 5aa24a29b..dc9b626dc 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -521,6 +521,22 @@ fn test(x: X) { ); } +#[test] +fn bug_585() { + check_inference( + r#" +fn test() { + X {}; + match x { + A::B {} => (), + A::Y() => (), + } +} +"#, + "bug_585.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/bug_585.txt b/crates/ra_hir/src/ty/tests/data/bug_585.txt new file mode 100644 index 000000000..627702a38 --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/bug_585.txt @@ -0,0 +1,8 @@ +[11; 89) '{ ... } }': () +[17; 21) 'X {}': [unknown] +[27; 87) 'match ... }': () +[33; 34) 'x': [unknown] +[45; 52) 'A::B {}': [unknown] +[56; 58) '()': () +[68; 74) 'A::Y()': [unknown] +[78; 80) '()': () -- cgit v1.2.3