Skip to content

Commit 23dbff8

Browse files
committed
Add a useful comment.
1 parent 1300310 commit 23dbff8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

compiler/rustc_middle/src/mir/basic_blocks.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ pub struct BasicBlocks<'tcx> {
2020
// Typically 95%+ of basic blocks have 4 or fewer predecessors.
2121
type Predecessors = IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>>;
2222

23+
/// Each `(target, switch)` entry in the map contains a list of switch values
24+
/// that lead to a `target` block from a `switch` block.
25+
///
26+
/// Note: this type is currently never instantiated, because it's only used for
27+
/// `BasicBlocks::switch_sources`, which is only called by backwards analyses
28+
/// that do `SwitchInt` handling, and we don't have any of those, not even in
29+
/// tests. See #95120 and #94576.
2330
type SwitchSources = FxHashMap<(BasicBlock, BasicBlock), SmallVec<[Option<u128>; 1]>>;
2431

2532
#[derive(Clone, Default, Debug)]
@@ -70,8 +77,8 @@ impl<'tcx> BasicBlocks<'tcx> {
7077
})
7178
}
7279

73-
/// `switch_sources()[&(target, switch)]` returns a list of switch
74-
/// values that lead to a `target` block from a `switch` block.
80+
/// Returns info about switch values that lead from one block to another
81+
/// block. See `SwitchSources`.
7582
#[inline]
7683
pub fn switch_sources(&self) -> &SwitchSources {
7784
self.cache.switch_sources.get_or_init(|| {

0 commit comments

Comments
 (0)