about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide
diff options
context:
space:
mode:
authorxFrednet <xFrednet@gmail.com>2024-08-05 13:52:39 +0200
committerNoah Lev <camelidcamel@gmail.com>2024-08-07 20:32:37 -0700
commitee84180c2c5ae380a99ddbd7746e10d0237e1b0b (patch)
treed499e70c71ce77c728db3dcc6db03858f24dcfd7 /src/doc/rustc-dev-guide
parent557ec475d93ba2d76c758cc3aa18873141f5548d (diff)
Correct rust code block in *Dataflow Analysis*
Diffstat (limited to 'src/doc/rustc-dev-guide')
-rw-r--r--src/doc/rustc-dev-guide/src/mir/dataflow.md22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/doc/rustc-dev-guide/src/mir/dataflow.md b/src/doc/rustc-dev-guide/src/mir/dataflow.md
index 15bfd6aed0f..e6e4b9b1a23 100644
--- a/src/doc/rustc-dev-guide/src/mir/dataflow.md
+++ b/src/doc/rustc-dev-guide/src/mir/dataflow.md
@@ -127,16 +127,18 @@ value will be `true`, since our analysis is done as soon as we determine that
 `transmute` has been called. Our join operator will just be the boolean OR (`||`)
 operator. We use OR and not AND because of this case:
 
-```
-let x = if some_cond {
-    std::mem::transmute<i32, u32>(0_i32); // transmute was called!
-} else {
-    1_u32; // transmute was not called
-};
-
-// Has transmute been called by this point? We conservatively approximate that
-// as yes, and that is why we use the OR operator.
-println!("x: {}", x);
+```rust
+# unsafe fn example(some_cond: bool) {
+    let x = if some_cond {
+        std::mem::transmute::<i32, u32>(0_i32) // transmute was called!
+    } else {
+        1_u32 // transmute was not called
+    };
+
+    // Has transmute been called by this point? We conservatively approximate that
+    // as yes, and that is why we use the OR operator.
+    println!("x: {}", x);
+# }
 ```
 
 ## Inspecting the Results of a Dataflow Analysis