about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-02-03 22:20:29 +0900
committerGitHub <noreply@github.com>2022-02-03 22:20:29 +0900
commit38adea96c53565f4c099375fd460a9cf3815bc65 (patch)
treebd2ce0617f3a3ebb6dc1178dc69975f83d51ddc7
parent95efb2b57853623a25b3b6cefc7d5dda03f923ab (diff)
parent3b52ccaa951240faf90e963ee2f5188085b6fb82 (diff)
downloadrust-38adea96c53565f4c099375fd460a9cf3815bc65.tar.gz
rust-38adea96c53565f4c099375fd460a9cf3815bc65.zip
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.
-rw-r--r--compiler/rustc_middle/src/mir/traversal.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/mir/traversal.rs b/compiler/rustc_middle/src/mir/traversal.rs
index 8c930fd161e..480f28620dc 100644
--- a/compiler/rustc_middle/src/mir/traversal.rs
+++ b/compiler/rustc_middle/src/mir/traversal.rs
@@ -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
 ///
@@ -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