Skip to content

Commit bfd1f3b

Browse files
committed
remove redundant lub
1 parent 8130e11 commit bfd1f3b

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,30 +1280,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12801280
}
12811281
}
12821282

1283-
match self.commit_if_ok(|_| coerce.coerce(prev_ty, new_ty)) {
1284-
Err(_) => {
1285-
// Avoid giving strange errors on failed attempts.
1286-
if let Some(e) = first_error {
1287-
Err(e)
1288-
} else {
1289-
Err(self
1290-
.commit_if_ok(|_| self.at(cause, self.param_env).lub(prev_ty, new_ty))
1291-
.unwrap_err())
1292-
}
1293-
}
1294-
Ok(ok) => {
1295-
let (adjustments, target) = self.register_infer_ok_obligations(ok);
1296-
for expr in exprs {
1297-
let expr = expr.as_coercion_site();
1298-
self.apply_adjustments(expr, adjustments.clone());
1299-
}
1300-
debug!(
1301-
"coercion::try_find_coercion_lub: was able to coerce previous type {:?} to new type {:?} ({:?})",
1302-
prev_ty, new_ty, target
1303-
);
1304-
Ok(target)
1305-
}
1283+
let ok = self
1284+
.commit_if_ok(|_| coerce.coerce(prev_ty, new_ty))
1285+
// Avoid giving strange errors on failed attempts.
1286+
.map_err(|e| first_error.unwrap_or(e))?;
1287+
1288+
let (adjustments, target) = self.register_infer_ok_obligations(ok);
1289+
for expr in exprs {
1290+
let expr = expr.as_coercion_site();
1291+
self.apply_adjustments(expr, adjustments.clone());
13061292
}
1293+
debug!(
1294+
"coercion::try_find_coercion_lub: was able to coerce previous type {:?} to new type {:?} ({:?})",
1295+
prev_ty, new_ty, target
1296+
);
1297+
Ok(target)
13071298
}
13081299
}
13091300

0 commit comments

Comments
 (0)