Skip to content

Commit 957898a

Browse files
committed
remove redundant lub
1 parent d862e08 commit 957898a

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
@@ -1273,30 +1273,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12731273
}
12741274
}
12751275

1276-
match self.commit_if_ok(|_| coerce.coerce(prev_ty, new_ty)) {
1277-
Err(_) => {
1278-
// Avoid giving strange errors on failed attempts.
1279-
if let Some(e) = first_error {
1280-
Err(e)
1281-
} else {
1282-
Err(self
1283-
.commit_if_ok(|_| self.at(cause, self.param_env).lub(prev_ty, new_ty))
1284-
.unwrap_err())
1285-
}
1286-
}
1287-
Ok(ok) => {
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());
1292-
}
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)
1298-
}
1276+
let ok = self
1277+
.commit_if_ok(|_| coerce.coerce(prev_ty, new_ty))
1278+
// Avoid giving strange errors on failed attempts.
1279+
.map_err(|e| first_error.unwrap_or(e))?;
1280+
1281+
let (adjustments, target) = self.register_infer_ok_obligations(ok);
1282+
for expr in exprs {
1283+
let expr = expr.as_coercion_site();
1284+
self.apply_adjustments(expr, adjustments.clone());
12991285
}
1286+
debug!(
1287+
"coercion::try_find_coercion_lub: was able to coerce previous type {:?} to new type {:?} ({:?})",
1288+
prev_ty, new_ty, target
1289+
);
1290+
Ok(target)
13001291
}
13011292
}
13021293

0 commit comments

Comments
 (0)