Skip to content

Commit 38adea9

Browse files
authored
Rollup merge of #93606 - JakobDegen:mischaracterized-preorder, r=oli-obk
Correct incorrect description of preorder traversals The internal documentation for the `Preorder` type gave an incorrect description (the description is not even correct for the example provided, since C is visited after one of its successors). This corrects the description, and adds in a sentence explaining more precisely how the traversals are performed.
2 parents 95efb2b + 3b52cca commit 38adea9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

compiler/rustc_middle/src/mir/traversal.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use super::*;
44

55
/// Preorder traversal of a graph.
66
///
7-
/// Preorder traversal is when each node is visited before any of its
8-
/// successors
7+
/// Preorder traversal is when each node is visited after at least one of its predecessors. If you
8+
/// are familar with some basic graph theory, then this performs a depth first search and returns
9+
/// nodes in order of discovery time.
910
///
1011
/// ```text
1112
///
@@ -82,8 +83,9 @@ impl<'a, 'tcx> Iterator for Preorder<'a, 'tcx> {
8283

8384
/// Postorder traversal of a graph.
8485
///
85-
/// Postorder traversal is when each node is visited after all of its
86-
/// successors, except when the successor is only reachable by a back-edge
86+
/// Postorder traversal is when each node is visited after all of its successors, except when the
87+
/// successor is only reachable by a back-edge. If you are familiar with some basic graph theory,
88+
/// then this performs a depth first search and returns nodes in order of completion time.
8789
///
8890
///
8991
/// ```text

0 commit comments

Comments
 (0)