diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_1.snap | 13 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_2.snap | 14 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 33 |
3 files changed, 60 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_1.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_1.snap new file mode 100644 index 000000000..4b99788e4 --- /dev/null +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_1.snap | |||
@@ -0,0 +1,13 @@ | |||
1 | --- | ||
2 | created: "2019-02-09T16:56:24.803326529Z" | ||
3 | creator: [email protected] | ||
4 | source: crates/ra_hir/src/ty/tests.rs | ||
5 | expression: "&result" | ||
6 | --- | ||
7 | [54; 139) '{ ... } }': () | ||
8 | [60; 137) 'match ... }': () | ||
9 | [66; 83) 'someth...nknown': Maybe<[unknown]> | ||
10 | [94; 124) 'Maybe:...thing)': Maybe<[unknown]> | ||
11 | [106; 123) 'ref mu...ething': &mut [unknown] | ||
12 | [128; 130) '()': () | ||
13 | |||
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_2.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_2.snap new file mode 100644 index 000000000..fd0b39b7d --- /dev/null +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_2.snap | |||
@@ -0,0 +1,14 @@ | |||
1 | --- | ||
2 | created: "2019-02-09T17:03:11.974225590Z" | ||
3 | creator: [email protected] | ||
4 | source: crates/ra_hir/src/ty/tests.rs | ||
5 | expression: "&result" | ||
6 | --- | ||
7 | [23; 53) '{ ...n']; }': () | ||
8 | [29; 50) '&[0, b...b'\n']': &[u8] | ||
9 | [30; 50) '[0, b'...b'\n']': [u8] | ||
10 | [31; 32) '0': u8 | ||
11 | [34; 39) 'b'\n'': u8 | ||
12 | [41; 42) '1': u8 | ||
13 | [44; 49) 'b'\n'': u8 | ||
14 | |||
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] | ||
634 | fn infer_std_crash_1() { | ||
635 | // caused stack overflow, taken from std | ||
636 | check_inference( | ||
637 | "infer_std_crash_1", | ||
638 | r#" | ||
639 | enum Maybe<T> { | ||
640 | Real(T), | ||
641 | Fake, | ||
642 | } | ||
643 | |||
644 | fn write() { | ||
645 | match something_unknown { | ||
646 | Maybe::Real(ref mut something) => (), | ||
647 | } | ||
648 | } | ||
649 | "#, | ||
650 | ); | ||
651 | } | ||
652 | |||
653 | #[test] | ||
654 | fn infer_std_crash_2() { | ||
655 | // caused "equating two type variables, ...", taken from std | ||
656 | check_inference( | ||
657 | "infer_std_crash_2", | ||
658 | r#" | ||
659 | fn test_line_buffer() { | ||
660 | &[0, b'\n', 1, b'\n']; | ||
661 | } | ||
662 | "#, | ||
663 | ); | ||
664 | } | ||
665 | |||
633 | fn infer(content: &str) -> String { | 666 | fn 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); |