Skip to content

Commit 9d7fc81

Browse files
committed
Use slice and unify
1 parent 5a6c038 commit 9d7fc81

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

crates/ra_hir/src/ty.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ pub enum Ty {
216216
/// A tuple type. For example, `(i32, bool)`.
217217
Tuple(Arc<[Ty]>),
218218

219-
/// A array type. For example, `[i32]`.
220-
Array(Arc<[Ty]>),
221-
222219
// The projection of an associated type. For example,
223220
// `<T as Trait<..>>::N`.pub
224221
// Projection(ProjectionTy),
@@ -411,16 +408,6 @@ impl fmt::Display for Ty {
411408
.to_fmt(f)
412409
}
413410
}
414-
Ty::Array(ts) => {
415-
if ts.len() == 1 {
416-
write!(f, "[{},]", ts[0])
417-
} else {
418-
join(ts.iter())
419-
.surround_with("[", "]")
420-
.separator(", ")
421-
.to_fmt(f)
422-
}
423-
}
424411
Ty::FnPtr(sig) => {
425412
join(sig.input.iter())
426413
.surround_with("fn(", ")")
@@ -1055,19 +1042,23 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
10551042
},
10561043
Expr::Tuple { exprs } => {
10571044
let mut ty_vec = Vec::with_capacity(exprs.len());
1058-
for arg in exprs.iter() {
1059-
ty_vec.push(self.infer_expr(*arg, &Expectation::none())?);
1045+
for expr in exprs.iter() {
1046+
ty_vec.push(self.infer_expr(*expr, &Expectation::none())?);
10601047
}
10611048

10621049
Ty::Tuple(Arc::from(ty_vec))
10631050
}
10641051
Expr::Array { exprs } => {
1065-
let mut ty_vec = Vec::with_capacity(exprs.len());
1066-
for arg in exprs.iter() {
1067-
ty_vec.push(self.infer_expr(*arg, &Expectation::none())?);
1052+
let mut ty = Ty::Unknown;
1053+
for expr in exprs.iter() {
1054+
let infered = self.infer_expr(*expr, &Expectation::none())?;
1055+
match infered {
1056+
Ty::Unknown => (),
1057+
_ => ty = infered,
1058+
}
10681059
}
10691060

1070-
Ty::Array(Arc::from(ty_vec))
1061+
Ty::Slice(Arc::new(ty))
10711062
}
10721063
};
10731064
// use a new type variable if we got Ty::Unknown here

0 commit comments

Comments
 (0)