Skip to content

Commit 1b5768d

Browse files
committed
document diverges more correctly
1 parent 8450add commit 1b5768d

File tree

1 file changed

+13
-5
lines changed
  • src/librustc_typeck/check

1 file changed

+13
-5
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,19 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
454454
ps: RefCell<UnsafetyState>,
455455

456456
/// Whether the last checked node generates a divergence (e.g.,
457-
/// `return` will set this to Always). In general, this is
458-
/// typically set to *Maybe* on the way **down** the tree, and
459-
/// then values are propagated **up** the tree. In a block, we
460-
/// combine the results from statements and propagate the
461-
/// end-result up.
457+
/// `return` will set this to Always). In general, when entering
458+
/// an expression or other node in the tree, the initial value
459+
/// indicates whether prior parts of the containing expression may
460+
/// have diverged. It is then typically set to `Maybe` (and the
461+
/// old value remembered) for processing the subparts of the
462+
/// current expression. As each subpart is processed, they may set
463+
/// the flag to `Always` etc. Finally, at the end, we take the
464+
/// result and "union" it with the original value, so that when we
465+
/// return the flag indicates if any subpart of the the parent
466+
/// expression (up to and including this part) has diverged. So,
467+
/// if you read it after evaluating a subexpression `X`, the value
468+
/// you get indicates whether any subexpression that was
469+
/// evaluating up to and including `X` diverged.
462470
///
463471
/// We use this flag for two purposes:
464472
///

0 commit comments

Comments
 (0)