diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-17 16:57:02 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-17 16:57:02 +0100 |
commit | 5a2a97c7e8cfac690a00505d8644be30f7ee863a (patch) | |
tree | eba980071d5c8941fdd3adc11fc5525d243ba2b3 /crates/ra_hir/src/ty/tests.rs | |
parent | d15cf2c9600e0464b9bcd0273e7845efbf7bdeb5 (diff) | |
parent | 189d879659f4e44c3343023d6455bed7cdf0e7c9 (diff) |
Merge #1694
1694: Implement initial type-inference support for Index r=flodiebold a=matklad
This doesn't actually infer indexing types, but at least it walks sub-expressions!
Initially, I wanted to make `Index` just a new kind of `BinOp` (b/c indexing is kind of a binary op), so I've refactoring binop handing a bit.
However, in the end I've decided to add a separate expr kind for Index, because `foo[0]`, `&foo[1]` and `&mut foo[1]` all seem to need slightly different handing, which is not binop-like
r? @flodiebold
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 28727bb18..6c2d857bc 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -2656,6 +2656,20 @@ fn test() -> u64 { | |||
2656 | } | 2656 | } |
2657 | 2657 | ||
2658 | #[test] | 2658 | #[test] |
2659 | fn indexing_arrays() { | ||
2660 | assert_snapshot_matches!( | ||
2661 | infer("fn main() { &mut [9][2]; }"), | ||
2662 | @r###" | ||
2663 | [10; 26) '{ &mut...[2]; }': () | ||
2664 | [12; 23) '&mut [9][2]': &mut {unknown} | ||
2665 | [17; 20) '[9]': [i32;_] | ||
2666 | [17; 23) '[9][2]': {unknown} | ||
2667 | [18; 19) '9': i32 | ||
2668 | [21; 22) '2': i32"### | ||
2669 | ) | ||
2670 | } | ||
2671 | |||
2672 | #[test] | ||
2659 | fn infer_macros_expanded() { | 2673 | fn infer_macros_expanded() { |
2660 | assert_snapshot_matches!( | 2674 | assert_snapshot_matches!( |
2661 | infer(r#" | 2675 | infer(r#" |