Skip to content

Commit fd79ed4

Browse files
committed
Add docs for BasicBlock
1 parent 255ceeb commit fd79ed4

File tree

1 file changed

+14
-0
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+14
-0
lines changed

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,19 @@ pub struct VarDebugInfo<'tcx> {
10761076
// BasicBlock
10771077

10781078
rustc_index::newtype_index! {
1079+
/// The unit of the MIR [control-flow graph][CFG].
1080+
///
1081+
/// There is no branching (e.g., `if`s, function calls, etc.) within a basic block, which makes
1082+
/// it easier to do [data-flow analyses] and optimizations. Basic blocks consist of a series of
1083+
/// [statements][`Statement`], ending with a [terminator][`Terminator`]. Basic blocks can have
1084+
/// multiple predecessors and successors.
1085+
///
1086+
/// Read more about basic blocks in the [rustc-dev-guide][guide-mir].
1087+
///
1088+
/// [CFG]: https://rustc-dev-guide.rust-lang.org/appendix/background.html#cfg
1089+
/// [data-flow analyses]:
1090+
/// https://rustc-dev-guide.rust-lang.org/appendix/background.html#what-is-a-dataflow-analysis
1091+
/// [guide-mir]: https://rustc-dev-guide.rust-lang.org/mir/
10791092
pub struct BasicBlock {
10801093
derive [HashStable]
10811094
DEBUG_FORMAT = "bb{}",
@@ -1092,6 +1105,7 @@ impl BasicBlock {
10921105
///////////////////////////////////////////////////////////////////////////
10931106
// BasicBlockData and Terminator
10941107

1108+
/// See [`BasicBlock`] for documentation on what basic blocks are at a high level.
10951109
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
10961110
pub struct BasicBlockData<'tcx> {
10971111
/// List of statements in this block.

0 commit comments

Comments
 (0)