@@ -1207,30 +1207,32 @@ extern "rust-intrinsic" {
1207
1207
1208
1208
/// Reinterprets the bits of a value of one type as another type.
1209
1209
///
1210
- /// Both types must have the same size. Neither the original, nor the result,
1211
- /// may be an [invalid value](../../nomicon/what-unsafe-does.html).
1210
+ /// Both types must have the same size. Compilation will fail if this is not guaranteed.
1212
1211
///
1213
1212
/// `transmute` is semantically equivalent to a bitwise move of one type
1214
1213
/// into another. It copies the bits from the source value into the
1215
1214
/// destination value, then forgets the original. Note that source and destination
1216
1215
/// are passed by-value, which means if `T` or `U` contains padding, that padding
1217
1216
/// might *not* be preserved by `transmute`.
1218
1217
///
1218
+ /// Both the argument and the result must be [valid](../../nomicon/what-unsafe-does.html) at
1219
+ /// their given type. Violating this condition leads to [undefined behavior][ub]. The compiler
1220
+ /// will generate code *assuming that you, the programmer, ensure that there will never be
1221
+ /// undefined behavior*. It is therefore your responsibility to guarantee that every value
1222
+ /// passed to `transmute` is valid at both types `T` and `U`. Failing to uphold this condition
1223
+ /// may lead to unexpeced and unstable compilation results. This makes `transmute` **incredibly
1224
+ /// unsafe**. `transmute` should be the absolute last resort.
1225
+ ///
1226
+ /// Transmuting pointers to integers in a `const` context is [undefined behavior][ub].
1227
+ /// Any attempt to use the resulting value for integer operations will abort const-evaluation.
1228
+ ///
1219
1229
/// Because `transmute` is a by-value operation, alignment of the *transmuted values
1220
1230
/// themselves* is not a concern. As with any other function, the compiler already ensures
1221
1231
/// both `T` and `U` are properly aligned. However, when transmuting values that *point
1222
1232
/// elsewhere* (such as pointers, references, boxes…), the caller has to ensure proper
1223
1233
/// alignment of the pointed-to values.
1224
1234
///
1225
- /// `transmute` is **incredibly** unsafe. There are a vast number of ways to
1226
- /// cause [undefined behavior][ub] with this function. `transmute` should be
1227
- /// the absolute last resort.
1228
- ///
1229
- /// Transmuting pointers to integers in a `const` context is [undefined behavior][ub].
1230
- /// Any attempt to use the resulting value for integer operations will abort const-evaluation.
1231
- ///
1232
- /// The [nomicon](../../nomicon/transmutes.html) has additional
1233
- /// documentation.
1235
+ /// The [nomicon](../../nomicon/transmutes.html) has additional documentation.
1234
1236
///
1235
1237
/// [ub]: ../../reference/behavior-considered-undefined.html
1236
1238
///
0 commit comments