diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-02-13 10:46:34 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-02-17 09:51:34 +1100 |
| commit | 23dbff88f6ecf7b92129ec3cfc41971b5cd9579c (patch) | |
| tree | 9905a07f42a4be84f7341a7f6c99689481ed5d4e | |
| parent | 13003100f803419307ada53620d00aa51ea678db (diff) | |
| download | rust-23dbff88f6ecf7b92129ec3cfc41971b5cd9579c.tar.gz rust-23dbff88f6ecf7b92129ec3cfc41971b5cd9579c.zip | |
Add a useful comment.
| -rw-r--r-- | compiler/rustc_middle/src/mir/basic_blocks.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/mir/basic_blocks.rs b/compiler/rustc_middle/src/mir/basic_blocks.rs index c32cf5f8253..5c670830376 100644 --- a/compiler/rustc_middle/src/mir/basic_blocks.rs +++ b/compiler/rustc_middle/src/mir/basic_blocks.rs @@ -20,6 +20,13 @@ pub struct BasicBlocks<'tcx> { // Typically 95%+ of basic blocks have 4 or fewer predecessors. type Predecessors = IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>>; +/// Each `(target, switch)` entry in the map contains a list of switch values +/// that lead to a `target` block from a `switch` block. +/// +/// Note: this type is currently never instantiated, because it's only used for +/// `BasicBlocks::switch_sources`, which is only called by backwards analyses +/// that do `SwitchInt` handling, and we don't have any of those, not even in +/// tests. See #95120 and #94576. type SwitchSources = FxHashMap<(BasicBlock, BasicBlock), SmallVec<[Option<u128>; 1]>>; #[derive(Clone, Default, Debug)] @@ -70,8 +77,8 @@ impl<'tcx> BasicBlocks<'tcx> { }) } - /// `switch_sources()[&(target, switch)]` returns a list of switch - /// values that lead to a `target` block from a `switch` block. + /// Returns info about switch values that lead from one block to another + /// block. See `SwitchSources`. #[inline] pub fn switch_sources(&self) -> &SwitchSources { self.cache.switch_sources.get_or_init(|| { |
