Add Ty::Array to walk_mut

This commit is contained in:
Hirokazu Hata 2019-01-17 00:08:53 +09:00
parent f66ca1bd2e
commit 0aedd4fb2f
2 changed files with 35 additions and 35 deletions

View File

@ -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),

View File

@ -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]