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/snapshots/tests__infer_std_crash_1.snap13
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_2.snap14
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_3.snap13
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_4.snap16
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_5.snap30
-rw-r--r--crates/ra_hir/src/ty/tests.rs89
6 files changed, 175 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---
2created: "2019-02-09T16:56:24.803326529Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&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---
2created: "2019-02-09T17:03:11.974225590Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&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/snapshots/tests__infer_std_crash_3.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_3.snap
new file mode 100644
index 000000000..d15b77e17
--- /dev/null
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_3.snap
@@ -0,0 +1,13 @@
1---
2created: "2019-02-09T18:02:37.377591660Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[18; 102) '{ ... } }': ()
8[24; 100) 'match ... }': ()
9[42; 88) 'SizeSk...tail }': [unknown]
10[76; 80) 'true': [unknown]
11[82; 86) 'tail': [unknown]
12[92; 94) '{}': ()
13
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_4.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_4.snap
new file mode 100644
index 000000000..fb31883ce
--- /dev/null
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_4.snap
@@ -0,0 +1,16 @@
1---
2created: "2019-02-09T19:55:39.712470520Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[25; 110) '{ ... } }': ()
8[31; 108) 'match ... }': ()
9[37; 42) '*self': [unknown]
10[38; 42) 'self': [unknown]
11[53; 95) 'Borrow...), ..}': [unknown]
12[74; 77) 'box': [unknown]
13[78; 87) 'Primitive': [unknown]
14[88; 89) 'p': [unknown]
15[99; 101) '{}': ()
16
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_5.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_5.snap
new file mode 100644
index 000000000..6bbf59fb6
--- /dev/null
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_5.snap
@@ -0,0 +1,30 @@
1---
2created: "2019-02-09T20:28:37.294693728Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[27; 323) '{ ... } }': ()
8[33; 321) 'for co... }': ()
9[37; 44) 'content': &[unknown]
10[48; 61) 'doesnt_matter': [unknown]
11[62; 321) '{ ... }': ()
12[76; 80) 'name': &&[unknown]
13[83; 167) 'if doe... }': &&[unknown]
14[86; 99) 'doesnt_matter': bool
15[100; 129) '{ ... }': &&[unknown]
16[114; 119) 'first': &&[unknown]
17[135; 167) '{ ... }': &&[unknown]
18[149; 157) '&content': &&[unknown]
19[150; 157) 'content': &[unknown]
20[182; 189) 'content': &&[unknown]
21[192; 314) 'if ICE... }': &&[unknown]
22[195; 232) 'ICE_RE..._VALUE': [unknown]
23[195; 248) 'ICE_RE...&name)': bool
24[242; 247) '&name': &&&[unknown]
25[243; 247) 'name': &&[unknown]
26[249; 277) '{ ... }': &&[unknown]
27[263; 267) 'name': &&[unknown]
28[283; 314) '{ ... }': &[unknown]
29[297; 304) 'content': &[unknown]
30
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 2621d1b55..e64fd2749 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -630,6 +630,95 @@ 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 covers!(type_var_resolves_to_int_var);
656 // caused "equating two type variables, ...", taken from std
657 check_inference(
658 "infer_std_crash_2",
659 r#"
660fn test_line_buffer() {
661 &[0, b'\n', 1, b'\n'];
662}
663"#,
664 );
665}
666
667#[test]
668fn infer_std_crash_3() {
669 // taken from rustc
670 check_inference(
671 "infer_std_crash_3",
672 r#"
673pub fn compute() {
674 match _ {
675 SizeSkeleton::Pointer { non_zero: true, tail } => {}
676 }
677}
678"#,
679 );
680}
681
682#[test]
683fn infer_std_crash_4() {
684 // taken from rustc
685 check_inference(
686 "infer_std_crash_4",
687 r#"
688pub fn primitive_type() {
689 match *self {
690 BorrowedRef { type_: box Primitive(p), ..} => {},
691 }
692}
693"#,
694 );
695}
696
697#[test]
698fn infer_std_crash_5() {
699 // taken from rustc
700 check_inference(
701 "infer_std_crash_5",
702 r#"
703fn extra_compiler_flags() {
704 for content in doesnt_matter {
705 let name = if doesnt_matter {
706 first
707 } else {
708 &content
709 };
710
711 let content = if ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.contains(&name) {
712 name
713 } else {
714 content
715 };
716 }
717}
718"#,
719 );
720}
721
633fn infer(content: &str) -> String { 722fn infer(content: &str) -> String {
634 let (db, _, file_id) = MockDatabase::with_single_file(content); 723 let (db, _, file_id) = MockDatabase::with_single_file(content);
635 let source_file = db.parse(file_id); 724 let source_file = db.parse(file_id);