Skip to content

Commit

Permalink
Rollup merge of #93606 - JakobDegen:mischaracterized-preorder, r=oli-obk
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthiaskrgr authored Feb 3, 2022
2 parents 1abc0da + 3b52cca commit d9c74a6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions compiler/rustc_middle/src/mir/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ use super::*;

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

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

0 comments on commit d9c74a6

Please sign in to comment.