From 0aedd4fb2f28ec24902d26c7d8a24d6146263d2f Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Thu, 17 Jan 2019 00:08:53 +0900 Subject: Add Ty::Array to walk_mut --- crates/ra_hir/src/ty.rs | 6 +-- crates/ra_hir/src/ty/tests/data/array.txt | 64 +++++++++++++++---------------- 2 files changed, 35 insertions(+), 35 deletions(-) (limited to 'crates') 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 { fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { f(self); match self { - Ty::Slice(t) => Arc::make_mut(t).walk_mut(f), + Ty::Slice(t) | Ty::Array(t) => Arc::make_mut(t).walk_mut(f), Ty::RawPtr(t, _) => Arc::make_mut(t).walk_mut(f), Ty::Ref(t, _) => Arc::make_mut(t).walk_mut(f), Ty::Tuple(ts) => { @@ -1105,7 +1105,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { } Ty::Tuple(Arc::from(ty_vec)) - }, + } Expr::Array { exprs } => { let elem_ty = match &expected.ty { Ty::Slice(inner) | Ty::Array(inner) => Ty::clone(&inner), @@ -1117,7 +1117,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { } Ty::Array(Arc::new(elem_ty)) - }, + } Expr::Literal(lit) => match lit { Literal::Bool(..) => Ty::Bool, 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 @@ [9; 10) 'x': &str [18; 19) 'y': isize [28; 293) '{ ... []; }': () -[38; 39) 'a': [_] -[42; 45) '[x]': [_] +[38; 39) 'a': [&str] +[42; 45) '[x]': [&str] [43; 44) 'x': &str -[55; 56) 'b': [_] -[59; 65) '[a, a]': [_] -[60; 61) 'a': [_] -[63; 64) 'a': [_] -[75; 76) 'c': [_] -[79; 85) '[b, b]': [_] -[80; 81) 'b': [_] -[83; 84) 'b': [_] -[96; 97) 'd': [_] -[100; 112) '[y, 1, 2, 3]': [_] +[55; 56) 'b': [[&str]] +[59; 65) '[a, a]': [[&str]] +[60; 61) 'a': [&str] +[63; 64) 'a': [&str] +[75; 76) 'c': [[[&str]]] +[79; 85) '[b, b]': [[[&str]]] +[80; 81) 'b': [[&str]] +[83; 84) 'b': [[&str]] +[96; 97) 'd': [isize] +[100; 112) '[y, 1, 2, 3]': [isize] [101; 102) 'y': isize [104; 105) '1': isize [107; 108) '2': isize [110; 111) '3': isize -[122; 123) 'd': [_] -[126; 138) '[1, y, 2, 3]': [_] +[122; 123) 'd': [isize] +[126; 138) '[1, y, 2, 3]': [isize] [127; 128) '1': isize [130; 131) 'y': isize [133; 134) '2': isize [136; 137) '3': isize -[148; 149) 'e': [_] -[152; 155) '[y]': [_] +[148; 149) 'e': [isize] +[152; 155) '[y]': [isize] [153; 154) 'y': isize -[165; 166) 'f': [_] -[169; 175) '[d, d]': [_] -[170; 171) 'd': [_] -[173; 174) 'd': [_] -[185; 186) 'g': [_] -[189; 195) '[e, e]': [_] -[190; 191) 'e': [_] -[193; 194) 'e': [_] -[206; 207) 'h': [_] -[210; 216) '[1, 2]': [_] +[165; 166) 'f': [[isize]] +[169; 175) '[d, d]': [[isize]] +[170; 171) 'd': [isize] +[173; 174) 'd': [isize] +[185; 186) 'g': [[isize]] +[189; 195) '[e, e]': [[isize]] +[190; 191) 'e': [isize] +[193; 194) 'e': [isize] +[206; 207) 'h': [i32] +[210; 216) '[1, 2]': [i32] [211; 212) '1': i32 [214; 215) '2': i32 -[226; 227) 'i': [_] -[230; 240) '["a", "b"]': [_] +[226; 227) 'i': [&str] +[230; 240) '["a", "b"]': [&str] [231; 234) '"a"': &str [236; 239) '"b"': &str -[251; 252) 'b': [_] -[255; 265) '[a, ["b"]]': [_] -[256; 257) 'a': [_] -[259; 264) '["b"]': [_] +[251; 252) 'b': [[&str]] +[255; 265) '[a, ["b"]]': [[&str]] +[256; 257) 'a': [&str] +[259; 264) '["b"]': [&str] [260; 263) '"b"': &str [275; 276) 'x': [u8] [288; 290) '[]': [u8] -- cgit v1.2.3