From 7b0eaef58072acc087d23faca5a9f9879f1765d5 Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Mon, 7 Jan 2019 20:11:31 +0100 Subject: Implement type inference for more binary operators Mostly just for primitive numeric types such as u32 and f64. Not yet a general solution using trait resolution. --- crates/ra_hir/src/ty/tests.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'crates/ra_hir/src/ty/tests.rs') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index e6c7e225b..2749d740c 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -157,7 +157,7 @@ impl S { } #[test] -fn infer_boolean_op() { +fn infer_binary_op() { check_inference( r#" fn f(x: bool) -> i32 { @@ -168,15 +168,18 @@ fn test() { let x = a && b; let y = true || false; let z = x == y; - let h = CONST_1 <= CONST_2; + let minus_forty: isize = -40isize; + let h = minus_forty <= CONST_2; let c = f(z || y) + 5; let d = b; - let e = 3i32 && "hello world"; + let g = minus_forty ^= i; + let ten: usize = 10; + let ten_is_eleven = ten == some_num; - 10 < 3 + ten < 3 } "#, - "boolean_op.txt", + "binary_op.txt", ); } -- cgit v1.2.3