aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-02-09 17:24:54 +0000
committerFlorian Diebold <[email protected]>2019-02-09 20:37:09 +0000
commit7ebde241c00cd9eb816b1aa7cb212a946afb0d3e (patch)
treeca49de264fa411c62216952b52b865fcce5bdabe /crates/ra_hir/src/ty/tests.rs
parent8bcb84ea681f982946a24b5e000ddde58247adba (diff)
Fix two crashes found by running inference on all of rustc
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 2621d1b55..3139eba0b 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -630,6 +630,39 @@ fn test() {
630 ); 630 );
631} 631}
632 632
633#[test]
634fn infer_std_crash_1() {
635 // caused stack overflow, taken from std
636 check_inference(
637 "infer_std_crash_1",
638 r#"
639enum Maybe<T> {
640 Real(T),
641 Fake,
642}
643
644fn write() {
645 match something_unknown {
646 Maybe::Real(ref mut something) => (),
647 }
648}
649"#,
650 );
651}
652
653#[test]
654fn infer_std_crash_2() {
655 // caused "equating two type variables, ...", taken from std
656 check_inference(
657 "infer_std_crash_2",
658 r#"
659fn test_line_buffer() {
660 &[0, b'\n', 1, b'\n'];
661}
662"#,
663 );
664}
665
633fn infer(content: &str) -> String { 666fn infer(content: &str) -> String {
634 let (db, _, file_id) = MockDatabase::with_single_file(content); 667 let (db, _, file_id) = MockDatabase::with_single_file(content);
635 let source_file = db.parse(file_id); 668 let source_file = db.parse(file_id);