diff options
author | Hirokazu Hata <[email protected]> | 2019-01-16 15:08:53 +0000 |
---|---|---|
committer | Hirokazu Hata <[email protected]> | 2019-01-16 15:08:53 +0000 |
commit | 0aedd4fb2f28ec24902d26c7d8a24d6146263d2f (patch) | |
tree | e67129e4e514e140463d8f0f7bd7556793cac484 /crates/ra_hir/src | |
parent | f66ca1bd2e0e5e198f60d0b0b6e2d953c81b0645 (diff) |
Add Ty::Array to walk_mut
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/ty.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/array.txt | 64 |
2 files changed, 35 insertions, 35 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 55373b05a..c7c063601 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -356,7 +356,7 @@ impl Ty { | |||
356 | fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { | 356 | fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { |
357 | f(self); | 357 | f(self); |
358 | match self { | 358 | match self { |
359 | Ty::Slice(t) => Arc::make_mut(t).walk_mut(f), | 359 | Ty::Slice(t) | Ty::Array(t) => Arc::make_mut(t).walk_mut(f), |
360 | Ty::RawPtr(t, _) => Arc::make_mut(t).walk_mut(f), | 360 | Ty::RawPtr(t, _) => Arc::make_mut(t).walk_mut(f), |
361 | Ty::Ref(t, _) => Arc::make_mut(t).walk_mut(f), | 361 | Ty::Ref(t, _) => Arc::make_mut(t).walk_mut(f), |
362 | Ty::Tuple(ts) => { | 362 | Ty::Tuple(ts) => { |
@@ -1105,7 +1105,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | Ty::Tuple(Arc::from(ty_vec)) | 1107 | Ty::Tuple(Arc::from(ty_vec)) |
1108 | }, | 1108 | } |
1109 | Expr::Array { exprs } => { | 1109 | Expr::Array { exprs } => { |
1110 | let elem_ty = match &expected.ty { | 1110 | let elem_ty = match &expected.ty { |
1111 | Ty::Slice(inner) | Ty::Array(inner) => Ty::clone(&inner), | 1111 | Ty::Slice(inner) | Ty::Array(inner) => Ty::clone(&inner), |
@@ -1117,7 +1117,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | Ty::Array(Arc::new(elem_ty)) | 1119 | Ty::Array(Arc::new(elem_ty)) |
1120 | }, | 1120 | } |
1121 | Expr::Literal(lit) => match lit { | 1121 | Expr::Literal(lit) => match lit { |
1122 | Literal::Bool(..) => Ty::Bool, | 1122 | Literal::Bool(..) => Ty::Bool, |
1123 | Literal::String(..) => Ty::Ref(Arc::new(Ty::Str), Mutability::Shared), | 1123 | Literal::String(..) => Ty::Ref(Arc::new(Ty::Str), Mutability::Shared), |
diff --git a/crates/ra_hir/src/ty/tests/data/array.txt b/crates/ra_hir/src/ty/tests/data/array.txt index 5fdbc67b6..acdf74ba4 100644 --- a/crates/ra_hir/src/ty/tests/data/array.txt +++ b/crates/ra_hir/src/ty/tests/data/array.txt | |||
@@ -1,52 +1,52 @@ | |||
1 | [9; 10) 'x': &str | 1 | [9; 10) 'x': &str |
2 | [18; 19) 'y': isize | 2 | [18; 19) 'y': isize |
3 | [28; 293) '{ ... []; }': () | 3 | [28; 293) '{ ... []; }': () |
4 | [38; 39) 'a': [_] | 4 | [38; 39) 'a': [&str] |
5 | [42; 45) '[x]': [_] | 5 | [42; 45) '[x]': [&str] |
6 | [43; 44) 'x': &str | 6 | [43; 44) 'x': &str |
7 | [55; 56) 'b': [_] | 7 | [55; 56) 'b': [[&str]] |
8 | [59; 65) '[a, a]': [_] | 8 | [59; 65) '[a, a]': [[&str]] |
9 | [60; 61) 'a': [_] | 9 | [60; 61) 'a': [&str] |
10 | [63; 64) 'a': [_] | 10 | [63; 64) 'a': [&str] |
11 | [75; 76) 'c': [_] | 11 | [75; 76) 'c': [[[&str]]] |
12 | [79; 85) '[b, b]': [_] | 12 | [79; 85) '[b, b]': [[[&str]]] |
13 | [80; 81) 'b': [_] | 13 | [80; 81) 'b': [[&str]] |
14 | [83; 84) 'b': [_] | 14 | [83; 84) 'b': [[&str]] |
15 | [96; 97) 'd': [_] | 15 | [96; 97) 'd': [isize] |
16 | [100; 112) '[y, 1, 2, 3]': [_] | 16 | [100; 112) '[y, 1, 2, 3]': [isize] |
17 | [101; 102) 'y': isize | 17 | [101; 102) 'y': isize |
18 | [104; 105) '1': isize | 18 | [104; 105) '1': isize |
19 | [107; 108) '2': isize | 19 | [107; 108) '2': isize |
20 | [110; 111) '3': isize | 20 | [110; 111) '3': isize |
21 | [122; 123) 'd': [_] | 21 | [122; 123) 'd': [isize] |
22 | [126; 138) '[1, y, 2, 3]': [_] | 22 | [126; 138) '[1, y, 2, 3]': [isize] |
23 | [127; 128) '1': isize | 23 | [127; 128) '1': isize |
24 | [130; 131) 'y': isize | 24 | [130; 131) 'y': isize |
25 | [133; 134) '2': isize | 25 | [133; 134) '2': isize |
26 | [136; 137) '3': isize | 26 | [136; 137) '3': isize |
27 | [148; 149) 'e': [_] | 27 | [148; 149) 'e': [isize] |
28 | [152; 155) '[y]': [_] | 28 | [152; 155) '[y]': [isize] |
29 | [153; 154) 'y': isize | 29 | [153; 154) 'y': isize |
30 | [165; 166) 'f': [_] | 30 | [165; 166) 'f': [[isize]] |
31 | [169; 175) '[d, d]': [_] | 31 | [169; 175) '[d, d]': [[isize]] |
32 | [170; 171) 'd': [_] | 32 | [170; 171) 'd': [isize] |
33 | [173; 174) 'd': [_] | 33 | [173; 174) 'd': [isize] |
34 | [185; 186) 'g': [_] | 34 | [185; 186) 'g': [[isize]] |
35 | [189; 195) '[e, e]': [_] | 35 | [189; 195) '[e, e]': [[isize]] |
36 | [190; 191) 'e': [_] | 36 | [190; 191) 'e': [isize] |
37 | [193; 194) 'e': [_] | 37 | [193; 194) 'e': [isize] |
38 | [206; 207) 'h': [_] | 38 | [206; 207) 'h': [i32] |
39 | [210; 216) '[1, 2]': [_] | 39 | [210; 216) '[1, 2]': [i32] |
40 | [211; 212) '1': i32 | 40 | [211; 212) '1': i32 |
41 | [214; 215) '2': i32 | 41 | [214; 215) '2': i32 |
42 | [226; 227) 'i': [_] | 42 | [226; 227) 'i': [&str] |
43 | [230; 240) '["a", "b"]': [_] | 43 | [230; 240) '["a", "b"]': [&str] |
44 | [231; 234) '"a"': &str | 44 | [231; 234) '"a"': &str |
45 | [236; 239) '"b"': &str | 45 | [236; 239) '"b"': &str |
46 | [251; 252) 'b': [_] | 46 | [251; 252) 'b': [[&str]] |
47 | [255; 265) '[a, ["b"]]': [_] | 47 | [255; 265) '[a, ["b"]]': [[&str]] |
48 | [256; 257) 'a': [_] | 48 | [256; 257) 'a': [&str] |
49 | [259; 264) '["b"]': [_] | 49 | [259; 264) '["b"]': [&str] |
50 | [260; 263) '"b"': &str | 50 | [260; 263) '"b"': &str |
51 | [275; 276) 'x': [u8] | 51 | [275; 276) 'x': [u8] |
52 | [288; 290) '[]': [u8] | 52 | [288; 290) '[]': [u8] |