Skip to content

Commit 821eae2

Browse files
committed
Add comment
1 parent 94946be commit 821eae2

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,14 +1519,20 @@ impl<'tcx> CoerceMany<'tcx> {
15191519

15201520
// Handle the actual type unification etc.
15211521
let result = if let Some(expression) = expression {
1522+
// For the *first* expression being coerced, we call `fcx.coerce`,
1523+
// which will actually end up using `Sub` rather tha `Lub`.
1524+
// This is not the most ideal thing to do, but this breaks all over
1525+
// the place when removing this special-case.
1526+
// So, for now, to keep things *logically* a bit more simple, we
1527+
// have a `force_lub` option that callers can use (currently only
1528+
// is set in match coercion) to guarantee that all expressions use
1529+
// Lub coercion.
15221530
if !self.force_lub && self.expressions.is_empty() {
1523-
// Special-case the first expression we are coercing.
1524-
// To be honest, I'm not entirely sure why we do this.
1525-
// We don't allow two-phase borrows, see comment in try_find_coercion_lub for why
15261531
fcx.coerce(
15271532
expression,
15281533
expression_ty,
15291534
self.expected_ty,
1535+
// We don't allow two-phase borrows, see comment in try_find_coercion_lub for why
15301536
AllowTwoPhase::No,
15311537
Some(cause.clone()),
15321538
)

0 commit comments

Comments
 (0)