Skip to content

Commit 7ea147e

Browse files
authored
Add an explanation shared to exclusive transmute (#344)
1 parent f6d6126 commit 7ea147e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/transmutes.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ boggling.
1919
* Transmute has an overloaded return type. If you do not specify the return type
2020
it may produce a surprising type to satisfy inference.
2121

22-
* Transmuting an `&` to `&mut` is UB.
22+
* Transmuting an `&` to `&mut` is UB. While certain usages may *appear* safe,
23+
note that the Rust optimizer is free to assume that a shared reference won't
24+
change through its lifetime and thus such transmutation will run afoul of those
25+
assumptions. So:
2326
* Transmuting an `&` to `&mut` is *always* UB.
2427
* No you can't do it.
2528
* No you're not special.

0 commit comments

Comments
 (0)