Use builtin_index instead of match

Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
This commit is contained in:
Andy Wang 2023-03-20 16:21:43 +01:00
parent e24f5ac56b
commit f404f33c21
No known key found for this signature in database
GPG Key ID: 181B49F9F38F3374

View File

@ -173,12 +173,9 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
)
),
ExprKind::Array { fields } => {
let elem_ty = match expr.ty.kind() {
ty::Array(ty, ..) => ty,
_ => unreachable!("ty is array"),
};
let elem_ty = expr.ty.builtin_index().expect("ty must be an array");
Ok(Rvalue::Aggregate(
Box::new(AggregateKind::Array(*elem_ty)),
Box::new(AggregateKind::Array(elem_ty)),
fields.iter().map(|e| self.parse_operand(*e)).collect::<Result<_, _>>()?
))
},