Skip to content

Commit ee9a38e

Browse files
committed
Document futility of printing temporary pointers
1 parent 8a9cccb commit ee9a38e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: library/core/src/fmt/mod.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -971,9 +971,14 @@ pub trait UpperHex {
971971
/// `p` formatting.
972972
///
973973
/// The `Pointer` trait should format its output as a memory location. This is commonly presented
974-
/// as hexadecimal.
974+
/// as hexadecimal. For more information on formatters, see [the module-level documentation][module].
975975
///
976-
/// For more information on formatters, see [the module-level documentation][module].
976+
/// Printing of pointers is not a reliable way to discover how Rust programs are implemented,
977+
/// because the act of reading an address of a value may change how the value is stored in memory,
978+
/// and prevent some code optimizations.
979+
///
980+
/// Rust may move values in memory, and reuse the same memory locations for different values, so
981+
/// the printed pointer values are not guaranteed to be stable nor unique identifiers of objects.
977982
///
978983
/// [module]: ../../std/fmt/index.html
979984
///

0 commit comments

Comments
 (0)