diff options
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 89 |
1 files changed, 89 insertions, 0 deletions
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] | ||
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 | 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#" | ||
660 | fn test_line_buffer() { | ||
661 | &[0, b'\n', 1, b'\n']; | ||
662 | } | ||
663 | "#, | ||
664 | ); | ||
665 | } | ||
666 | |||
667 | #[test] | ||
668 | fn infer_std_crash_3() { | ||
669 | // taken from rustc | ||
670 | check_inference( | ||
671 | "infer_std_crash_3", | ||
672 | r#" | ||
673 | pub fn compute() { | ||
674 | match _ { | ||
675 | SizeSkeleton::Pointer { non_zero: true, tail } => {} | ||
676 | } | ||
677 | } | ||
678 | "#, | ||
679 | ); | ||
680 | } | ||
681 | |||
682 | #[test] | ||
683 | fn infer_std_crash_4() { | ||
684 | // taken from rustc | ||
685 | check_inference( | ||
686 | "infer_std_crash_4", | ||
687 | r#" | ||
688 | pub fn primitive_type() { | ||
689 | match *self { | ||
690 | BorrowedRef { type_: box Primitive(p), ..} => {}, | ||
691 | } | ||
692 | } | ||
693 | "#, | ||
694 | ); | ||
695 | } | ||
696 | |||
697 | #[test] | ||
698 | fn infer_std_crash_5() { | ||
699 | // taken from rustc | ||
700 | check_inference( | ||
701 | "infer_std_crash_5", | ||
702 | r#" | ||
703 | fn 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 | |||
633 | fn infer(content: &str) -> String { | 722 | fn 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); |