Skip to content

Commit 9b21aa0

Browse files
committed
Document futility of printing temporary pointers
1 parent bd7aa57 commit 9b21aa0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

core/src/fmt/mod.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,17 @@ pub trait UpperHex {
975975
/// `p` formatting.
976976
///
977977
/// The `Pointer` trait should format its output as a memory location. This is commonly presented
978-
/// as hexadecimal.
978+
/// as hexadecimal. For more information on formatters, see [the module-level documentation][module].
979979
///
980-
/// For more information on formatters, see [the module-level documentation][module].
980+
/// Printing of pointers is not a reliable way to discover how Rust programs are implemented.
981+
/// The act of reading an address changes the program itself, and may change how the data is represented
982+
/// in memory, and may affect which optimizations are applied to the code.
983+
///
984+
/// The printed pointer values are not guaranteed to be stable nor unique identifiers of objects.
985+
/// Rust allows moving values to different memory locations, and may reuse the same memory locations
986+
/// for different purposes.
987+
///
988+
/// There is no guarantee that the printed value can be converted back to a pointer.
981989
///
982990
/// [module]: ../../std/fmt/index.html
983991
///

0 commit comments

Comments
 (0)