Skip to content

Commit 68aa4cc

Browse files
committed
fix code
1 parent 7db6ebb commit 68aa4cc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

reference/src/validity/function-pointers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ That makes this code UB:
1010

1111
```rust
1212
fn bad() {
13-
let x: fn() = unsafe { mem::transmute(0usize) } // This is UB!
13+
let x: fn() = unsafe { std::mem::transmute(0usize) }; // This is UB!
1414
}
1515
```
1616

1717
However, any integer value other than NULL is allowed for function pointers:
1818

1919
```rust
2020
fn good() {
21-
let x: fn() = unsafe { mem::transmute(1usize) } // This is not UB.
21+
let x: fn() = unsafe { std::mem::transmute(1usize) }; // This is not UB.
2222
}
2323
```
2424

rfcs/0000-unaligned-fn-ptr.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ When transmuting data to a function pointer, you must make sure it is non-null:
4242

4343
```rust
4444
fn bad() {
45-
let x: fn() = unsafe { mem::transmute(0usize) } // This is UB!
45+
let x: fn() = unsafe { std::mem::transmute(0usize) }; // This is UB!
4646
}
4747
```
4848

4949
Transmuting any non-null value to a function pointer is defined behavior.
5050

5151
```rust
5252
fn good() {
53-
let x: fn() = unsafe { mem::transmute(1usize) } // This is not UB.
53+
let x: fn() = unsafe { std::mem::transmute(1usize) }; // This is not UB.
5454
}
5555
```
5656

0 commit comments

Comments
 (0)