Skip to content

Commit 91dbac2

Browse files
committed
remove redundant lub
1 parent 00cd001 commit 91dbac2

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
@@ -1302,30 +1302,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13021302
}
13031303
}
13041304

1305-
match self.commit_if_ok(|_| coerce.coerce(prev_ty, new_ty)) {
1306-
Err(_) => {
1307-
// Avoid giving strange errors on failed attempts.
1308-
if let Some(e) = first_error {
1309-
Err(e)
1310-
} else {
1311-
Err(self
1312-
.commit_if_ok(|_| self.at(cause, self.param_env).lub(prev_ty, new_ty))
1313-
.unwrap_err())
1314-
}
1315-
}
1316-
Ok(ok) => {
1317-
let (adjustments, target) = self.register_infer_ok_obligations(ok);
1318-
for expr in exprs {
1319-
let expr = expr.as_coercion_site();
1320-
self.apply_adjustments(expr, adjustments.clone());
1321-
}
1322-
debug!(
1323-
"coercion::try_find_coercion_lub: was able to coerce previous type {:?} to new type {:?} ({:?})",
1324-
prev_ty, new_ty, target
1325-
);
1326-
Ok(target)
1327-
}
1305+
let ok = self
1306+
.commit_if_ok(|_| coerce.coerce(prev_ty, new_ty))
1307+
// Avoid giving strange errors on failed attempts.
1308+
.map_err(|e| first_error.unwrap_or(e))?;
1309+
1310+
let (adjustments, target) = self.register_infer_ok_obligations(ok);
1311+
for expr in exprs {
1312+
let expr = expr.as_coercion_site();
1313+
self.apply_adjustments(expr, adjustments.clone());
13281314
}
1315+
debug!(
1316+
"coercion::try_find_coercion_lub: was able to coerce previous type {:?} to new type {:?} ({:?})",
1317+
prev_ty, new_ty, target
1318+
);
1319+
Ok(target)
13291320
}
13301321
}
13311322

0 commit comments

Comments
 (0)