Skip to content

Commit 0e6ebf0

Browse files
Merge pull request #2987 from RalfJung/raw-addr-of
RFC 2582: fix implicit auto-deref of raw pointers
2 parents af927e4 + d8b995a commit 0e6ebf0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

text/2582-raw-reference-mir-operator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ This has the side-effect of being able to entirely remove reference-to-pointer-*
198198

199199
```rust
200200
let x: *mut Struct = NonNull::dangling().as_ptr();
201-
let field: *mut Field = &mut x.field;
201+
let field: *mut Field = &mut (*x).field;
202202
```
203203

204204
The lint as described in this RFC would nudge people to instead write
205205

206206
```rust
207207
let x: *mut Struct = NonNull::dangling().as_ptr();
208-
let field: *mut Field = &raw mut x.field;
208+
let field: *mut Field = &raw mut (*x).field;
209209
```
210210

211211
which is better, but still UB: we emit a `getelementptr inbounds` for the `.field` offset computation.

0 commit comments

Comments
 (0)