diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-07 20:05:44 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-07 20:05:44 +0000 |
commit | 812e47785b4f14a961f97414d0ca69d8c9bf5c9c (patch) | |
tree | f4e1936de76bee89502613ce038f4ecaef19ec4b /crates/ra_hir/src/ty/tests.rs | |
parent | e2592cf09087ae0a6cad5b588cbf1ab1161440e9 (diff) | |
parent | 5d15dd70b037b3d1623ebd83d8ef0f66ad6950af (diff) |
Merge #451
451: More type inference for more binary expressions r=flodiebold a=marcusklaas
Implements more of https://github.com/rust-analyzer/rust-analyzer/issues/390. Just works for primitive (numeric) types for now.
Found an issue where `let x: Ty = expr;` doesn't actually propagate the type information unless `Ty` is primitive and numeric. I'll open an issue for this.
Co-authored-by: Marcus Klaas de Vries <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 13 |
1 files changed, 8 insertions, 5 deletions
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 { | |||
157 | } | 157 | } |
158 | 158 | ||
159 | #[test] | 159 | #[test] |
160 | fn infer_boolean_op() { | 160 | fn infer_binary_op() { |
161 | check_inference( | 161 | check_inference( |
162 | r#" | 162 | r#" |
163 | fn f(x: bool) -> i32 { | 163 | fn f(x: bool) -> i32 { |
@@ -168,15 +168,18 @@ fn test() { | |||
168 | let x = a && b; | 168 | let x = a && b; |
169 | let y = true || false; | 169 | let y = true || false; |
170 | let z = x == y; | 170 | let z = x == y; |
171 | let h = CONST_1 <= CONST_2; | 171 | let minus_forty: isize = -40isize; |
172 | let h = minus_forty <= CONST_2; | ||
172 | let c = f(z || y) + 5; | 173 | let c = f(z || y) + 5; |
173 | let d = b; | 174 | let d = b; |
174 | let e = 3i32 && "hello world"; | 175 | let g = minus_forty ^= i; |
176 | let ten: usize = 10; | ||
177 | let ten_is_eleven = ten == some_num; | ||
175 | 178 | ||
176 | 10 < 3 | 179 | ten < 3 |
177 | } | 180 | } |
178 | "#, | 181 | "#, |
179 | "boolean_op.txt", | 182 | "binary_op.txt", |
180 | ); | 183 | ); |
181 | } | 184 | } |
182 | 185 | ||