Skip to content

Commit

Permalink
Rollup merge of #71247 - ldm0:minor, r=estebank
Browse files Browse the repository at this point in the history
Remove unnecessary variable intialization

Minor fix.
  • Loading branch information
Dylan-DPC authored Apr 17, 2020
2 parents 07cb4f4 + be6716f commit 029e930
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/librustc_typeck/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,18 +975,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expected: Expectation<'tcx>,
expr: &'tcx hir::Expr<'tcx>,
) -> Ty<'tcx> {
let uty = expected.to_option(self).and_then(|uty| match uty.kind {
ty::Array(ty, _) | ty::Slice(ty) => Some(ty),
_ => None,
});

let element_ty = if !args.is_empty() {
let coerce_to = uty.unwrap_or_else(|| {
self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: expr.span,
let coerce_to = expected
.to_option(self)
.and_then(|uty| match uty.kind {
ty::Array(ty, _) | ty::Slice(ty) => Some(ty),
_ => None,
})
});
.unwrap_or_else(|| {
self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: expr.span,
})
});
let mut coerce = CoerceMany::with_coercion_sites(coerce_to, args);
assert_eq!(self.diverges.get(), Diverges::Maybe);
for e in args {
Expand Down

0 comments on commit 029e930

Please sign in to comment.