Skip to content

Commit 2532ad7

Browse files
authored
Rollup merge of #40576 - dwrensha:mir-terminator-kind-doc-typo, r=nikomatsakis
fix innacuracy in mir TerminatorKind::SwitchInt docs Each index of `values` corresponds to an index of `targets`, and `targets` additionally has a "default case" element at its end, so `targets.len() == values.len() + 1`, not the other way around. For example, [here](https://github.com/rust-lang/rust/blob/0aeb9c12979e6da753701a798d04105b6b1a8c28/src/librustc/mir/mod.rs#L549-L550) is a concrete instance of `SwitchInt` being constructed with `targets.len() == 2` and `values.len() == 1`.
2 parents 17656ab + e9c07cf commit 2532ad7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ pub enum TerminatorKind<'tcx> {
467467
values: Cow<'tcx, [ConstInt]>,
468468

469469
/// Possible branch sites. The last element of this vector is used
470-
/// for the otherwise branch, so values.len() == targets.len() + 1
470+
/// for the otherwise branch, so targets.len() == values.len() + 1
471471
/// should hold.
472472
// This invariant is quite non-obvious and also could be improved.
473473
// One way to make this invariant is to have something like this instead:

0 commit comments

Comments
 (0)