diff options
Diffstat (limited to 'crates/hir_ty/src/tests')
-rw-r--r-- | crates/hir_ty/src/tests/coercion.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/coercion.rs b/crates/hir_ty/src/tests/coercion.rs index 67295b663..bb568ea37 100644 --- a/crates/hir_ty/src/tests/coercion.rs +++ b/crates/hir_ty/src/tests/coercion.rs | |||
@@ -873,3 +873,42 @@ fn foo(c: i32) { | |||
873 | "#, | 873 | "#, |
874 | ) | 874 | ) |
875 | } | 875 | } |
876 | |||
877 | #[test] | ||
878 | fn infer_match_diverging_branch_1() { | ||
879 | check_types( | ||
880 | r#" | ||
881 | enum Result<T> { Ok(T), Err } | ||
882 | fn parse<T>() -> T { loop {} } | ||
883 | |||
884 | fn test() -> i32 { | ||
885 | let a = match parse() { | ||
886 | Ok(val) => val, | ||
887 | Err => return 0, | ||
888 | }; | ||
889 | a | ||
890 | //^ i32 | ||
891 | } | ||
892 | "#, | ||
893 | ) | ||
894 | } | ||
895 | |||
896 | #[test] | ||
897 | fn infer_match_diverging_branch_2() { | ||
898 | // same as 1 except for order of branches | ||
899 | check_types( | ||
900 | r#" | ||
901 | enum Result<T> { Ok(T), Err } | ||
902 | fn parse<T>() -> T { loop {} } | ||
903 | |||
904 | fn test() -> i32 { | ||
905 | let a = match parse() { | ||
906 | Err => return 0, | ||
907 | Ok(val) => val, | ||
908 | }; | ||
909 | a | ||
910 | //^ i32 | ||
911 | } | ||
912 | "#, | ||
913 | ) | ||
914 | } | ||