Skip to content

Commit 029e930

Browse files
authored
Rollup merge of #71247 - ldm0:minor, r=estebank
Remove unnecessary variable intialization Minor fix.
2 parents 07cb4f4 + be6716f commit 029e930

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/librustc_typeck/check/expr.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -975,18 +975,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
975975
expected: Expectation<'tcx>,
976976
expr: &'tcx hir::Expr<'tcx>,
977977
) -> Ty<'tcx> {
978-
let uty = expected.to_option(self).and_then(|uty| match uty.kind {
979-
ty::Array(ty, _) | ty::Slice(ty) => Some(ty),
980-
_ => None,
981-
});
982-
983978
let element_ty = if !args.is_empty() {
984-
let coerce_to = uty.unwrap_or_else(|| {
985-
self.next_ty_var(TypeVariableOrigin {
986-
kind: TypeVariableOriginKind::TypeInference,
987-
span: expr.span,
979+
let coerce_to = expected
980+
.to_option(self)
981+
.and_then(|uty| match uty.kind {
982+
ty::Array(ty, _) | ty::Slice(ty) => Some(ty),
983+
_ => None,
988984
})
989-
});
985+
.unwrap_or_else(|| {
986+
self.next_ty_var(TypeVariableOrigin {
987+
kind: TypeVariableOriginKind::TypeInference,
988+
span: expr.span,
989+
})
990+
});
990991
let mut coerce = CoerceMany::with_coercion_sites(coerce_to, args);
991992
assert_eq!(self.diverges.get(), Diverges::Maybe);
992993
for e in args {

0 commit comments

Comments
 (0)