Skip to content

Commit 91f2d11

Browse files
xFrednetcamelid
authored andcommitted
Correct rust code block in *Dataflow Analysis*
1 parent f8fae75 commit 91f2d11

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/mir/dataflow.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,18 @@ value will be `true`, since our analysis is done as soon as we determine that
127127
`transmute` has been called. Our join operator will just be the boolean OR (`||`)
128128
operator. We use OR and not AND because of this case:
129129

130-
```
131-
let x = if some_cond {
132-
std::mem::transmute<i32, u32>(0_i32); // transmute was called!
133-
} else {
134-
1_u32; // transmute was not called
135-
};
136-
137-
// Has transmute been called by this point? We conservatively approximate that
138-
// as yes, and that is why we use the OR operator.
139-
println!("x: {}", x);
130+
```rust
131+
# unsafe fn example(some_cond: bool) {
132+
let x = if some_cond {
133+
std::mem::transmute::<i32, u32>(0_i32) // transmute was called!
134+
} else {
135+
1_u32 // transmute was not called
136+
};
137+
138+
// Has transmute been called by this point? We conservatively approximate that
139+
// as yes, and that is why we use the OR operator.
140+
println!("x: {}", x);
141+
# }
140142
```
141143

142144
## Inspecting the Results of a Dataflow Analysis

0 commit comments

Comments
 (0)