From 91f2d11e9ceebe35d0e23e645fc7747a2cded162 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Mon, 5 Aug 2024 13:52:39 +0200 Subject: [PATCH] Correct rust code block in *Dataflow Analysis* --- src/mir/dataflow.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/mir/dataflow.md b/src/mir/dataflow.md index 15bfd6ae..e6e4b9b1 100644 --- a/src/mir/dataflow.md +++ b/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(0_i32); // transmute was called! -} else { - 1_u32; // transmute was not called -}; +```rust +# unsafe fn example(some_cond: bool) { + let x = if some_cond { + std::mem::transmute::(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); + // 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