From 9b21aa05574a294e25e24e812ae40e52529d3101 Mon Sep 17 00:00:00 2001 From: Kornel Date: Wed, 17 Jul 2024 22:39:31 +0100 Subject: [PATCH] Document futility of printing temporary pointers --- core/src/fmt/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/src/fmt/mod.rs b/core/src/fmt/mod.rs index 45c2b6a6a0f73..8fc43cb1875e3 100644 --- a/core/src/fmt/mod.rs +++ b/core/src/fmt/mod.rs @@ -975,9 +975,17 @@ pub trait UpperHex { /// `p` formatting. /// /// The `Pointer` trait should format its output as a memory location. This is commonly presented -/// as hexadecimal. +/// as hexadecimal. For more information on formatters, see [the module-level documentation][module]. /// -/// For more information on formatters, see [the module-level documentation][module]. +/// Printing of pointers is not a reliable way to discover how Rust programs are implemented. +/// The act of reading an address changes the program itself, and may change how the data is represented +/// in memory, and may affect which optimizations are applied to the code. +/// +/// The printed pointer values are not guaranteed to be stable nor unique identifiers of objects. +/// Rust allows moving values to different memory locations, and may reuse the same memory locations +/// for different purposes. +/// +/// There is no guarantee that the printed value can be converted back to a pointer. /// /// [module]: ../../std/fmt/index.html ///