diff options
author | Florian Diebold <[email protected]> | 2021-05-15 15:00:24 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-05-21 16:48:34 +0100 |
commit | a09079f27aa631b011f6c0703200862d28af81f4 (patch) | |
tree | 863ab0fbdb3dafed13cdbe1b6b066072c012f1b4 /crates/hir_ty/src/tests/coercion.rs | |
parent | afa6be243587e523d5a2fc218db78568041ff296 (diff) |
Fix coercion of two closures to a function pointer
Fixes #8604.
Diffstat (limited to 'crates/hir_ty/src/tests/coercion.rs')
-rw-r--r-- | crates/hir_ty/src/tests/coercion.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/hir_ty/src/tests/coercion.rs b/crates/hir_ty/src/tests/coercion.rs index 190471069..67295b663 100644 --- a/crates/hir_ty/src/tests/coercion.rs +++ b/crates/hir_ty/src/tests/coercion.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use expect_test::expect; | 1 | use expect_test::expect; |
2 | 2 | ||
3 | use super::{check_infer, check_infer_with_mismatches}; | 3 | use super::{check_infer, check_infer_with_mismatches, check_types}; |
4 | 4 | ||
5 | #[test] | 5 | #[test] |
6 | fn infer_block_expr_type_mismatch() { | 6 | fn infer_block_expr_type_mismatch() { |
@@ -858,3 +858,18 @@ fn coerce_unsize_generic() { | |||
858 | "]], | 858 | "]], |
859 | ); | 859 | ); |
860 | } | 860 | } |
861 | |||
862 | #[test] | ||
863 | fn infer_two_closures_lub() { | ||
864 | check_types( | ||
865 | r#" | ||
866 | fn foo(c: i32) { | ||
867 | let add = |a: i32, b: i32| a + b; | ||
868 | let sub = |a, b| a - b; | ||
869 | //^ |i32, i32| -> i32 | ||
870 | if c > 42 { add } else { sub }; | ||
871 | //^ fn(i32, i32) -> i32 | ||
872 | } | ||
873 | "#, | ||
874 | ) | ||
875 | } | ||